Class: CodeTools::AST::ReceiverCase

Inherits:
Case
  • Object
show all
Defined in:
lib/rubinius/code/ast/control_flow.rb

Instance Attribute Summary collapse

Attributes inherited from Case

#else, #whens

Attributes inherited from Node

#line

Instance Method Summary collapse

Methods inherited from Case

#defined, #to_sexp

Methods inherited from Node

#ascii_graph, #attributes, #children, #defined, match_arguments?, match_send?, #new_block_generator, #new_generator, #node_name, #or_bytecode, #pos, #set_child, #to_sexp, #transform, transform, transform_comment, transform_kind, transform_kind=, transform_name, #value_defined, #visit, #walk

Constructor Details

#initialize(line, receiver, whens, else_body) ⇒ ReceiverCase

Returns a new instance of ReceiverCase.



51
52
53
54
55
56
# File 'lib/rubinius/code/ast/control_flow.rb', line 51

def initialize(line, receiver, whens, else_body)
  @line = line
  @receiver = receiver
  @whens = whens
  @else = else_body || NilLiteral.new(line)
end

Instance Attribute Details

#receiverObject

Returns the value of attribute receiver.



49
50
51
# File 'lib/rubinius/code/ast/control_flow.rb', line 49

def receiver
  @receiver
end

Instance Method Details

#bytecode(g) ⇒ Object



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/rubinius/code/ast/control_flow.rb', line 58

def bytecode(g)
  pos(g)

  done = g.new_label

  @receiver.bytecode(g)

  @whens.each do |w|
    w.receiver_bytecode(g, done)
  end

  g.pop
  @else.bytecode(g)

  # See command in if about why using line 0
  g.set_line 0

  done.set!
end

#receiver_sexpObject



78
79
80
# File 'lib/rubinius/code/ast/control_flow.rb', line 78

def receiver_sexp
  @receiver.to_sexp
end