corrected method enter and return and created those missing constants
This commit is contained in:
parent
771eeb7a3d
commit
1d33c03537
@ -6,11 +6,9 @@ module Register
|
|||||||
next unless code.is_a? Virtual::MethodEnter
|
next unless code.is_a? Virtual::MethodEnter
|
||||||
# save return register and create a new frame
|
# save return register and create a new frame
|
||||||
to = RegisterReference.new(:r0) # message base
|
to = RegisterReference.new(:r0) # message base
|
||||||
tmp = RegisterReference.new(:r5) # tmp
|
|
||||||
pc = RegisterReference.new(:pc)
|
pc = RegisterReference.new(:pc)
|
||||||
move1 = RegisterMachine.instance.ldr( tmp , pc )
|
move1 = RegisterMachine.instance.str( pc , to , Virtual::Message::RETURN )
|
||||||
move2 = RegisterMachine.instance.ldr( tmp , to , 3 ) #TODO 3 == return reg, needs constant / layout
|
block.replace(code , [move1] )
|
||||||
block.replace(code , [move1,move2] )
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -3,12 +3,11 @@ module Register
|
|||||||
def run block
|
def run block
|
||||||
block.codes.dup.each do |code|
|
block.codes.dup.each do |code|
|
||||||
next unless code.is_a? Virtual::MethodReturn
|
next unless code.is_a? Virtual::MethodReturn
|
||||||
to = RegisterReference.new(:r0)
|
#load the return address into pc, affecting return. (other cpus have commands for this, but not arm)
|
||||||
tmp = RegisterReference.new(:r5)
|
message = RegisterReference.new(:r0)
|
||||||
pc = RegisterReference.new(:pc)
|
pc = RegisterReference.new(:pc)
|
||||||
move1 = RegisterMachine.instance.ldr( to , tmp , 3 ) #TODO 3 == return reg, needs constant / layout
|
move1 = RegisterMachine.instance.ldr( pc ,message , Virtual::Message::RETURN )
|
||||||
move2 = RegisterMachine.instance.ldr( pc , tmp )
|
block.replace(code , [move1] )
|
||||||
block.replace(code , [move1,move2] )
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -20,6 +20,10 @@ module Virtual
|
|||||||
# During compilation Message and frame objects are created to do type analysis
|
# During compilation Message and frame objects are created to do type analysis
|
||||||
|
|
||||||
class Message
|
class Message
|
||||||
|
RETURN = 2
|
||||||
|
EXCEPTION = 3
|
||||||
|
SELF = 4
|
||||||
|
|
||||||
def initialize me , normal , exceptional
|
def initialize me , normal , exceptional
|
||||||
@me = me
|
@me = me
|
||||||
@next_normal = normal
|
@next_normal = normal
|
||||||
|
Loading…
Reference in New Issue
Block a user