lib/nydp/interpreted_function.rb in nydp-0.1.13.2 vs lib/nydp/interpreted_function.rb in nydp-0.1.14
- old
+ new
@@ -2,11 +2,11 @@
require 'nydp/lexical_context_builder'
require 'nydp/closure'
module Nydp
class PopArg
- def self.execute vm ; vm.pop_arg ; end
+ def self.execute vm ; vm.args.pop ; end
def self.to_s ; "" ; end
def self.inspect ; "#pop_arg" ; end
end
class InterpretedFunction
@@ -14,35 +14,40 @@
extend Helper
attr_accessor :arg_names, :body, :context_builder
def invoke_1 vm, parent_context
- vm.push_instructions self.body, LexicalContext.new(parent_context)
+ vm.instructions.push self.body
+ vm.contexts.push LexicalContext.new(parent_context)
end
def invoke_2 vm, parent_context, arg
lc = LexicalContext.new parent_context
set_args_1 lc, arg
- vm.push_instructions self.body, lc
+ vm.instructions.push self.body
+ vm.contexts.push lc
end
def invoke_3 vm, parent_context, arg_0, arg_1
lc = LexicalContext.new parent_context
set_args_2 lc, arg_0, arg_1
- vm.push_instructions self.body, lc
+ vm.instructions.push self.body
+ vm.contexts.push lc
end
def invoke_4 vm, parent_context, arg_0, arg_1, arg_2
lc = LexicalContext.new parent_context
set_args_3 lc, arg_0, arg_1, arg_2
- vm.push_instructions self.body, lc
+ vm.instructions.push self.body
+ vm.contexts.push lc
end
def invoke vm, parent_context, arg_values
lc = LexicalContext.new parent_context
set_args lc, arg_values
- vm.push_instructions self.body, lc
+ vm.instructions.push self.body
+ vm.contexts.push lc
end
def setup_context context, names, values
if pair? names
context.set names.car, values.car
@@ -83,10 +88,10 @@
hsh[arg_list] = hsh.size
end
end
def execute vm
- vm.push_arg Closure.new(self, vm.peek_context)
+ vm.push_arg Closure.new(self, vm.current_context)
end
def nydp_type ; "fn" ; end
def inspect ; to_s ; end
def to_s