Class: DefNode
- Inherits:
-
Struct
- Object
- Struct
- DefNode
- Defined in:
- lib/toylang/ast/nodes.rb,
lib/toylang/interpreter/evaluation.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#name ⇒ Object
Returns the value of attribute name.
-
#params ⇒ Object
Returns the value of attribute params.
Instance Method Summary collapse
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body
41 42 43 |
# File 'lib/toylang/ast/nodes.rb', line 41 def body @body end |
#name ⇒ Object
Returns the value of attribute name
41 42 43 |
# File 'lib/toylang/ast/nodes.rb', line 41 def name @name end |
#params ⇒ Object
Returns the value of attribute params
41 42 43 |
# File 'lib/toylang/ast/nodes.rb', line 41 def params @params end |
Instance Method Details
#eval(context) ⇒ Object
93 94 95 96 |
# File 'lib/toylang/interpreter/evaluation.rb', line 93 def eval(context) method = ToyLangMethod.new(params, body) context.current_class.runtime_methods[name] = method end |