Class: Citrus::Case

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

Instance Method Summary collapse

Instance Method Details

#codegen(g) ⇒ Object



171
172
173
174
175
176
177
178
179
180
181
182
# File 'lib/citrus/nodes.rb', line 171

def codegen(g)
  cases = {}
  whens.each do |w|
    cases[w.val.codegen(g).last] = g.block do |gb|
      w.elements.each { |e| e.expression.codegen(gb) }
    end
  end
  eb = g.block do |gb|
    else_expressions.each { |e| e.codegen(gb) }
  end
  g.case(switch.codegen(g).last, cases, eb)
end