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 = []
|
2015-06-29 19:58:06 +02:00
|
|
|
# save return register to the message at instance return_address
|
2015-07-27 11:13:39 +02:00
|
|
|
new_codes << Register.save_return(code, :message , :return_address)
|
2015-06-29 19:58:06 +02:00
|
|
|
# and create a new frame if needed
|
2015-09-27 13:00:24 +02:00
|
|
|
unless code.method.locals.empty?
|
2015-10-16 16:58:42 +02:00
|
|
|
new_codes << Register.get_slot( code, :message , :frame , Register.resolve_to_register(:frame))
|
2015-06-28 21:03:21 +02:00
|
|
|
end
|
2014-09-24 17:25:18 +02:00
|
|
|
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
|