use transfer factory

This commit is contained in:
Torsten Ruger 2016-12-28 18:37:15 +02:00
parent 57c038f13b
commit 4cf732d395
4 changed files with 8 additions and 8 deletions

View File

@ -47,7 +47,7 @@ module Register
#
def save_message(compiler)
r8 = RegisterValue.new( :r8 , :Message)
compiler.add_code RegisterTransfer.new("save_message", Register.message_reg , r8 )
compiler.add_code Register.transfer("save_message", Register.message_reg , r8 )
end
def restore_message(compiler)
@ -55,9 +55,9 @@ module Register
return_tmp = Register.tmp_reg :Integer
source = "_restore_message"
# get the sys return out of the way
compiler.add_code RegisterTransfer.new(source, Register.message_reg , return_tmp )
compiler.add_code Register.transfer(source, Register.message_reg , return_tmp )
# load the stored message into the base RegisterMachine
compiler.add_code RegisterTransfer.new(source, r8 , Register.message_reg )
compiler.add_code Register.transfer(source, r8 , Register.message_reg )
# save the return value into the message
compiler.add_code Register.reg_to_slot( source , return_tmp , :message , :return_value )
end

View File

@ -20,10 +20,10 @@ module Register
ret_tmp = compiler.use_reg(:Label)
compiler.add_code Register.load_constant("#{callee.name} load ret", return_label , ret_tmp)
compiler.add_code Register.reg_to_slot("#{callee.name} store ret", ret_tmp , :new_message , :return_address)
compiler.add_code RegisterTransfer.new("#{callee.name} move new message", Register.new_message_reg , Register.message_reg )
compiler.add_code Register.transfer("#{callee.name} move new message", Register.new_message_reg , Register.message_reg )
compiler.add_code FunctionCall.new( "#{callee.name} call" , callee )
compiler.add_code return_label
compiler.add_code Register::RegisterTransfer.new("#{callee.name} remove new message", Register.message_reg , Register.new_message_reg )
compiler.add_code Register.transfer("#{callee.name} remove new message", Register.message_reg , Register.new_message_reg )
compiler.add_code Register.slot_to_reg("#{callee.name} restore message" , :new_message , :caller , :message )
end
end

View File

@ -29,7 +29,7 @@ module Register
"RegisterTransfer: #{from} -> #{to}"
end
end
def self.transfer source , from , to
RegisterTransfer.new source , from , to
def self.transfer( source , from , to)
RegisterTransfer.new( source , from , to)
end
end

View File

@ -51,7 +51,7 @@ module Typed
def handle_special_message(statement)
reg = use_reg :Message
add_code Register::RegisterTransfer.new( "#{statement} load message", Register.message_reg , reg )
add_code Register.transfer( "#{statement} load message", Register.message_reg , reg )
return reg
end
end #module