2014-08-26 11:05:49 +02:00
|
|
|
module Register
|
|
|
|
|
|
|
|
class EnterImplementation
|
|
|
|
def run block
|
|
|
|
block.codes.dup.each do |code|
|
|
|
|
next unless code.is_a? Virtual::MethodEnter
|
2014-09-24 17:25:18 +02:00
|
|
|
new_codes = []
|
2014-08-26 11:05:49 +02:00
|
|
|
# save return register and create a new frame
|
2014-09-24 17:25:18 +02:00
|
|
|
# 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 << Virtual::NewFrame.new
|
|
|
|
block.replace(code , new_codes )
|
2014-08-26 11:05:49 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2014-10-03 13:52:47 +02:00
|
|
|
Virtual::BootSpace.space.add_pass_after "Register::EnterImplementation" , "Virtual::GetImplementation"
|
2014-08-26 11:05:49 +02:00
|
|
|
end
|