corrected method enter and return and created those missing constants

This commit is contained in:
Torsten Ruger 2014-09-11 19:00:14 +03:00
parent 771eeb7a3d
commit 1d33c03537
3 changed files with 10 additions and 9 deletions

View File

@ -6,11 +6,9 @@ module Register
next unless code.is_a? Virtual::MethodEnter
# save return register and create a new frame
to = RegisterReference.new(:r0) # message base
tmp = RegisterReference.new(:r5) # tmp
pc = RegisterReference.new(:pc)
move1 = RegisterMachine.instance.ldr( tmp , pc )
move2 = RegisterMachine.instance.ldr( tmp , to , 3 ) #TODO 3 == return reg, needs constant / layout
block.replace(code , [move1,move2] )
move1 = RegisterMachine.instance.str( pc , to , Virtual::Message::RETURN )
block.replace(code , [move1] )
end
end
end

View File

@ -3,12 +3,11 @@ module Register
def run block
block.codes.dup.each do |code|
next unless code.is_a? Virtual::MethodReturn
to = RegisterReference.new(:r0)
tmp = RegisterReference.new(:r5)
#load the return address into pc, affecting return. (other cpus have commands for this, but not arm)
message = RegisterReference.new(:r0)
pc = RegisterReference.new(:pc)
move1 = RegisterMachine.instance.ldr( to , tmp , 3 ) #TODO 3 == return reg, needs constant / layout
move2 = RegisterMachine.instance.ldr( pc , tmp )
block.replace(code , [move1,move2] )
move1 = RegisterMachine.instance.ldr( pc ,message , Virtual::Message::RETURN )
block.replace(code , [move1] )
end
end
end

View File

@ -20,6 +20,10 @@ module Virtual
# During compilation Message and frame objects are created to do type analysis
class Message
RETURN = 2
EXCEPTION = 3
SELF = 4
def initialize me , normal , exceptional
@me = me
@next_normal = normal