implement simple_calls to_risc

This commit is contained in:
Torsten Ruger
2018-03-21 18:54:42 +05:30
parent 71c59e5bc0
commit a9196e9cd6
4 changed files with 25 additions and 20 deletions

View File

@ -5,7 +5,7 @@ module Mom
# actually call it.
#
# As the call setup is done beforehand (for both simple and cached call), the
# calling really means just jumping to the address. Simple.
# calling really means mostly jumping to the address. Simple.
#
class SimpleCall < Instruction
attr_reader :method
@ -13,8 +13,19 @@ module Mom
def initialize(method)
@method = method
end
def to_risc(context)
Risc::Label.new(self,"SimpleCall")
# To call the method, we determine the jumpable address (method.binary), move that
# into a register and issue a FunctionCall
#
# For returning, we add a label after the call, and load it's address into the
# return_address of the next_message, for the ReturnSequence to pick it up.
def to_risc(compiler)
reg = compiler.use_reg(:int)
return_label = Risc::Label.new(self,"continue")
load = SlotLoad.new([:message,:next_message,:return_address],[return_label])
moves = load.to_risc(compiler)
moves << Risc::FunctionCall.new(self, reg)
moves << return_label
end
end

View File

@ -102,7 +102,7 @@ module Mom
type = known_object.respond_to?(:ct_type) ? known_object.ct_type : :int
right = compiler.use_reg( type )
case known_object
when Constant , Parfait::Object
when Constant , Parfait::Object , Risc::Label
const = Risc.load_constant(instruction, self , right)
when Symbol
const = Risc::SlotToReg.new( instruction , Risc.resolve_to_register(known_object) ,