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
|
2014-10-04 11:52:28 +02:00
|
|
|
new_codes << Register::SaveReturn.new( Virtual::Slot::MESSAGE_REGISTER , Virtual::Slot::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-05-12 14:36:44 +02:00
|
|
|
Virtual::Machine.instance.add_pass "Virtual::EnterImplementation"
|
2014-08-26 11:05:49 +02:00
|
|
|
end
|