2014-10-04 11:52:28 +02:00
|
|
|
module Virtual
|
2014-08-26 11:05:49 +02:00
|
|
|
|
|
|
|
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
|
2015-06-21 16:22:51 +02:00
|
|
|
new_codes << Register::SaveReturn.new( Virtual::Slot::MESSAGE_REGISTER , Virtual::MESSAGE_RETURN_ADDRESS )
|
2014-09-24 17:25:18 +02:00
|
|
|
new_codes << Virtual::NewFrame.new
|
|
|
|
block.replace(code , new_codes )
|
2014-08-26 11:05:49 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2015-06-01 07:40:17 +02:00
|
|
|
Virtual.machine.add_pass "Virtual::EnterImplementation"
|
2014-08-26 11:05:49 +02:00
|
|
|
end
|