diff --git a/lib/mom/instruction/slot_definition.rb b/lib/mom/instruction/slot_definition.rb index 1aa058d2..ca5bee1e 100644 --- a/lib/mom/instruction/slot_definition.rb +++ b/lib/mom/instruction/slot_definition.rb @@ -63,7 +63,11 @@ module Mom parfait = known_object.to_parfait(compiler) const = Risc.load_constant(source, parfait , right) compiler.add_code const - raise "Can't have slots into Constants" if slots.length > 0 + if slots.length == 1 + raise "only type allowed for constants, not #{slots[0]}" unless slots[0] == :type + compiler.add_code Risc::SlotToReg.new( source , right , Parfait::TYPE_INDEX, right) + end + raise "Can't have slots into Constants #{slots}" if slots.length > 1 when Parfait::Object , Risc::Label const = const = Risc.load_constant(source, known_object , right) compiler.add_code const diff --git a/test/mains/test_arm.rb b/test/mains/test_arm.rb index 84dca1da..1b648db4 100644 --- a/test/mains/test_arm.rb +++ b/test/mains/test_arm.rb @@ -12,7 +12,7 @@ module Mains def self.Qemu @Qemu end - DEBUG = true + DEBUG = false # runnable_methods is called by minitest to determine which tests to run def self.runnable_methods @@ -37,7 +37,7 @@ module Mains def self.has_qemu if `uname -a`.include?("torsten") @Linker = "arm-linux-gnu-ld" - #return false + return false end begin `#{@Qemu} -version` diff --git a/test/mom/helper.rb b/test/mom/helper.rb index d7f69ca0..c9e5a6f5 100644 --- a/test/mom/helper.rb +++ b/test/mom/helper.rb @@ -28,7 +28,9 @@ module Risc end def to_target assert @expect , "No output given" - RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_target(as_test_main,:interpreter) + compiler = RubyX::RubyXCompiler.new(RubyX.default_test_options) + vool = compiler.ruby_to_vool(as_test_main) + compiler.to_target(:interpreter) end def produce_main produce_target(:main) diff --git a/test/mom/instruction/test_slot_definition1.rb b/test/mom/instruction/test_slot_definition1.rb index 189c4aea..ef4f1449 100644 --- a/test/mom/instruction/test_slot_definition1.rb +++ b/test/mom/instruction/test_slot_definition1.rb @@ -23,4 +23,31 @@ module Mom assert_equal "[StringConstant]" , @definition.to_s end end + class TestSlotDefinitionConstantType < MiniTest::Test + def setup + Parfait.boot!(Parfait.default_test_options) + @compiler = Risc::FakeCompiler.new + @definition = SlotDefinition.new(StringConstant.new("hi") , [:type]) + @register = @definition.to_register(@compiler , InstructionMock.new) + @instruction = @compiler.instructions.first + end + def test_def_class + assert_equal Risc::LoadConstant , @instruction.class + end + def test_def_register + assert_equal :r1 , @instruction.register.symbol + end + def test_def_const + assert_equal "hi" , @instruction.constant.to_string + end + def test_to_s + assert_equal "[StringConstant, type]" , @definition.to_s + end + def test_def_register2 + assert_equal :r1 , @compiler.instructions[1].register.symbol + end + def test_def_next_index + assert_equal 0 , @compiler.instructions[1].index + end + end end