Parent

Class Index [+]

Quicksearch

RKelly::JS::Function

Attributes

body[R]

(Not documented)

arguments[R]

(Not documented)

Public Class Methods

create(*args) click to toggle source

(Not documented)

# File lib/rkelly/js/function.rb, line 5
        def create(*args)
          if args.length > 0
            parser = RKelly::Parser.new
            body = args.pop
            tree = parser.parse("function x(#{args.join(',')}) { #{body} }")
            func = tree.value.first
            self.new(func.function_body, func.arguments)
          else
            self.new
          end
        end
new(body = nil, arguments = []) click to toggle source

(Not documented)

# File lib/rkelly/js/function.rb, line 19
      def initialize(body = nil, arguments = [])
        super()
        @body = body
        @arguments = arguments
        self['prototype'] = JS::FunctionPrototype.new(self)
        self['toString'] = :undefined
        self['length'] = arguments.length
      end

Public Instance Methods

js_call(scope_chain, *params) click to toggle source

(Not documented)

# File lib/rkelly/js/function.rb, line 28
      def js_call(scope_chain, *params)
        arguments.each_with_index { |name, i|
          scope_chain[name.value] = params[i] || RKelly::Runtime::UNDEFINED
        }
        function_visitor  = RKelly::Visitors::FunctionVisitor.new(scope_chain)
        eval_visitor      = RKelly::Visitors::EvaluationVisitor.new(scope_chain)
        body.accept(function_visitor) if body
        body.accept(eval_visitor) if body
      end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.