From bc558d1f0d6913185af6e6b4ccabf1e845f6c4ee Mon Sep 17 00:00:00 2001 From: Torsten Date: Wed, 25 Mar 2020 12:43:57 +0200 Subject: [PATCH] do not copy name of method so that the resolve can compare name identity which is what is does, not equality this (and some other bug) is crashing arm currently --- lib/arm/translator.rb | 1 + lib/risc/parfait_adapter.rb | 4 ++++ .../instructions/resolve_method.rb | 2 +- .../instructions/test_resolve_method.rb | 18 +++++++++--------- test/sol/test_yield_statement.rb | 2 +- 5 files changed, 16 insertions(+), 11 deletions(-) diff --git a/lib/arm/translator.rb b/lib/arm/translator.rb index f42a9af8..0030d314 100644 --- a/lib/arm/translator.rb +++ b/lib/arm/translator.rb @@ -72,6 +72,7 @@ module Arm codes << ArmMachine.mov( :pc , code.register) codes end + def translate_DynamicJump(code) index = Parfait.object_space.get_type_by_class_name(:CallableMethod).variable_index(:binary) codes = ArmMachine.ldr( code.register , code.register , arm_index(index) ) diff --git a/lib/risc/parfait_adapter.rb b/lib/risc/parfait_adapter.rb index 2d3ba1fe..ce48ec42 100644 --- a/lib/risc/parfait_adapter.rb +++ b/lib/risc/parfait_adapter.rb @@ -140,6 +140,10 @@ class Symbol #puts "LL #{l.class}" l end + alias :ct_type :get_type + def value + self + end def padded_length Parfait::Object.padded( to_s.length + 4) end diff --git a/lib/slot_machine/instructions/resolve_method.rb b/lib/slot_machine/instructions/resolve_method.rb index 072842f8..79d899e6 100644 --- a/lib/slot_machine/instructions/resolve_method.rb +++ b/lib/slot_machine/instructions/resolve_method.rb @@ -38,7 +38,7 @@ module SlotMachine # currently a fail results in sys exit def to_risc( compiler ) builder = compiler.builder(self) - word = builder.load_object(Parfait.new_word(@name.to_s)) + word = builder.load_object(@name) entry = builder.load_object(@cache_entry) while_start_label = Risc.label(to_s, "resolve_#{name}_#{object_id}") ok_label = Risc.label(to_s, "ok_resolve_#{name}_#{object_id}") diff --git a/test/slot_machine/instructions/test_resolve_method.rb b/test/slot_machine/instructions/test_resolve_method.rb index c34f6e25..2581fc5e 100644 --- a/test/slot_machine/instructions/test_resolve_method.rb +++ b/test/slot_machine/instructions/test_resolve_method.rb @@ -13,8 +13,8 @@ module SlotMachine assert_equal 20 , all.length , all_str end def test_load_name - assert_load 1, Parfait::Word , "id_word_" - assert_equal "name" , risc(1).constant.to_string + assert_load 1, Symbol , "id_symbol_" + assert_equal "name" , risc(1).constant.to_s end def test_load_cache assert_load 2, Parfait::CacheEntry , "id_cacheentry_" @@ -26,7 +26,7 @@ module SlotMachine assert_slot_to_reg 4 , "id_cacheentry_.cached_type" , 4 , "id_cacheentry_.cached_type.methods" end def test_start_label - assert_label 5 , "while_start_" + assert_label 5 , "resolve_" end def test_load_nil assert_load 6, Parfait::NilClass , "id_nilclass_" @@ -41,10 +41,10 @@ module SlotMachine assert_slot_to_reg 9, "id_cacheentry_.cached_type.methods" , 6 , "id_cacheentry_.cached_type.methods.name" end def test_check_name - assert_operator 10, :- , "id_cacheentry_.cached_type.methods.name" , "id_word_" , "op_-_" + assert_operator 10, :- , "id_cacheentry_.cached_type.methods.name" , "id_symbol_" , "op_-_" end def test_nil_branch - assert_zero 11, "ok_label_" + assert_zero 11, "ok_resolve_name_" end def test_get_next_method assert_slot_to_reg 12, "id_cacheentry_.cached_type.methods" , 2 , "id_cacheentry_.cached_type.methods.next_callable" @@ -53,19 +53,19 @@ module SlotMachine assert_transfer 13 , "id_cacheentry_.cached_type.methods.next" , "id_cacheentry_.cached_type.methods" end def test_continue_while - assert_branch 14, "while_start_" + assert_branch 14, "resolve_" end def test_goto_exit - assert_label 15, "exit_label_" + assert_label 15, "exit_resolve_name_" end def test_move_name - assert_transfer 16, "id_word_" , :r1 + assert_transfer 16, "id_symbol_" , :r1 end def test_sys assert_syscall 17, :died end def test_label - assert_label 18, "ok_label_" + assert_label 18, "ok_resolve_name_" end def test_method assert_reg_to_slot 19 , "id_cacheentry_.cached_type.methods" , "id_cacheentry_" , 2 diff --git a/test/sol/test_yield_statement.rb b/test/sol/test_yield_statement.rb index 91a0c88d..0aad33b7 100644 --- a/test/sol/test_yield_statement.rb +++ b/test/sol/test_yield_statement.rb @@ -72,7 +72,7 @@ module Sol end def test_check_label assert_equal NotSameCheck, @ins.class - assert @ins.false_label.name.start_with?("cache_ok_") , @ins.false_label.name + assert @ins.false_label.name.start_with?("send_cache_some_ok_") , @ins.false_label.name end def test_array check_array [NotSameCheck, SlotLoad, ResolveMethod, Label, MessageSetup ,