2014-10-04 12:52:28 +03:00
|
|
|
module Virtual
|
2014-08-26 12:05:49 +03:00
|
|
|
|
|
|
|
class EnterImplementation
|
|
|
|
def run block
|
|
|
|
block.codes.dup.each do |code|
|
|
|
|
next unless code.is_a? Virtual::MethodEnter
|
2014-09-24 18:25:18 +03:00
|
|
|
new_codes = []
|
2015-06-29 20:58:06 +03:00
|
|
|
# save return register to the message at instance return_address
|
2015-07-27 12:13:39 +03:00
|
|
|
new_codes << Register.save_return(code, :message , :return_address)
|
2015-06-29 20:58:06 +03:00
|
|
|
# and create a new frame if needed
|
2015-09-27 14:00:24 +03:00
|
|
|
unless code.method.locals.empty?
|
2015-06-28 22:03:21 +03:00
|
|
|
new_codes << Virtual::NewFrame.new
|
|
|
|
end
|
2014-09-24 18:25:18 +03:00
|
|
|
block.replace(code , new_codes )
|
2014-08-26 12:05:49 +03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2015-06-01 08:40:17 +03:00
|
|
|
Virtual.machine.add_pass "Virtual::EnterImplementation"
|
2014-08-26 12:05:49 +03:00
|
|
|
end
|