Class: SetConstantNode
- Inherits:
-
Struct
- Object
- Struct
- SetConstantNode
- Defined in:
- lib/toylang/ast/nodes.rb,
lib/toylang/interpreter/evaluation.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name
36 37 38 |
# File 'lib/toylang/ast/nodes.rb', line 36 def name @name end |
#value ⇒ Object
Returns the value of attribute value
36 37 38 |
# File 'lib/toylang/ast/nodes.rb', line 36 def value @value end |
Instance Method Details
#eval(context) ⇒ Object
63 64 65 66 67 |
# File 'lib/toylang/interpreter/evaluation.rb', line 63 def eval(context) raise "Unable to re-assigne constant: #{name}" unless context[name].nil? context[name] = value.eval(context) end |