class Sol::RuntimeModel::SolFunction

Represents a method defined in the runtime

Public Class Methods

new(params, body) click to toggle source
# File lib/sol/runtime/function.rb, line 10
def initialize(params, body)

        @params = params

        @body = body

end

Public Instance Methods

call(reciever, arguments) click to toggle source
# File lib/sol/runtime/function.rb, line 18
def call(reciever, arguments)

        # Create a context of evaluation in which the method will execute
        context = Context.new(reciever)

        if @params.class == "NullClass"

                # Assign arguments to local variables
                @params.to_enum.each_with_index do |param, index|

                        context.locals[param] = arguments[index]

                end

        end

        return @body.eval(context)

end