diff --git a/lib/mom/instruction/simple_call.rb b/lib/mom/instruction/simple_call.rb index 350f02b1..86fd40eb 100644 --- a/lib/mom/instruction/simple_call.rb +++ b/lib/mom/instruction/simple_call.rb @@ -24,7 +24,7 @@ module Mom 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 << Risc::FunctionCall.new(self, method ,reg) moves << return_label end diff --git a/lib/risc/builtin/kernel.rb b/lib/risc/builtin/kernel.rb index a7248d43..7b9444ea 100644 --- a/lib/risc/builtin/kernel.rb +++ b/lib/risc/builtin/kernel.rb @@ -24,7 +24,7 @@ module Risc ret_tmp = compiler.use_reg(:Label) compiler.add_load_constant("__init__ load return", exit_label , ret_tmp) compiler.add_reg_to_slot("__init__ store return", ret_tmp , :message , :return_address) - compiler.add_code Risc.function_call( "__init__ issue call" , Parfait.object_space.get_main ) + compiler.add_code Risc.function_call( "__init__ issue call" , Parfait.object_space.get_main , ret_tmp) compiler.add_code exit_label emit_syscall( compiler , :exit ) return compiler.method diff --git a/lib/risc/instructions/function_call.rb b/lib/risc/instructions/function_call.rb index 67b57b8e..abe6ec10 100644 --- a/lib/risc/instructions/function_call.rb +++ b/lib/risc/instructions/function_call.rb @@ -4,19 +4,20 @@ module Risc # assembly takes care of the rest (ie getting the address) class FunctionCall < Instruction - def initialize( source , method ) + def initialize( source , method , register) super(source) @method = method + @register = register end - attr_reader :method + attr_reader :method , :register def to_s "FunctionCall: #{method.name}" end end - def self.function_call( source , method ) - Risc::FunctionCall.new( source , method ) + def self.function_call( source , method , register) + Risc::FunctionCall.new( source , method , register) end def self.issue_call( compiler , callee )