Class: Rubinius::AST::Case

Inherits:
Node
  • Object
show all
Defined in:
lib/compiler/ast/control_flow.rb

Direct Known Subclasses

ReceiverCase

Instance Attribute Summary collapse

Attributes inherited from Node

#line

Instance Method Summary collapse

Methods inherited from Node

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

Constructor Details

#initialize(line, whens, else_body) ⇒ Case

Returns a new instance of Case.



8
9
10
11
12
# File 'lib/compiler/ast/control_flow.rb', line 8

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

Instance Attribute Details

#elseObject

Returns the value of attribute else.



6
7
8
# File 'lib/compiler/ast/control_flow.rb', line 6

def else
  @else
end

#whensObject

Returns the value of attribute whens.



6
7
8
# File 'lib/compiler/ast/control_flow.rb', line 6

def whens
  @whens
end

Instance Method Details

#receiver_sexpObject



14
15
16
# File 'lib/compiler/ast/control_flow.rb', line 14

def receiver_sexp
  nil
end

#to_sexpObject



18
19
20
21
22
23
24
# File 'lib/compiler/ast/control_flow.rb', line 18

def to_sexp
  else_sexp = @else.kind_of?(NilLiteral) ? nil : @else.to_sexp
  sexp = [:case, receiver_sexp]
  sexp << [:whens] + @whens.map { |x| x.to_sexp }
  sexp << else_sexp
  sexp
end