rubyx/lib/register/instructions/function_call.rb

25 lines
657 B
Ruby
Raw Normal View History

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
def initialize source , method
super(source)
@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
end
2015-07-24 12:23:56 +02:00
2015-10-28 20:39:59 +01:00
def self.issue_call compiler , callee
# move the current new_message to message
2015-10-28 20:39:59 +01:00
compiler.add_code RegisterTransfer.new("__call__", Register.new_message_reg , Register.message_reg )
# do the register call
2015-10-28 20:39:59 +01:00
compiler.add_code FunctionCall.new( "__call__" , callee )
end
2015-07-24 12:23:56 +02:00
end