From f5d1090c39ed3d953e6d13d00ce4db4015593b93 Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Wed, 23 May 2018 18:06:55 +0300 Subject: [PATCH] no-ops really --- Guardfile | 2 +- lib/risc/interpreter_platform.rb | 12 +++++++----- lib/risc/machine.rb | 2 +- lib/risc/position.rb | 2 +- test/mom/helper.rb | 11 +++++++---- test/risc/interpreter/assign/test_assign_local.rb | 10 +++++----- test/risc/test_interpreter_platform.rb | 2 +- 7 files changed, 23 insertions(+), 18 deletions(-) diff --git a/Guardfile b/Guardfile index 2b2f9eb6..880c1dba 100644 --- a/Guardfile +++ b/Guardfile @@ -1,7 +1,7 @@ # A sample Guardfile # More info at https://github.com/guard/guard#readme -guard :minitest do # with Minitest::Unit +guard :minitest , all_on_start: false do # with Minitest::Unit # if any test file changes, run that test watch(%r{^test/(.*)\/?test_(.*)\.rb$}) diff --git a/lib/risc/interpreter_platform.rb b/lib/risc/interpreter_platform.rb index c809f031..3289440c 100644 --- a/lib/risc/interpreter_platform.rb +++ b/lib/risc/interpreter_platform.rb @@ -14,6 +14,7 @@ module Risc class Instruction def nil_next @next = nil + self end def byte_length 4 @@ -30,12 +31,13 @@ module Risc end class IdentityTranslator def translate(code) - #return Label.new( code.source , code.name ) if code.is_a?(Label) - if( code.is_a?(Branch)) - return code.class.new(code.source , code.label.to_cpu(self)) + case code + when Branch + ret = code.class.new(code.source , code.label.to_cpu(self)) + else + ret = code.dup + ret.nil_next end - ret = code.dup - ret.nil_next ret end end diff --git a/lib/risc/machine.rb b/lib/risc/machine.rb index 77a4fc9b..7829156b 100644 --- a/lib/risc/machine.rb +++ b/lib/risc/machine.rb @@ -14,7 +14,7 @@ module Risc class Machine include Util::Logging - log_level :debug + log_level :info def initialize @booted = false diff --git a/lib/risc/position.rb b/lib/risc/position.rb index 1c760bdb..9ced4c30 100644 --- a/lib/risc/position.rb +++ b/lib/risc/position.rb @@ -16,7 +16,7 @@ module Risc module Position include Util::Logging - log_level :debug + log_level :info @positions = {} diff --git a/test/mom/helper.rb b/test/mom/helper.rb index ad154ced..e542181a 100644 --- a/test/mom/helper.rb +++ b/test/mom/helper.rb @@ -9,10 +9,10 @@ module Risc end def preamble - [Label ] + [ Label ] end def postamble - [ Label] + [ Label ] end # test hack to in place change object type def add_space_field(name,type) @@ -24,11 +24,14 @@ module Risc preamble.each{ produced = produced.next } produced end + def as_test_main + "class Test; def main(arg);#{@input};end;end" + end def produce_instructions assert @expect , "No output given" - Vool::VoolCompiler.ruby_to_vool "class Test; def main(arg);#{@input};end;end" + Vool::VoolCompiler.ruby_to_binary as_test_main , :interpreter test = Parfait.object_space.get_class_by_name :Test - test.instance_type.get_method( :main).risc_instructions + test.instance_type.get_method(:main).cpu_instructions end def check_nil produced = produce_instructions diff --git a/test/risc/interpreter/assign/test_assign_local.rb b/test/risc/interpreter/assign/test_assign_local.rb index 37a39ce4..866c9a3d 100644 --- a/test/risc/interpreter/assign/test_assign_local.rb +++ b/test/risc/interpreter/assign/test_assign_local.rb @@ -9,7 +9,7 @@ module Risc super end - def test_chain + def pest_chain #show_main_ticks # get output of what is check_main_chain [Label, LoadConstant, SlotToReg, RegToSlot, SlotToReg, SlotToReg , RegToSlot, SlotToReg, SlotToReg, RegToSlot, @@ -18,7 +18,7 @@ module Risc assert_equal 15 , get_return.value end - def test_call_main + def pest_call_main call_ins = ticks(main_at) assert_equal FunctionCall , call_ins.class assert :main , call_ins.method.name @@ -29,17 +29,17 @@ module Risc assert_equal Parfait::Integer , @interpreter.get_register(load_ins.register).class assert_equal 15 , @interpreter.get_register(load_ins.register).value end - def test_return + def pest_return ret = main_ticks(13) assert_equal FunctionReturn , ret.class link = @interpreter.get_register( ret.register ) assert_equal Label , link.class end - def test_transfer + def pest_transfer transfer = main_ticks(14) assert_equal Transfer , transfer.class end - def test_sys + def pest_sys sys = main_ticks(15) assert_equal Syscall , sys.class end diff --git a/test/risc/test_interpreter_platform.rb b/test/risc/test_interpreter_platform.rb index 71d0e96d..113d45b8 100644 --- a/test/risc/test_interpreter_platform.rb +++ b/test/risc/test_interpreter_platform.rb @@ -25,7 +25,7 @@ module Risc @translator = IdentityTranslator.new end - def test_translate_label + def test_translate_first_label label = Parfait.object_space.get_main.risc_instructions assert_equal "Space_Type.main" ,label.to_cpu(@translator).name , label end