From 3145547315a1d1a27bd240cca612ec41b12f9b47 Mon Sep 17 00:00:00 2001 From: Torsten Date: Sun, 15 Mar 2020 10:39:09 +0200 Subject: [PATCH] init fell into the ssa tap, fixed reducing and assuming the same register, buuh adds a transfer instruction that can hopefully be removed by analysis --- lib/slot_machine/macro/macro.rb | 3 ++- test/risc/interpreter/assign/test_assign_local.rb | 10 +++++----- test/risc/interpreter/test_dynamic_call.rb | 6 +++--- test/risc/interpreter/test_events.rb | 8 ++++---- test/risc/interpreter/test_return.rb | 5 +++-- test/slot_machine/macro/test_init.rb | 5 +++-- 6 files changed, 20 insertions(+), 17 deletions(-) diff --git a/lib/slot_machine/macro/macro.rb b/lib/slot_machine/macro/macro.rb index c5088d39..b5f6cbab 100644 --- a/lib/slot_machine/macro/macro.rb +++ b/lib/slot_machine/macro/macro.rb @@ -22,7 +22,8 @@ module SlotMachine save_message( builder ) builder.build do message << message[:return_value] - message.reduce_int(false) #hack, noo type check + int = message.reduce_int(false) #hack, noo type check + message << int add_code Risc::Syscall.new("emit_syscall(exit)", :exit ) end end diff --git a/test/risc/interpreter/assign/test_assign_local.rb b/test/risc/interpreter/assign/test_assign_local.rb index 847734b3..60fa8afe 100644 --- a/test/risc/interpreter/assign/test_assign_local.rb +++ b/test/risc/interpreter/assign/test_assign_local.rb @@ -13,10 +13,10 @@ module Risc #show_main_ticks # get output of what is check_main_chain [LoadConstant, RegToSlot, SlotToReg, RegToSlot, Branch, #5 SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg, #10 - FunctionReturn, Transfer, SlotToReg, SlotToReg, Syscall, #15 - NilClass,] #20 - assert_equal Parfait::Integer , get_return.class - assert_equal 15 , get_return.value + FunctionReturn, Transfer, SlotToReg, SlotToReg, Transfer, + Syscall, NilClass,] #20 + assert_equal ::Integer , get_return.class + assert_equal 15 , get_return end def test_call_main call_ins = ticks(main_at) @@ -40,7 +40,7 @@ module Risc assert_transfer 12 , :message , :saved_message end def test_sys - assert_syscall 15 , :exit + assert_syscall 16 , :exit end end end diff --git a/test/risc/interpreter/test_dynamic_call.rb b/test/risc/interpreter/test_dynamic_call.rb index 7d56d4de..2e9232f3 100644 --- a/test/risc/interpreter/test_dynamic_call.rb +++ b/test/risc/interpreter/test_dynamic_call.rb @@ -26,9 +26,9 @@ module Risc Branch, SlotToReg, RegToSlot, SlotToReg, SlotToReg, #60 FunctionReturn, SlotToReg, RegToSlot, Branch, SlotToReg, #65 SlotToReg, RegToSlot, SlotToReg, SlotToReg, FunctionReturn, #70 - Transfer, SlotToReg, SlotToReg, Syscall, NilClass,] #75 - assert_equal Parfait::Integer , get_return.class - assert_equal 1 , get_return.value + Transfer, SlotToReg, SlotToReg, Transfer ,Syscall, NilClass,] #75 + assert_equal ::Integer , get_return.class + assert_equal 1 , get_return end def test_load_entry call_ins = main_ticks(3) diff --git a/test/risc/interpreter/test_events.rb b/test/risc/interpreter/test_events.rb index 19ac038e..59e919bf 100644 --- a/test/risc/interpreter/test_events.rb +++ b/test/risc/interpreter/test_events.rb @@ -19,7 +19,7 @@ module Risc @instruction_events << was end def length - 27 + 28 end def test_state_change @interpreter.register_event :state_changed , self @@ -44,9 +44,9 @@ module Risc RegToSlot, LoadConstant, RegToSlot, FunctionCall, LoadConstant, #15 RegToSlot, Branch, SlotToReg, SlotToReg, RegToSlot, #20 SlotToReg, SlotToReg, FunctionReturn, Transfer, SlotToReg, #25 - SlotToReg, Syscall, NilClass,] #30 - assert_equal Parfait::Integer , get_return.class - assert_equal 5 , get_return.value + SlotToReg, Transfer, Syscall, NilClass,] #30 + assert_equal ::Integer , get_return.class + assert_equal 5 , get_return end def test_length run_all diff --git a/test/risc/interpreter/test_return.rb b/test/risc/interpreter/test_return.rb index bb8110cf..559ecf49 100644 --- a/test/risc/interpreter/test_return.rb +++ b/test/risc/interpreter/test_return.rb @@ -13,13 +13,14 @@ module Risc # show_main_ticks # get output of what is check_main_chain [LoadConstant, RegToSlot, Branch, SlotToReg, SlotToReg, #5 RegToSlot, SlotToReg, SlotToReg, FunctionReturn, Transfer, #10 - SlotToReg, SlotToReg, Syscall, NilClass,] #15 - assert_equal 5 , get_return.value + SlotToReg, SlotToReg, Transfer, Syscall, NilClass,] #15 + assert_equal 5 , get_return end def test_call_main assert_function_call 0 , :main end + def test_function_return ret = main_ticks(9) assert_equal FunctionReturn , ret.class diff --git a/test/slot_machine/macro/test_init.rb b/test/slot_machine/macro/test_init.rb index d3aacf09..5a604d39 100644 --- a/test/slot_machine/macro/test_init.rb +++ b/test/slot_machine/macro/test_init.rb @@ -16,7 +16,7 @@ module SlotMachine assert_equal Risc::MethodCompiler , @method.to_risc.class end def test_risc_length - assert_equal 19 , @method.to_risc.risc_instructions.length + assert_equal 20 , @method.to_risc.risc_instructions.length end def test_all assert_load 1 , Parfait::Factory , "id_factory_" @@ -36,7 +36,8 @@ module SlotMachine assert_transfer 15 , :message , :saved_message assert_slot_to_reg 16 ,:message , 5 , :message assert_slot_to_reg 17 ,:message , 2 , "message.data_1" - assert_syscall 18, :exit + assert_transfer 18 , "message.data_1" , :message + assert_syscall 19, :exit end end end