class Q::Syntax::Function

Public Instance Methods

args() click to toggle source
# File lib/q/syntax.rb, line 26
def args
  arguments.elements.map do |argument|
    argument.identifier.text_value
  end
end
eval(prefscope) click to toggle source
# 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