getting better, but somethings off

This commit is contained in:
Torsten Ruger
2014-05-05 09:35:40 +03:00
parent a61170942f
commit 7c0aa8ae7d
10 changed files with 138 additions and 51 deletions

View File

@@ -2,31 +2,37 @@ module Vm
# name and args , return
class FunctionCall < Value
class FunctionCall < Block
def initialize(name , args)
super(name)
@name = name
@args = args
@values = args
@function = nil
end
attr_reader :name , :args , :function
attr_reader :function
def args
values
end
def compile context
@function = context.program.get_function @name
if @function
raise "error #{self}" unless function.arity != @args.length
raise "error #{self}" unless @function.arity != @values.length
else
@function = context.program.get_or_create_function @name
end
args.each_with_index do |arg , index|
arg.load
args.each_with_index do |arg |
arg.compile context
end
args.each_with_index do |arg , index|
arg.load index
end
#puts "funcall #{self.inspect}"
self.call
self.do_call
end
def call
def do_call
Machine.instance.function_call self
end
end