use transfer factory
This commit is contained in:
parent
57c038f13b
commit
4cf732d395
@ -47,7 +47,7 @@ module Register
|
|||||||
#
|
#
|
||||||
def save_message(compiler)
|
def save_message(compiler)
|
||||||
r8 = RegisterValue.new( :r8 , :Message)
|
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
|
end
|
||||||
|
|
||||||
def restore_message(compiler)
|
def restore_message(compiler)
|
||||||
@ -55,9 +55,9 @@ module Register
|
|||||||
return_tmp = Register.tmp_reg :Integer
|
return_tmp = Register.tmp_reg :Integer
|
||||||
source = "_restore_message"
|
source = "_restore_message"
|
||||||
# get the sys return out of the way
|
# 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
|
# 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
|
# save the return value into the message
|
||||||
compiler.add_code Register.reg_to_slot( source , return_tmp , :message , :return_value )
|
compiler.add_code Register.reg_to_slot( source , return_tmp , :message , :return_value )
|
||||||
end
|
end
|
||||||
|
@ -20,10 +20,10 @@ module Register
|
|||||||
ret_tmp = compiler.use_reg(:Label)
|
ret_tmp = compiler.use_reg(:Label)
|
||||||
compiler.add_code Register.load_constant("#{callee.name} load ret", return_label , ret_tmp)
|
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 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 FunctionCall.new( "#{callee.name} call" , callee )
|
||||||
compiler.add_code return_label
|
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 )
|
compiler.add_code Register.slot_to_reg("#{callee.name} restore message" , :new_message , :caller , :message )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -29,7 +29,7 @@ module Register
|
|||||||
"RegisterTransfer: #{from} -> #{to}"
|
"RegisterTransfer: #{from} -> #{to}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
def self.transfer source , from , to
|
def self.transfer( source , from , to)
|
||||||
RegisterTransfer.new source , from , to
|
RegisterTransfer.new( source , from , to)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -51,7 +51,7 @@ module Typed
|
|||||||
|
|
||||||
def handle_special_message(statement)
|
def handle_special_message(statement)
|
||||||
reg = use_reg :Message
|
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
|
return reg
|
||||||
end
|
end
|
||||||
end #module
|
end #module
|
||||||
|
Loading…
Reference in New Issue
Block a user