remove save return

This commit is contained in:
Torsten Ruger 2015-11-02 20:11:12 +02:00
parent ddb1df7362
commit 45bd4bfdc6
2 changed files with 16 additions and 10 deletions

View File

@ -84,8 +84,7 @@ module Soml
def init_method
source = "_init_method"
@method.instructions = Register::Label.new(source, "#{method.for_class.name}.#{method.name}")
@current = method.instructions
add_code enter = Register.save_return(source, :message , :return_address)
@current = enter = method.instructions
add_code Register::Label.new( source, "return")
# move the current message to new_message
add_code Register::RegisterTransfer.new(source, Register.message_reg , Register.new_message_reg )

View File

@ -4,7 +4,6 @@ module Soml
def on_call statement
#puts statement
name_s , arguments , receiver = *statement
name = name_s.to_a.first
raise "not inside method " unless @method
reset_regs
#move the new message (that we need to populate to make a call) to std register
@ -24,21 +23,30 @@ module Soml
end
# move our receiver there
add_code Register.set_slot( statement , me , :new_message , :receiver)
set_message_details(name_s , arguments)
set_arguments(arguments)
#puts "clazz #{clazz.name}"
raise "No such class #{me.type}" unless clazz
method = clazz.get_instance_method(name)
#puts Register.machine.space.get_class_by_name(:Integer).method_names.to_a
raise "Method not implemented #{me.type}.#{name}" unless method
Register.issue_call( self , method )
do_call(clazz , statement)
ret = use_reg( :Integer )
# the effect of the method is that the NewMessage Return slot will be filled, return it
# but move it into a register too
add_code Register.get_slot(statement, :message , :return_value , ret )
ret
end
private
def do_call clazz , statement
name = statement.first.first
#puts "clazz #{clazz.name}"
raise "No such class #{me.type}" unless clazz
method = clazz.get_instance_method(name)
#puts Register.machine.space.get_class_by_name(:Integer).method_names.to_a
raise "Method not implemented #{me.type}.#{name}" unless method
ret_tmp = use_reg(:Label)
add_code Register::LoadConstant.new(statement.first, method.instructions , ret_tmp)
add_code Register.set_slot(statement, ret_tmp , :message , :return_address)
Register.issue_call( self , method )
end
def set_message_details name_s , arguments
name = name_s.to_a.first
# load method name and set to new message (for exceptions/debug)
@ -49,7 +57,6 @@ module Soml
len_tmp = use_reg(:Integer , arguments.to_a.length )
add_code Register::LoadConstant.new(arguments, arguments.to_a.length , len_tmp)
add_code Register.set_slot( arguments , len_tmp , :new_message , :indexed_length)
end
def set_arguments arguments
# reset tmp regs for each and load result into new_message