Class: Q::Syntax::Function
- Inherits:
-
Treetop::Runtime::SyntaxNode
- Object
- Treetop::Runtime::SyntaxNode
- Q::Syntax::Function
- Defined in:
- lib/q/syntax.rb
Instance Method Summary collapse
Instance Method Details
#args ⇒ Object
26 27 28 29 30 |
# File 'lib/q/syntax.rb', line 26 def args arguments.elements.map do |argument| argument.identifier.text_value end end |
#eval(prefscope) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/q/syntax.rb', line 7 def eval prefscope defargs = args prefscope['_'] = this = lambda { |scope| argscope = Q::Scope.new defargs.each_with_index do |arg, i| argscope[arg] = scope.args[i] end fscope = Q::Scope.new [argscope, scope, prefscope] fscope.this = this fscope['_'] = statements.eval fscope return fscope.this } end |