From 8867d60c13a6c570d494c845ba287fa66515872c Mon Sep 17 00:00:00 2001 From: Torsten Date: Tue, 10 Mar 2020 17:36:53 +0200 Subject: [PATCH] fix method_missing register logic is still wrong, even it is slightly less (at least loading the method name) --- lib/slot_machine/macro/method_missing.rb | 2 +- test/slot_machine/macro/test_method_missing.rb | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/slot_machine/macro/method_missing.rb b/lib/slot_machine/macro/method_missing.rb index af2faa37..1260eba6 100644 --- a/lib/slot_machine/macro/method_missing.rb +++ b/lib/slot_machine/macro/method_missing.rb @@ -11,7 +11,7 @@ module SlotMachine def to_risc(compiler) builder = compiler.builder(compiler.source_name) - from = Risc::RegisterValue.new(@name , :Word) + from = compiler.load_object(Parfait.new_word(@name)) to = Risc::RegisterValue.new(:r1 , :Word) builder.add_code Risc::Transfer.new(self , from , to) builder.add_code Risc::Syscall.new(self, :died ) diff --git a/test/slot_machine/macro/test_method_missing.rb b/test/slot_machine/macro/test_method_missing.rb index 3e41d233..24e00af3 100644 --- a/test/slot_machine/macro/test_method_missing.rb +++ b/test/slot_machine/macro/test_method_missing.rb @@ -17,16 +17,16 @@ module SlotMachine assert_equal 15 , @method.to_risc.risc_instructions.length end def test_all - assert_transfer risc(1) , :r1 , :r1 - assert_equal Risc::Syscall, risc(2).class - assert_slot_to_reg risc(3),:r0 , 5 , :r2 - assert_slot_to_reg risc(3),:r0 , 5 , :r2 - assert_reg_to_slot risc(4) , :r2 , :r0 , 5 - assert_branch risc(5) , "return_label" - assert_label risc(6) , "return_label" + assert_load 1 , Parfait::Word , "id_word_" + assert_transfer 2 , "id_word_" , :r1 + assert_syscall 3 , :died + assert_slot_to_reg 4 , :message , 5 , "message.return_value" + assert_reg_to_slot 5 , "message.return_value" , :message , 5 + assert_branch 6 , "return_label" + assert_label 7 , "return_label" end def test_return - assert_return(6) + assert_return(7) end end end