Class: Citrus::If

Inherits:
Node
  • Object
show all
Defined in:
lib/citrus/nodes.rb

Instance Method Summary collapse

Instance Method Details

#codegen(g) ⇒ Object



140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# File 'lib/citrus/nodes.rb', line 140

def codegen(g)
  tb = g.block do |gb|
    expressions.each { |e| e.codegen(gb) }
  end
  elfs = elsifs.each do |elf|
    [elf.condition.codegen(g).last,
    g.block do |gb|
      elf.elements.each { |e| e.expression.codegen(gb) }
    end]
  end
  fb = g.block do |gb|
    else_expressions.each { |e| e.codegen(gb) }
  end
  cond = condition.is_a?(Expression) ? condition.codegen(g).last : condition.codegen(g)
  g.condition(cond, tb, fb, elfs)
end