From 72643ebb085614e82e224f0a6f383c2e8485f109 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torsten=20R=C3=BCger?= Date: Tue, 10 Sep 2019 14:49:02 +0300 Subject: [PATCH] Fix last parfait bug missing return statement (duh) --- lib/risc/interpreter.rb | 6 +++++- lib/risc/parfait_adapter.rb | 2 +- test/mom/test_if_no_if.rb | 5 ----- test/risc/interpreter/calling/test_minus.rb | 2 +- test/risc/test_collector.rb | 4 ++-- test/risc/test_interpreter.rb | 4 ++-- test/risc/test_linker1.rb | 2 +- 7 files changed, 12 insertions(+), 13 deletions(-) diff --git a/lib/risc/interpreter.rb b/lib/risc/interpreter.rb index 21fde3b5..a9b75db6 100644 --- a/lib/risc/interpreter.rb +++ b/lib/risc/interpreter.rb @@ -52,6 +52,7 @@ module Risc raise "Not int #{pos}" unless pos.is_a? Numeric position = Position.at(pos) raise "No position at 0x#{pos.to_s(16)}" unless position + log.debug "" log.debug "Setting Position #{clock}-#{position}, " set_instruction( position.object ) @clock += 1 @@ -60,7 +61,7 @@ module Risc def set_instruction( instruction ) raise "set to same instruction #{instruction}:#{instruction.class} at #{clock}" if @instruction == instruction - log.debug "Setting Instruction #{instruction.class}" + #log.debug "Setting Instruction #{instruction.class}" old = @instruction @instruction = instruction trigger(:instruction_changed, old , instruction) @@ -121,6 +122,7 @@ module Risc end def execute_Branch label = @instruction.label + log.debug "Branch to Label: #{@instruction.label}" pos = Position.get(label).at pos += Parfait::BinaryCode.byte_offset if label.is_a?(Parfait::BinaryCode) set_pc( pos ) @@ -169,6 +171,8 @@ module Risc raise "error #{@instruction} retrieves nil" else value = object.get_internal_word( index ) + #log.debug "Getting #{index} from #{object} value=#{value}" + #log.debug "type=#{object.type} get_type=#{object.get_type} intern=#{object.get_internal_word(0)}" end log.debug "#{@instruction} == #{object}(#{Position.get(object)}) (#{value}|#{index})" set_register( @instruction.register , value ) diff --git a/lib/risc/parfait_adapter.rb b/lib/risc/parfait_adapter.rb index 660efa84..f0623973 100644 --- a/lib/risc/parfait_adapter.rb +++ b/lib/risc/parfait_adapter.rb @@ -11,7 +11,7 @@ module Parfait end # 0 -based index def get_internal_word(index) - super(index) if index < self.class.type_length + return super(index) if index < self.class.type_length @memory[ index ] end diff --git a/test/mom/test_if_no_if.rb b/test/mom/test_if_no_if.rb index 094f2415..c3096ec4 100644 --- a/test/mom/test_if_no_if.rb +++ b/test/mom/test_if_no_if.rb @@ -39,11 +39,6 @@ module Risc produced = produce_body assert_equal Parfait::NilClass , produced.next(5).constant.class end - def est_nil_check - produced = produce_body - assert_equal Label , produced.next(4).label.class - assert_equal produced.next(12) , produced.next(4).label - end def test_true_label produced = produce_body assert produced.next(8).name.start_with?("true_label") diff --git a/test/risc/interpreter/calling/test_minus.rb b/test/risc/interpreter/calling/test_minus.rb index 2b3da3d4..4c117c67 100644 --- a/test/risc/interpreter/calling/test_minus.rb +++ b/test/risc/interpreter/calling/test_minus.rb @@ -37,7 +37,7 @@ module Risc ret = main_ticks(46) assert_equal FunctionReturn , ret.class assert_equal :r3 , ret.register.symbol - assert_equal 23404 , @interpreter.get_register(ret.register) + assert_equal 40220 , @interpreter.get_register(ret.register) end end end diff --git a/test/risc/test_collector.rb b/test/risc/test_collector.rb index 2adaa3ac..b184728e 100644 --- a/test/risc/test_collector.rb +++ b/test/risc/test_collector.rb @@ -12,7 +12,7 @@ module Risc def test_simple_collect objects = Collector.collect_space(@linker) - assert_equal 564 , objects.length , objects.length.to_s + assert_equal 1564 , objects.length , objects.length.to_s end def test_collect_all_types @@ -59,7 +59,7 @@ module Risc def test_simple_collect objects = Collector.collect_space(@linker) - assert_equal 564, objects.length , objects.length.to_s + assert_equal 1564, objects.length , objects.length.to_s end def test_integer_positions diff --git a/test/risc/test_interpreter.rb b/test/risc/test_interpreter.rb index 0101bc5c..5e8f7816 100644 --- a/test/risc/test_interpreter.rb +++ b/test/risc/test_interpreter.rb @@ -55,12 +55,12 @@ module Risc end def test_pc1 @interpreter.tick - assert_equal 23320 , @interpreter.pc + assert_equal 40168 , @interpreter.pc end def test_pc2 @interpreter.tick @interpreter.tick - assert_equal 23324 , @interpreter.pc + assert_equal 40172 , @interpreter.pc end def test_tick2 @interpreter.tick diff --git a/test/risc/test_linker1.rb b/test/risc/test_linker1.rb index dc15437e..f4c101c2 100644 --- a/test/risc/test_linker1.rb +++ b/test/risc/test_linker1.rb @@ -15,7 +15,7 @@ module Risc mains = @linker.assemblers.find_all{|asm| asm.callable.name == :main } assert_equal 1 , mains.length end - def est_assembler_num + def test_assembler_num assert_equal 22 , @linker.assemblers.length end end