Class: Halunke::FunctionNode
- Inherits:
-
Struct
- Object
- Struct
- Halunke::FunctionNode
- Defined in:
- lib/halunke/nodes.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#params ⇒ Object
Returns the value of attribute params.
-
#te ⇒ Object
Returns the value of attribute te.
-
#ts ⇒ Object
Returns the value of attribute ts.
Instance Method Summary collapse
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body
76 77 78 |
# File 'lib/halunke/nodes.rb', line 76 def body @body end |
#params ⇒ Object
Returns the value of attribute params
76 77 78 |
# File 'lib/halunke/nodes.rb', line 76 def params @params end |
#te ⇒ Object
Returns the value of attribute te
76 77 78 |
# File 'lib/halunke/nodes.rb', line 76 def te @te end |
#ts ⇒ Object
Returns the value of attribute ts
76 77 78 |
# File 'lib/halunke/nodes.rb', line 76 def ts @ts end |
Instance Method Details
#==(other) ⇒ Object
86 87 88 89 90 |
# File 'lib/halunke/nodes.rb', line 86 def ==(other) other.is_a?(FunctionNode) && params == other.params && body == other.body end |
#eval(context) ⇒ Object
77 78 79 80 81 82 83 84 |
# File 'lib/halunke/nodes.rb', line 77 def eval(context) raise HEmptyFunction.new("This function would not return anything, in Halunke every function needs to return something.", source_code_position) if body.empty? signature = params.nodes.map(&:node).map(&:value) context["Function"].new(signature, lambda { |call_context| body.eval(call_context) }) end |
#source_code_position ⇒ Object
92 93 94 |
# File 'lib/halunke/nodes.rb', line 92 def source_code_position SourceCodePosition.new(ts, te) end |