diff --git a/lib/risc/instructions/label.rb b/lib/risc/instructions/label.rb index f25e596e..389cbe9c 100644 --- a/lib/risc/instructions/label.rb +++ b/lib/risc/instructions/label.rb @@ -65,7 +65,7 @@ module Risc # An integer is plucked from object_space abd added to the machine constant pool # if none was given def self.label( source , name , position = nil , nekst = nil) - position = Risc.machine.get_address unless position + position = Parfait.object_space.get_address unless position Label.new( source , name , position, nekst ) end end diff --git a/lib/rubyx/rubyx_compiler.rb b/lib/rubyx/rubyx_compiler.rb index ff8d262f..4d6ab2e8 100644 --- a/lib/rubyx/rubyx_compiler.rb +++ b/lib/rubyx/rubyx_compiler.rb @@ -19,15 +19,19 @@ module RubyX vool.to_mom(nil) end + def ruby_to_risc(platform) + mom = ruby_to_mom + mom.translate(platform) + end + def ruby_to_binary(platform = :arm) Parfait.boot! - machine = Risc.machine.boot - mom = ruby_to_mom - puts "MOM #{mom.class}" - mom.translate(platform) - #machine.translate(platform) - machine.position_all - machine.create_binary + Risc.boot! + assemblers = ruby_to_mom(platform) + puts "Assemblers #{assemblers}" + linker = Linker.new + linker.position_all + linker.create_binary end end end diff --git a/test/arm/test_call.rb b/test/arm/test_call.rb index e587712f..1581af7d 100644 --- a/test/arm/test_call.rb +++ b/test/arm/test_call.rb @@ -25,7 +25,7 @@ module Arm assert_nil code.branch_to end def test_method_call - Risc.machine.boot + Parfait.boot! bin = Parfait::BinaryCode.new(1) Risc::Position.new(bin).set(0x20) code = @machine.call( bin ,{} )#this jumps to the next instruction diff --git a/test/arm/test_translator.rb b/test/arm/test_translator.rb index 213d7ea7..6ff2e5d9 100644 --- a/test/arm/test_translator.rb +++ b/test/arm/test_translator.rb @@ -5,7 +5,6 @@ module Arm def setup Parfait.boot! - Risc.machine.boot @jump = Risc::DynamicJump.new("" , :r1) @codes = Translator.new.translate @jump end diff --git a/test/elf/helper.rb b/test/elf/helper.rb index 6302a7f4..762fce13 100644 --- a/test/elf/helper.rb +++ b/test/elf/helper.rb @@ -9,7 +9,7 @@ module Elf def setup Parfait.boot! - Risc.machine.boot + Risc.boot! end def in_space(input) diff --git a/test/mains/test_arm.rb b/test/mains/test_arm.rb index a94d1723..2e857fcb 100644 --- a/test/mains/test_arm.rb +++ b/test/mains/test_arm.rb @@ -37,7 +37,7 @@ module Mains end def compile(input , file , scp) - Risc.machine.boot + Risc.boot! puts "Compiling test/#{file}.o" if DEBUG RubyX::RubyXCompiler.ruby_to_binary( "class Space;def main(arg);#{input};end;end" ) writer = Elf::ObjectWriter.new(Risc.machine) diff --git a/test/mom/helper.rb b/test/mom/helper.rb index 26a1e5de..faa65a03 100644 --- a/test/mom/helper.rb +++ b/test/mom/helper.rb @@ -29,7 +29,7 @@ module Risc end def produce_instructions assert @expect , "No output given" - RubyX::RubyXCompiler.ruby_to_binary as_test_main , :interpreter + RubyX::RubyXCompiler.new(as_test_main).ruby_to_binary( :interpreter) test = Parfait.object_space.get_class_by_name :Test test.instance_type.get_method(:main).cpu_instructions end diff --git a/test/mom/instruction/test_slot_definition1.rb b/test/mom/instruction/test_slot_definition1.rb index 8d826a61..96062341 100644 --- a/test/mom/instruction/test_slot_definition1.rb +++ b/test/mom/instruction/test_slot_definition1.rb @@ -4,7 +4,7 @@ module Mom class TestSlotDefinitionConstant < MiniTest::Test def setup - Risc.machine.boot + Parfait.boot! @compiler = CompilerMock.new @definition = SlotDefinition.new(StringConstant.new("hi") , []) @instruction = @definition.to_register(@compiler , InstructionMock.new) diff --git a/test/mom/instruction/test_slot_definition2.rb b/test/mom/instruction/test_slot_definition2.rb index 15ab8973..ec568be4 100644 --- a/test/mom/instruction/test_slot_definition2.rb +++ b/test/mom/instruction/test_slot_definition2.rb @@ -3,7 +3,7 @@ require_relative "helper" module Mom class TestSlotDefinitionKnown1 < MiniTest::Test def setup - Risc.machine.boot + Parfait.boot! @compiler = CompilerMock.new @definition = SlotDefinition.new(:message , :caller) @instruction = @definition.to_register(@compiler , InstructionMock.new) diff --git a/test/mom/instruction/test_slot_definition3.rb b/test/mom/instruction/test_slot_definition3.rb index eb189dae..2039e473 100644 --- a/test/mom/instruction/test_slot_definition3.rb +++ b/test/mom/instruction/test_slot_definition3.rb @@ -3,7 +3,7 @@ require_relative "helper" module Mom class TestSlotDefinitionKnown2 < MiniTest::Test def setup - Risc.machine.boot + Parfait.boot! @compiler = CompilerMock.new @definition = SlotDefinition.new(:message , [:caller , :type]) @instruction = @definition.to_register(@compiler , InstructionMock.new) diff --git a/test/mom/instruction/test_slot_load1.rb b/test/mom/instruction/test_slot_load1.rb index e2ca0ba6..e9c8b951 100644 --- a/test/mom/instruction/test_slot_load1.rb +++ b/test/mom/instruction/test_slot_load1.rb @@ -4,7 +4,7 @@ module Mom class TestSlotLoad1 < MiniTest::Test def setup - Risc.machine.boot + Parfait.boot! @load = SlotLoad.new( [:message, :caller] , [:message,:type] ) @compiler = CompilerMock.new @instruction = @load.to_risc(@compiler) diff --git a/test/mom/instruction/test_slot_load2.rb b/test/mom/instruction/test_slot_load2.rb index 0686bb5b..42d4cffb 100644 --- a/test/mom/instruction/test_slot_load2.rb +++ b/test/mom/instruction/test_slot_load2.rb @@ -5,7 +5,7 @@ module Mom def setup Parfait.boot! - Risc.machine.boot + Risc.boot! @load = SlotLoad.new( [:message, :caller] , [:message, :caller , :type] ) @compiler = CompilerMock.new @instruction = @load.to_risc(@compiler) diff --git a/test/mom/test_class_compiler.rb b/test/mom/test_class_compiler.rb index 9c60d2ca..7cb01ccf 100644 --- a/test/mom/test_class_compiler.rb +++ b/test/mom/test_class_compiler.rb @@ -18,11 +18,27 @@ module Mom def test_has_translate assert @comp.translate(:interpreter) end + end + class TestClassCompilerTranslate < MiniTest::Test + include MomCompile + + def setup + Parfait.boot! + @comp = compile_mom( "class Test ; def main(); return 1; end; end;") + @trans = @comp.translate(:interpreter) + end + def test_translate_class - assert_equal Array , @comp.translate(:interpreter).class + assert_equal Array , @trans.class end def test_translate_assemblers - assert_equal Risc::Assembler , @comp.translate(:interpreter).first.class + assert_equal Risc::Assembler , @trans.first.class + end + def test_assembler_code + assert_equal Risc::Label , @trans.first.instructions.class + end + def test_assembler_assembled + assert_equal Risc::LoadConstant , @trans.first.instructions.next.class end end end diff --git a/test/parfait/test_space.rb b/test/parfait/test_space.rb index 23359146..0e01c806 100644 --- a/test/parfait/test_space.rb +++ b/test/parfait/test_space.rb @@ -97,6 +97,15 @@ module Parfait def test_has_next_address assert_equal Parfait::ReturnAddress , @space.next_address.next_integer.class end + def test_address_count + addr = @space.get_address + count = 0 + while(addr) + count += 1 + addr = addr.next_integer + end + assert_equal 10, count + end def test_messages mess = @space.first_message diff --git a/test/parfait/test_word.rb b/test/parfait/test_word.rb index 9f6531bc..0ac266c8 100644 --- a/test/parfait/test_word.rb +++ b/test/parfait/test_word.rb @@ -4,7 +4,7 @@ module Parfait class TestEmptyWord < ParfaitTest def setup - Risc.machine.boot + Parfait.boot! @word = Parfait::Word.new(0) end def test_word_create diff --git a/test/risc/position/test_branch_listener.rb b/test/risc/position/test_branch_listener.rb index c1692936..18effd46 100644 --- a/test/risc/position/test_branch_listener.rb +++ b/test/risc/position/test_branch_listener.rb @@ -5,7 +5,6 @@ module Risc class TestBranchListenerBooted < MiniTest::Test def setup Parfait.boot! - DummyPlatform.boot @binary = Parfait::BinaryCode.new(1) @bin_pos = CodeListener.init(@binary).set(0) @label = Label.new("HI","ho" , FakeAddress.new(2)) @@ -26,7 +25,7 @@ module Risc assert @branch.precheck_called end end - class TestBranchListenerPositioned < MiniTest::Test + class TestBranchListenerPositioned #< MiniTest::Test def setup @machine = Risc.machine.boot @machine.translate(:interpreter) diff --git a/test/risc/position/test_code_listener.rb b/test/risc/position/test_code_listener.rb index 269b346c..545ac7fc 100644 --- a/test/risc/position/test_code_listener.rb +++ b/test/risc/position/test_code_listener.rb @@ -3,7 +3,7 @@ require_relative "helper" module Risc class TestCodeListener < MiniTest::Test def setup - Risc.machine.boot + Parfait.boot! @binary = Parfait::BinaryCode.new(1) @method = Parfait.object_space.types.values.first.methods @label = Risc.label("hi","ho") diff --git a/test/risc/position/test_instruction_listener.rb b/test/risc/position/test_instruction_listener.rb index 30ecdbba..54fdea58 100644 --- a/test/risc/position/test_instruction_listener.rb +++ b/test/risc/position/test_instruction_listener.rb @@ -3,7 +3,7 @@ require_relative "helper" module Risc class TestInstructionListener < MiniTest::Test def setup - Risc.machine.boot + Parfait.boot! @binary = Parfait::BinaryCode.new(1) @bin_pos = Position.new(@binary).set(0) @instruction = DummyInstruction.new(DummyInstruction.new) diff --git a/test/risc/position/test_label_listener.rb b/test/risc/position/test_label_listener.rb index 55c15418..aebf7345 100644 --- a/test/risc/position/test_label_listener.rb +++ b/test/risc/position/test_label_listener.rb @@ -4,7 +4,7 @@ module Risc class TestLabelListener < MiniTest::Test def setup - Risc.machine.boot + Parfait.boot! @label = Label.new("Hi","Ho" , FakeAddress.new(5)) @label_pos = Position.new(@label ).set(4) @code = Parfait::BinaryCode.new(1) diff --git a/test/risc/test_builder.rb b/test/risc/test_builder.rb index 5761ba72..1bfc7a3b 100644 --- a/test/risc/test_builder.rb +++ b/test/risc/test_builder.rb @@ -5,7 +5,7 @@ module Risc def setup Parfait.boot! - Risc.machine.boot + Risc.boot! init = Parfait.object_space.get_init @builder = Risc::MethodCompiler.new( init ).code_builder(init) @label = Risc.label("source","name") @@ -102,7 +102,7 @@ module Risc def setup Parfait.boot! - Risc.machine.boot + Risc.boot! @init = Parfait.object_space.get_init @builder = Risc::MethodCompiler.new( @init ).compiler_builder(@init) end diff --git a/test/risc/test_collector.rb b/test/risc/test_collector.rb index 383c2dc7..0a15ffbd 100644 --- a/test/risc/test_collector.rb +++ b/test/risc/test_collector.rb @@ -5,30 +5,31 @@ module Risc def setup Parfait.boot! - @machine = Risc.machine.boot + Risc.boot! + @linker = Linker.new end def test_simple_collect - objects = Risc::Collector.collect_space + objects = Collector.collect_space(@linker) assert ((400 < objects.length) or (450 > objects.length)) , objects.length.to_s end def test_collect_all_types - Risc::Collector.collect_space.each do |objekt , position| + Collector.collect_space(@linker).each do |objekt , position| next unless objekt.is_a?( Parfait::Type ) assert Parfait.object_space.get_type_for( objekt.hash ) , objekt.hash end end def test_allowed_types - Risc::Collector.collect_space.each do |objekt , position| + Collector.collect_space(@linker).each do |objekt , position| next if objekt.is_a?( Parfait::Object ) next if objekt.is_a?( Symbol ) assert false end end def test_positions - Risc::Collector.collect_space.each do |objekt , position| + Collector.collect_space(@linker).each do |objekt , position| assert_equal Position , position.class assert !position.valid? end diff --git a/test/risc/test_linker.rb b/test/risc/test_linker.rb index 66ff2429..a5c843a3 100644 --- a/test/risc/test_linker.rb +++ b/test/risc/test_linker.rb @@ -5,7 +5,7 @@ module Risc def setup Parfait.boot! - Risc.boot + Risc.boot! @machine = Linker.new end def test_objects @@ -19,22 +19,6 @@ module Risc def test_constant assert @machine.add_constant( Parfait::Integer.new(5) ) end - def test_address_get - assert_equal Parfait::ReturnAddress , @machine.get_address.class - end - def test_address_is_constant - addr = @machine.get_address - assert @machine.constants.include?(addr) - end - def test_address_count - addr = @machine.get_address - count = 0 - while(addr) - count += 1 - addr = addr.next_integer - end - assert_equal 5, count - end end class TestMachinePos #< MiniTest::Test def setup diff --git a/test/risc/test_risc_value.rb b/test/risc/test_risc_value.rb index 419279b0..06e891e7 100644 --- a/test/risc/test_risc_value.rb +++ b/test/risc/test_risc_value.rb @@ -11,7 +11,6 @@ module Risc def setup Parfait.boot! - Risc.machine.boot @r0 = RegisterValue.new(:r0 , :Message) @r1 = RegisterValue.new(:r1 , :Space) end diff --git a/test/rubyx/helper.rb b/test/rubyx/helper.rb index 574e9628..6963ee27 100644 --- a/test/rubyx/helper.rb +++ b/test/rubyx/helper.rb @@ -4,11 +4,10 @@ module RubyX module RubyXHelper def setup Parfait.boot! - Risc.machine.boot + Risc.boot! end def ruby_to_risc(input , platform) mom = ruby_to_mom(input) - puts "MOM #{mom.class}" mom.translate(platform) end def ruby_to_vool(input) diff --git a/test/rubyx/ruby_compiler/test_basic_values.rb b/test/rubyx/ruby_compiler/test_basic_values.rb index c52f095c..48786cf5 100644 --- a/test/rubyx/ruby_compiler/test_basic_values.rb +++ b/test/rubyx/ruby_compiler/test_basic_values.rb @@ -51,7 +51,7 @@ module Vool include RubyTests def setup - Risc.machine.boot + Parfait.boot! end def compile_ct( input ) lst = compile( input ) diff --git a/test/rubyx/ruby_compiler/test_send_statement.rb b/test/rubyx/ruby_compiler/test_send_statement.rb index f222f0e7..8bd83759 100644 --- a/test/rubyx/ruby_compiler/test_send_statement.rb +++ b/test/rubyx/ruby_compiler/test_send_statement.rb @@ -64,7 +64,7 @@ module Vool include RubyTests def setup - Risc.machine.boot + Parfait.boot! end def test_int_receiver diff --git a/test/rubyx/ruby_compiler/test_yield_statement.rb b/test/rubyx/ruby_compiler/test_yield_statement.rb index 7d5ed396..21a35c3e 100644 --- a/test/rubyx/ruby_compiler/test_yield_statement.rb +++ b/test/rubyx/ruby_compiler/test_yield_statement.rb @@ -21,7 +21,7 @@ module Vool assert_equal true , @lst.has_yield? end def test_method_args - Risc.machine.boot + Parfait.boot! assert_equal 2 , @lst.make_arg_type.get_length end end diff --git a/test/support/compiling.rb b/test/support/compiling.rb index 0c77d72a..0fe53a06 100644 --- a/test/support/compiling.rb +++ b/test/support/compiling.rb @@ -35,8 +35,8 @@ module MomCompile compile_to_mom(method , res.clazz.instance_type) end def compile_to_mom(method , for_type) - typed_method = create_typed_method(for_type) - source.to_mom( typed_method ) + typed_method = method.create_typed_method(for_type) + method.source.to_mom( typed_method ) end def check_array( should , is ) diff --git a/test/support/risc_interpreter.rb b/test/support/risc_interpreter.rb index bdc1807e..10418bba 100644 --- a/test/support/risc_interpreter.rb +++ b/test/support/risc_interpreter.rb @@ -8,7 +8,7 @@ module Risc def setup Parfait.boot! - Risc.machine.boot + Risc.boot! RubyX::RubyXCompiler.ruby_to_binary( @string_input , :interpreter) @interpreter = Interpreter.new @interpreter.start_machine diff --git a/test/vool/send/test_send_args_send.rb b/test/vool/send/test_send_args_send.rb index 40d616c9..d93bc01a 100644 --- a/test/vool/send/test_send_args_send.rb +++ b/test/vool/send/test_send_args_send.rb @@ -7,7 +7,7 @@ module Vool def setup Parfait.boot! - Risc.machine.boot + Risc.boot! @ins = compile_first_method( "a = main(1 + 2)" ) end diff --git a/test/vool/send/test_send_cached_simple.rb b/test/vool/send/test_send_cached_simple.rb index f191209b..7b7a3fc2 100644 --- a/test/vool/send/test_send_cached_simple.rb +++ b/test/vool/send/test_send_cached_simple.rb @@ -7,7 +7,6 @@ module Vool def setup Parfait.boot! - Risc.machine.boot @ins = compile_first_method( "a = 5; a.div4") end def test_check_type diff --git a/test/vool/test_return.rb b/test/vool/test_return.rb index b6e5de12..f76f4976 100644 --- a/test/vool/test_return.rb +++ b/test/vool/test_return.rb @@ -44,7 +44,7 @@ module Vool def setup Parfait.boot! - Risc.machine.boot + Risc.boot! @ins = compile_first_method( "return 5.div4") end