Class: Malady::AST::Program
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
Attributes inherited from Node
Instance Method Summary collapse
- #bytecode(g) ⇒ Object
-
#initialize(filename, line, body) ⇒ Program
constructor
A new instance of Program.
Methods inherited from Node
Constructor Details
#initialize(filename, line, body) ⇒ Program
Returns a new instance of Program.
19 20 21 22 |
# File 'lib/malady/ast.rb', line 19 def initialize(filename, line, body) super @body = body end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
17 18 19 |
# File 'lib/malady/ast.rb', line 17 def body @body end |
Instance Method Details
#bytecode(g) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/malady/ast.rb', line 24 def bytecode(g) g.file = (filename || :"(malady)").to_sym pos(g) body.each_with_index do |expression, idx| expression.bytecode(g) g.pop unless idx == body.size - 1 end g.finalize end |