Class: ProgramNode
- Inherits:
-
Object
- Object
- ProgramNode
- Defined in:
- lib/nodes.rb
Instance Attribute Summary collapse
-
#statements ⇒ Object
readonly
Returns the value of attribute statements.
Instance Method Summary collapse
- #evaluate ⇒ Object
-
#initialize(statements) ⇒ ProgramNode
constructor
A new instance of ProgramNode.
Constructor Details
#initialize(statements) ⇒ ProgramNode
Returns a new instance of ProgramNode.
161 162 163 |
# File 'lib/nodes.rb', line 161 def initialize(statements) @statements = statements end |
Instance Attribute Details
#statements ⇒ Object (readonly)
Returns the value of attribute statements.
160 161 162 |
# File 'lib/nodes.rb', line 160 def statements @statements end |
Instance Method Details
#evaluate ⇒ Object
165 166 167 168 169 170 171 172 173 |
# File 'lib/nodes.rb', line 165 def evaluate global_scope = Scope.new result = nil @statements.each do |statement| result = statement.evaluate(global_scope) return result.value if statement.is_a?(ReturnNode) end return result end |