Class: Rubinius::AST::If
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#condition ⇒ Object
Returns the value of attribute condition.
-
#else ⇒ Object
Returns the value of attribute else.
Attributes inherited from Node
Instance Method Summary collapse
-
#initialize(line, condition, body, else_body) ⇒ If
constructor
A new instance of If.
- #to_sexp ⇒ Object
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, condition, body, else_body) ⇒ If
Returns a new instance of If.
138 139 140 141 142 143 |
# File 'lib/compiler/ast/control_flow.rb', line 138 def initialize(line, condition, body, else_body) @line = line @condition = condition @body = body || NilLiteral.new(line) @else = else_body || NilLiteral.new(line) end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
136 137 138 |
# File 'lib/compiler/ast/control_flow.rb', line 136 def body @body end |
#condition ⇒ Object
Returns the value of attribute condition.
136 137 138 |
# File 'lib/compiler/ast/control_flow.rb', line 136 def condition @condition end |
#else ⇒ Object
Returns the value of attribute else.
136 137 138 |
# File 'lib/compiler/ast/control_flow.rb', line 136 def else @else end |
Instance Method Details
#to_sexp ⇒ Object
145 146 147 148 |
# File 'lib/compiler/ast/control_flow.rb', line 145 def to_sexp else_sexp = @else.kind_of?(NilLiteral) ? nil : @else.to_sexp [:if, @condition.to_sexp, @body.to_sexp, else_sexp] end |