2014-10-03 13:32:54 +02:00
|
|
|
module Register
|
|
|
|
# name says it all really
|
|
|
|
# only arg is the method object we want to call
|
|
|
|
# assembly takes care of the rest (ie getting the address)
|
|
|
|
|
|
|
|
class FunctionCall < Instruction
|
2015-07-27 11:13:39 +02:00
|
|
|
def initialize source , method
|
|
|
|
super(source)
|
2014-10-03 13:32:54 +02:00
|
|
|
@method = method
|
|
|
|
end
|
|
|
|
attr_reader :method
|
2015-07-24 12:23:56 +02:00
|
|
|
|
|
|
|
def to_s
|
2015-07-25 08:30:58 +02:00
|
|
|
"FunctionCall: #{method.name}"
|
2015-07-24 12:23:56 +02:00
|
|
|
end
|
2015-10-18 18:27:46 +02:00
|
|
|
end
|
2015-07-24 12:23:56 +02:00
|
|
|
|
2015-10-18 18:27:46 +02:00
|
|
|
def self.issue_call caller , callee
|
|
|
|
# move the current new_message to message
|
|
|
|
caller.source.add_code RegisterTransfer.new(caller, Register.new_message_reg , Register.message_reg )
|
|
|
|
# do the register call
|
|
|
|
caller.source.add_code FunctionCall.new( caller , callee )
|
2014-10-03 13:32:54 +02:00
|
|
|
end
|
2015-07-24 12:23:56 +02:00
|
|
|
end
|