class Malady::AST::IfNode

Attributes

condition[R]
else_branch[R]
then_branch[R]

Public Class Methods

new(filename, line, condition, then_branch, else_branch) click to toggle source
Calls superclass method Malady::AST::Node::new
# 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

Public Instance Methods

bytecode(g) click to toggle source
# 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