fix slot moves for assignment

This commit is contained in:
Torsten Ruger 2017-09-10 13:04:36 +03:00
parent 66901eeb5b
commit 43d660d2d2
4 changed files with 21 additions and 4 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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