rubyx/lib/virtual/passes/enter_implementation.rb

18 lines
619 B
Ruby
Raw Normal View History

2014-10-04 11:52:28 +02:00
module Virtual
class EnterImplementation
def run block
block.codes.dup.each do |code|
next unless code.is_a? Virtual::MethodEnter
new_codes = []
# save return register and create a new frame
# 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 )
new_codes << Virtual::NewFrame.new
block.replace(code , new_codes )
end
end
end
Virtual::Machine.instance.add_pass "Virtual::EnterImplementation"
end