diff --git a/lib/arm/arm_platform.rb b/lib/arm/arm_platform.rb index 3f34f8bf..5f3fef0b 100644 --- a/lib/arm/arm_platform.rb +++ b/lib/arm/arm_platform.rb @@ -1,6 +1,6 @@ require_relative "translator" module Arm - class ArmPlatform + class ArmPlatform < Risc::Platform def translator Translator.new end diff --git a/lib/risc/interpreter_platform.rb b/lib/risc/interpreter_platform.rb index 4220e4b5..69bd93af 100644 --- a/lib/risc/interpreter_platform.rb +++ b/lib/risc/interpreter_platform.rb @@ -1,6 +1,6 @@ module Risc - class InterpreterPlatform + class InterpreterPlatform < Platform def translator IdentityTranslator.new end diff --git a/lib/risc/linker.rb b/lib/risc/linker.rb index 8babd81a..19d7c9b4 100644 --- a/lib/risc/linker.rb +++ b/lib/risc/linker.rb @@ -13,7 +13,13 @@ module Risc include Util::Logging log_level :info - def initialize + def initialize(platform) + if(platform.is_a?(Symbol)) + platform = platform.to_s.capitalize + platform = Risc::Platform.for(platform) + end + raise "Platform must be platform, not #{platform.class}" unless platform.is_a?(Platform) + @platform = platform @risc_init = nil @constants = [] end diff --git a/lib/rubyx/rubyx_compiler.rb b/lib/rubyx/rubyx_compiler.rb index 4d6ab2e8..ce8531dc 100644 --- a/lib/rubyx/rubyx_compiler.rb +++ b/lib/rubyx/rubyx_compiler.rb @@ -27,9 +27,9 @@ module RubyX def ruby_to_binary(platform = :arm) Parfait.boot! Risc.boot! - assemblers = ruby_to_mom(platform) + assemblers = ruby_to_mom puts "Assemblers #{assemblers}" - linker = Linker.new + linker = Risc::Linker.new(platform) linker.position_all linker.create_binary end diff --git a/test/risc/test_linker.rb b/test/risc/test_linker.rb index a5c843a3..c44ffe53 100644 --- a/test/risc/test_linker.rb +++ b/test/risc/test_linker.rb @@ -6,7 +6,7 @@ module Risc def setup Parfait.boot! Risc.boot! - @machine = Linker.new + @machine = Linker.new(:arm) end def test_objects objects = @machine.object_positions @@ -20,11 +20,12 @@ module Risc assert @machine.add_constant( Parfait::Integer.new(5) ) end end - class TestMachinePos #< MiniTest::Test + class TestMachinePos < MiniTest::Test def setup Parfait.boot! - @machine = Risc.machine.boot - @machine.translate(:arm) + Risc.boot! + @linker = Linker.new(:arm) + @linker.translate @machine.position_all end def test_positions_set diff --git a/test/support/risc_interpreter.rb b/test/support/risc_interpreter.rb index 10418bba..2143980b 100644 --- a/test/support/risc_interpreter.rb +++ b/test/support/risc_interpreter.rb @@ -9,7 +9,7 @@ module Risc def setup Parfait.boot! Risc.boot! - RubyX::RubyXCompiler.ruby_to_binary( @string_input , :interpreter) + RubyX::RubyXCompiler.new(@string_input).ruby_to_binary( :interpreter) @interpreter = Interpreter.new @interpreter.start_machine end