diff --git a/lib/vool/statements/local_statement.rb b/lib/vool/statements/local_statement.rb index dbfc0562..6e765279 100644 --- a/lib/vool/statements/local_statement.rb +++ b/lib/vool/statements/local_statement.rb @@ -12,7 +12,7 @@ module Vool else type = :frame end - Mom::SlotConstant.new(Mom::SlotDefinition.new(:message , [type , @name]) , @value) + @value.slot_class.new(Mom::SlotDefinition.new(:message , [type , @name]) , @value) end end diff --git a/test/vool/statements/test_local.rb b/test/vool/statements/test_local.rb index 13fe1e96..4ae0c1c7 100644 --- a/test/vool/statements/test_local.rb +++ b/test/vool/statements/test_local.rb @@ -11,6 +11,10 @@ module Vool lst = RubyCompiler.compile( "foo = bar") assert_equal :foo , lst.name end + def test_local_const + lst = RubyCompiler.compile( "foo = 5") + assert_equal LocalAssignment , lst.class + end end end diff --git a/test/vool/to_mom/test_assign.rb b/test/vool/to_mom/test_assign.rb index b8ba2fc6..5d8478e3 100644 --- a/test/vool/to_mom/test_assign.rb +++ b/test/vool/to_mom/test_assign.rb @@ -11,7 +11,7 @@ module Vool end def test_class_compiles - assert_equal Mom::SlotMove , @first.class , @stats + assert_equal Mom::SlotConstant , @first.class , @stats end def test_slot_is_set assert @first.left @@ -33,6 +33,19 @@ module Vool end end + #otherwise as above, but assigning instance, so should get a SlotMove + class TestAssignMomInstance < MiniTest::Test + include MomCompile + def setup + Risc.machine.boot + @stats = compile_first_method( "arg = @a") + end + + def test_class_compiles + assert_equal Mom::SlotMove , @stats.first.class , @stats + end + end + #compiling to an argument should result in different second parameter in the slot array class TestArgMom < MiniTest::Test include MomCompile @@ -44,7 +57,7 @@ module Vool end def test_class_compiles - assert_equal Mom::SlotMove , @first.class , @stats + assert_equal Mom::SlotConstant , @first.class , @stats end def test_slot_is_set assert @first.left diff --git a/test/vool/to_mom/test_local.rb b/test/vool/to_mom/test_local.rb index 4678b37c..8e4da0d5 100644 --- a/test/vool/to_mom/test_local.rb +++ b/test/vool/to_mom/test_local.rb @@ -14,7 +14,7 @@ module Vool assert Array != @stats.class , @stats end def test_class_compiles - assert_equal Mom::SlotMove , @first.class , @stats + assert_equal Mom::SlotConstant , @first.class , @stats end def test_slot_is_set assert @first.left