Class: Atomy::Code::Sequence
Instance Attribute Summary collapse
-
#nodes ⇒ Object
readonly
Returns the value of attribute nodes.
Instance Method Summary collapse
- #bytecode(gen, mod) ⇒ Object
-
#initialize(nodes) ⇒ Sequence
constructor
A new instance of Sequence.
Constructor Details
#initialize(nodes) ⇒ Sequence
Returns a new instance of Sequence.
6 7 8 |
# File 'lib/atomy/code/sequence.rb', line 6 def initialize(nodes) @nodes = nodes end |
Instance Attribute Details
#nodes ⇒ Object (readonly)
Returns the value of attribute nodes.
4 5 6 |
# File 'lib/atomy/code/sequence.rb', line 4 def nodes @nodes end |
Instance Method Details
#bytecode(gen, mod) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/atomy/code/sequence.rb', line 10 def bytecode(gen, mod) if @nodes.empty? gen.push_nil return end @nodes.each.with_index do |node, idx| gen.pop unless idx == 0 mod.compile(gen, node) end end |