2014-10-05 17:40:47 +02:00
|
|
|
module Register
|
|
|
|
|
2015-06-21 16:22:51 +02:00
|
|
|
# Defines the method call, ie
|
2014-10-05 17:40:47 +02:00
|
|
|
# - move the new_message to message
|
|
|
|
# - unroll self and
|
|
|
|
# - register call
|
|
|
|
|
|
|
|
# all in all, quite the reverse of a return
|
|
|
|
|
|
|
|
class CallImplementation
|
|
|
|
def run block
|
|
|
|
block.codes.dup.each do |code|
|
|
|
|
next unless code.is_a? Virtual::MethodCall
|
|
|
|
new_codes = []
|
|
|
|
slot = Virtual::Slot
|
|
|
|
# move the current new_message to message
|
2015-06-27 20:16:46 +02:00
|
|
|
new_codes << RegisterTransfer.new( RegisterReference.new_message_reg , RegisterReference.message_reg )
|
2014-10-05 17:40:47 +02:00
|
|
|
# "roll out" self into its register
|
2015-06-27 20:16:46 +02:00
|
|
|
new_codes << GetSlot.new( RegisterReference.message_reg , Virtual::SELF_INDEX, RegisterReference.self_reg )
|
2014-10-05 17:40:47 +02:00
|
|
|
# do the register call
|
|
|
|
new_codes << FunctionCall.new( code.method )
|
|
|
|
block.replace(code , new_codes )
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2015-06-01 07:40:17 +02:00
|
|
|
Virtual.machine.add_pass "Register::CallImplementation"
|
2014-10-05 17:40:47 +02:00
|
|
|
end
|