Remove MethodReturn instruction

and pass
and fix all tests
move towards removing all vm instructions
This commit is contained in:
Torsten Ruger
2015-10-18 17:32:32 +03:00
parent ae21feb6dc
commit 8bf1337043
18 changed files with 40 additions and 67 deletions

View File

@ -16,4 +16,3 @@ end
require_relative "instructions/halt"
require_relative "instructions/method_call"
require_relative "instructions/method_enter"
require_relative "instructions/method_return"

View File

@ -1,14 +0,0 @@
module Virtual
# also the return shuffles our objects beck before actually transferring control
class MethodReturn < Instruction
def initialize method
@method = method
end
attr_reader :method
end
end

View File

@ -60,7 +60,13 @@ module Virtual
set_return_type( return_type )
@blocks = [enter]
@current = enter
new_block("return").add_code(MethodReturn.new(method))
ret = new_block("return")
# move the current message to new_message
ret.add_code Register::RegisterTransfer.new(self, Register.message_reg , Register.new_message_reg )
# and restore the message from saved value in new_message
ret.add_code Register.get_slot(self,:new_message , :caller , :message )
#load the return address into pc, affecting return. (other cpus have commands for this, but not arm)
ret.add_code Register::FunctionReturn.new( self , Register.new_message_reg , Register.resolve_index(:message , :return_address) )
@constants = []
end
attr_reader :blocks , :constants , :return_type