From f424e58715b7a19654d893fb009decfbb2a04f52 Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Wed, 21 Mar 2018 19:29:00 +0530 Subject: [PATCH] finish the simple call moving jump address --- lib/mom/instruction/simple_call.rb | 5 +++-- test/mom/assign/test_assign_local_send.rb | 4 ++-- test/mom/test_send_simple.rb | 26 ++++++----------------- 3 files changed, 11 insertions(+), 24 deletions(-) diff --git a/lib/mom/instruction/simple_call.rb b/lib/mom/instruction/simple_call.rb index 132e42cb..8802cadb 100644 --- a/lib/mom/instruction/simple_call.rb +++ b/lib/mom/instruction/simple_call.rb @@ -20,12 +20,13 @@ module Mom # 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) + jump_address = compiler.use_reg(:int) return_label = Risc::Label.new(self,"continue") save_return = SlotLoad.new([:message,:next_message,:return_address],[return_label]) moves = save_return.to_risc(compiler) moves << Risc.slot_to_reg(self, :message , :next_message , Risc.message_reg) - moves << Risc::FunctionCall.new(self, method ,reg) + moves << Risc.load_constant(self , method.binary , jump_address) + moves << Risc::FunctionCall.new(self, method ,jump_address) moves << return_label end diff --git a/test/mom/assign/test_assign_local_send.rb b/test/mom/assign/test_assign_local_send.rb index 1dbc8720..dfe7b174 100644 --- a/test/mom/assign/test_assign_local_send.rb +++ b/test/mom/assign/test_assign_local_send.rb @@ -9,8 +9,8 @@ module Risc @input = "r = 5.mod4" @expect = [LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg, SlotToReg , RegToSlot, LoadConstant, SlotToReg, SlotToReg, RegToSlot, LoadConstant , - SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot, FunctionCall , - Label, SlotToReg, SlotToReg, RegToSlot] + SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot, SlotToReg , + LoadConstant, FunctionCall, Label, SlotToReg, SlotToReg, RegToSlot] end def test_local_assign_instructions assert_nil msg = check_nil , msg diff --git a/test/mom/test_send_simple.rb b/test/mom/test_send_simple.rb index 00279c91..c9f2d07b 100644 --- a/test/mom/test_send_simple.rb +++ b/test/mom/test_send_simple.rb @@ -10,7 +10,7 @@ module Risc @expect = [LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg, SlotToReg , RegToSlot, LoadConstant, SlotToReg, SlotToReg, RegToSlot, LoadConstant , SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot, SlotToReg , - FunctionCall, Label] + LoadConstant, FunctionCall, Label] end def test_send_instructions @@ -18,8 +18,8 @@ module Risc end def test_function_call produced = produce_body - assert_equal FunctionCall , produced.next(18).class - assert_equal :mod4 , produced.next(18).method.name + assert_equal FunctionCall , produced.next(19).class + assert_equal :mod4 , produced.next(19).method.name end def test_load_label produced = produce_body @@ -29,24 +29,10 @@ module Risc produced = produce_body assert_equal 5 , produced.next(11).constant.known_object.value end - - def est_call_reg_setup + def test_call_reg_setup produced = produce_body - assert_equal produced.next(16).register , produced.next(17).register + assert_equal produced.next(18).register , produced.next(19).register end - def pest_nil_load - produced = produce_body - assert_equal Mom::NilConstant , produced.next(4).constant.known_object.class - end - def pest_nil_check - produced = produce_body - assert_equal produced.next(10) , produced.next(5).label - end - - def pest_true_label - produced = produce_body - assert produced.next(6).name.start_with?("true_label") - end - + #TODO check the message setup, type and frame moves end end