diff --git a/lib/register/passes/return_implementation.rb b/lib/register/passes/return_implementation.rb index 5e86f937..4b2eb666 100644 --- a/lib/register/passes/return_implementation.rb +++ b/lib/register/passes/return_implementation.rb @@ -4,17 +4,16 @@ module Register block.codes.dup.each do |code| next unless code.is_a? Virtual::MethodReturn new_codes = [] - machine = RegisterMachine.instance slot = Virtual::Slot # move the current message to new_message - new_codes << machine.mov( slot::MESSAGE_REGISTER , slot::NEW_MESSAGE_REGISTER ) + new_codes << RegisterTransfer.new( slot::MESSAGE_REGISTER , slot::NEW_MESSAGE_REGISTER ) # and restore the message from saved value in new_message - new_codes << machine.ldr( slot::MESSAGE_REGISTER ,slot::NEW_MESSAGE_REGISTER , slot::MESSAGE_CALLER ) + new_codes << GetSlot.new( slot::MESSAGE_REGISTER , slot::NEW_MESSAGE_REGISTER , slot::MESSAGE_CALLER ) # "roll out" self and frame into their registers - new_codes << machine.ldr( slot::SELF_REGISTER ,slot::MESSAGE_REGISTER , slot::MESSAGE_SELF ) - new_codes << machine.ldr( slot::FRAME_REGISTER ,slot::MESSAGE_REGISTER , slot::MESSAGE_FRAME ) + new_codes << GetSlot.new( slot::SELF_REGISTER ,slot::MESSAGE_REGISTER , slot::MESSAGE_SELF ) + new_codes << GetSlot.new( slot::FRAME_REGISTER ,slot::MESSAGE_REGISTER , slot::MESSAGE_FRAME ) #load the return address into pc, affecting return. (other cpus have commands for this, but not arm) - new_codes << machine.ldr( :pc ,slot::MESSAGE_REGISTER , slot::MESSAGE_RETURN_ADDRESS ) + new_codes << FunctionReturn.new( slot::MESSAGE_REGISTER , slot::MESSAGE_RETURN_ADDRESS ) block.replace(code , new_codes ) end end diff --git a/lib/virtual/passes/enter_implementation.rb b/lib/virtual/passes/enter_implementation.rb index ea45f879..3f686ae3 100644 --- a/lib/virtual/passes/enter_implementation.rb +++ b/lib/virtual/passes/enter_implementation.rb @@ -1,4 +1,4 @@ -module Register +module Virtual class EnterImplementation def run block @@ -7,11 +7,11 @@ module Register new_codes = [] # save return register and create a new frame # lr is link register, ie where arm stores the return address when call is issued - new_codes << RegisterMachine.instance.str( :lr , Virtual::Slot::MESSAGE_REGISTER , Virtual::Slot::MESSAGE_RETURN_ADDRESS ) + new_codes << Register::SaveReturn.new( Virtual::Slot::MESSAGE_REGISTER , Virtual::Slot::MESSAGE_RETURN_ADDRESS ) new_codes << Virtual::NewFrame.new block.replace(code , new_codes ) end end end - Virtual::BootSpace.space.add_pass_after "Register::EnterImplementation" , "Virtual::GetImplementation" + Virtual::BootSpace.space.add_pass_after "Virtual::EnterImplementation" , "Virtual::GetImplementation" end diff --git a/lib/virtual/passes/send_implementation.rb b/lib/virtual/passes/send_implementation.rb index 28703f90..c7ef5af2 100644 --- a/lib/virtual/passes/send_implementation.rb +++ b/lib/virtual/passes/send_implementation.rb @@ -22,13 +22,13 @@ module Virtual # get the function from my class. easy peasy method = me.clazz.get_instance_method(code.name) raise "Method not implemented #{clazz.name}.#{code.name}" unless method - new_codes << FunctionCall.new( method ) + new_codes << Register::FunctionCall.new( method ) else # note: this is the current view: call internal send, even the method name says else # but send is "special" and accesses the internal method name and resolves. kernel = Virtual::BootSpace.space.get_or_create_class(:Kernel) method = kernel.get_instance_method(:__send) - new_codes << FunctionCall.new( method ) + new_codes << Register::FunctionCall.new( method ) raise "unimplemented #{code}" end else