save and restore the right registers

This commit is contained in:
Torsten Ruger
2014-05-22 21:55:17 +03:00
parent 4f0b769e82
commit 86e73bf1ba
5 changed files with 22 additions and 17 deletions

View File

@ -11,25 +11,14 @@ module Ast
function = context.program.get_or_create_function(name)
raise "Forward declaration not implemented (#{name}) #{inspect}" if function == nil
call = Vm::CallSite.new( name , params , function)
save_locals context , into
current_function = context.function
current_function.save_locals(context , into) if current_function
call.load_args into
call.do_call into
restore_locals context , into
current_function.restore_locals(context , into) if current_function
function.return_type
end
def save_locals context , into
into.instance_eval do
push [:r0,:r1 , :r2 , :r3]
end
end
def restore_locals context , into
into.instance_eval do
pop [:r0,:r1, :r2 , :r3]
end
end
def inspect
self.class.name + ".new(" + name.inspect + ", ["+
args.collect{|m| m.inspect }.join( ",") +"] )"