Class: Malady::AST::IfNode
Instance Attribute Summary collapse
-
#condition ⇒ Object
readonly
Returns the value of attribute condition.
-
#else_branch ⇒ Object
readonly
Returns the value of attribute else_branch.
-
#then_branch ⇒ Object
readonly
Returns the value of attribute then_branch.
Attributes inherited from Node
Instance Method Summary collapse
- #bytecode(g) ⇒ Object
-
#initialize(filename, line, condition, then_branch, else_branch) ⇒ IfNode
constructor
A new instance of IfNode.
Methods inherited from Node
Constructor Details
#initialize(filename, line, condition, then_branch, else_branch) ⇒ IfNode
Returns a new instance of IfNode.
145 146 147 148 149 150 |
# File 'lib/malady/ast.rb', line 145 def initialize(filename, line, condition, then_branch, else_branch) super @condition = condition @then_branch = then_branch @else_branch = else_branch end |
Instance Attribute Details
#condition ⇒ Object (readonly)
Returns the value of attribute condition.
144 145 146 |
# File 'lib/malady/ast.rb', line 144 def condition @condition end |
#else_branch ⇒ Object (readonly)
Returns the value of attribute else_branch.
144 145 146 |
# File 'lib/malady/ast.rb', line 144 def else_branch @else_branch end |
#then_branch ⇒ Object (readonly)
Returns the value of attribute then_branch.
144 145 146 |
# File 'lib/malady/ast.rb', line 144 def then_branch @then_branch end |
Instance Method Details
#bytecode(g) ⇒ Object
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/malady/ast.rb', line 152 def bytecode(g) pos(g) end_label = g.new_label else_label = g.new_label condition.bytecode(g) g.goto_if_false else_label then_branch.bytecode(g) g.goto end_label else_label.set! else_branch.bytecode(g) end_label.set! end |