remove save return
This commit is contained in:
parent
ddb1df7362
commit
45bd4bfdc6
@ -84,8 +84,7 @@ module Soml
|
|||||||
def init_method
|
def init_method
|
||||||
source = "_init_method"
|
source = "_init_method"
|
||||||
@method.instructions = Register::Label.new(source, "#{method.for_class.name}.#{method.name}")
|
@method.instructions = Register::Label.new(source, "#{method.for_class.name}.#{method.name}")
|
||||||
@current = method.instructions
|
@current = enter = method.instructions
|
||||||
add_code enter = Register.save_return(source, :message , :return_address)
|
|
||||||
add_code Register::Label.new( source, "return")
|
add_code Register::Label.new( source, "return")
|
||||||
# move the current message to new_message
|
# move the current message to new_message
|
||||||
add_code Register::RegisterTransfer.new(source, Register.message_reg , Register.new_message_reg )
|
add_code Register::RegisterTransfer.new(source, Register.message_reg , Register.new_message_reg )
|
||||||
|
@ -4,7 +4,6 @@ module Soml
|
|||||||
def on_call statement
|
def on_call statement
|
||||||
#puts statement
|
#puts statement
|
||||||
name_s , arguments , receiver = *statement
|
name_s , arguments , receiver = *statement
|
||||||
name = name_s.to_a.first
|
|
||||||
raise "not inside method " unless @method
|
raise "not inside method " unless @method
|
||||||
reset_regs
|
reset_regs
|
||||||
#move the new message (that we need to populate to make a call) to std register
|
#move the new message (that we need to populate to make a call) to std register
|
||||||
@ -24,21 +23,30 @@ module Soml
|
|||||||
end
|
end
|
||||||
# move our receiver there
|
# move our receiver there
|
||||||
add_code Register.set_slot( statement , me , :new_message , :receiver)
|
add_code Register.set_slot( statement , me , :new_message , :receiver)
|
||||||
|
|
||||||
set_message_details(name_s , arguments)
|
set_message_details(name_s , arguments)
|
||||||
set_arguments(arguments)
|
set_arguments(arguments)
|
||||||
#puts "clazz #{clazz.name}"
|
do_call(clazz , statement)
|
||||||
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 )
|
|
||||||
ret = use_reg( :Integer )
|
ret = use_reg( :Integer )
|
||||||
# the effect of the method is that the NewMessage Return slot will be filled, return it
|
# the effect of the method is that the NewMessage Return slot will be filled, return it
|
||||||
# but move it into a register too
|
# but move it into a register too
|
||||||
add_code Register.get_slot(statement, :message , :return_value , ret )
|
add_code Register.get_slot(statement, :message , :return_value , ret )
|
||||||
ret
|
ret
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
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
|
def set_message_details name_s , arguments
|
||||||
name = name_s.to_a.first
|
name = name_s.to_a.first
|
||||||
# load method name and set to new message (for exceptions/debug)
|
# 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 )
|
len_tmp = use_reg(:Integer , arguments.to_a.length )
|
||||||
add_code Register::LoadConstant.new(arguments, arguments.to_a.length , len_tmp)
|
add_code Register::LoadConstant.new(arguments, arguments.to_a.length , len_tmp)
|
||||||
add_code Register.set_slot( arguments , len_tmp , :new_message , :indexed_length)
|
add_code Register.set_slot( arguments , len_tmp , :new_message , :indexed_length)
|
||||||
|
|
||||||
end
|
end
|
||||||
def set_arguments arguments
|
def set_arguments arguments
|
||||||
# reset tmp regs for each and load result into new_message
|
# reset tmp regs for each and load result into new_message
|
||||||
|
Loading…
x
Reference in New Issue
Block a user