rubyx/lib/register/passes/call_implementation.rb
Torsten Ruger 6c7e4c0fe2 stop pinning self and frame
before: r0-message , r1-self , r2-frame , r3-new_message , r4 + tmps
now: r0-message , r1-new_message , r2 + tmps
programs got smaller, less fuss
also fix in return implementation that got the address from the wrong
message
2015-10-18 17:20:19 +03:00

25 lines
699 B
Ruby

module Register
# Defines the method call, ie
# - 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 = []
# move the current new_message to message
new_codes << RegisterTransfer.new(code, Register.new_message_reg , Register.message_reg )
# do the register call
new_codes << FunctionCall.new( code , code.method )
block.replace(code , new_codes )
end
end
end
Virtual.machine.add_pass "Register::CallImplementation"
end