gets rid of conversion approach, ast compiles

This commit is contained in:
Torsten Ruger
2014-05-05 10:13:49 +03:00
parent c67ee7f6f3
commit 99da6f5be3
5 changed files with 21 additions and 43 deletions

View File

@ -6,32 +6,24 @@ module Vm
def initialize(name , args)
super(name)
@name = name
@values = args
@args = args
@function = nil
end
attr_reader :function
def args
values
end
attr_reader :function , :args
def compile context
def assign_function context
@function = context.program.get_function @name
if @function
raise "error #{self}" unless @function.arity != @values.length
raise "error #{self}" unless @function.arity != args.length
else
@function = context.program.get_or_create_function @name
end
args.each_with_index do |arg |
arg.compile context
end
end
def load_args
args.each_with_index do |arg , index|
arg.load index
end
#puts "funcall #{self.inspect}"
self.do_call
end
def do_call
Machine.instance.function_call self
end

View File

@ -96,5 +96,3 @@ module Vm
end
end
require "ast/conversion"