fix moms ivar assignment
This commit is contained in:
parent
c245acbdd3
commit
1a9370ad14
@ -18,7 +18,7 @@ module Vool
|
||||
end
|
||||
|
||||
def to_mom( method )
|
||||
Mom::SlotConstant.new([:message , :self , @name] , @value)
|
||||
@value.slot_class.new([:message , :self , @name] , @value)
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -21,6 +21,11 @@ module Vool
|
||||
assert_equal :foo , lst.name
|
||||
end
|
||||
|
||||
def test_const
|
||||
lst = RubyCompiler.compile( "@foo = 5")
|
||||
assert_equal IvarAssignment , lst.class
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
|
@ -6,7 +6,7 @@ module Vool
|
||||
|
||||
def setup
|
||||
Risc.machine.boot
|
||||
@stats = compile_first_method( "arg = 5")
|
||||
@stats = compile_first_method( "local = 5")
|
||||
@first = @stats.first
|
||||
end
|
||||
|
||||
@ -20,10 +20,10 @@ module Vool
|
||||
assert_equal :message , @first.left.known_object
|
||||
end
|
||||
def test_slot_gets_self
|
||||
assert_equal :arguments , @first.left.slots[0]
|
||||
assert_equal :frame , @first.left.slots[0]
|
||||
end
|
||||
def test_slot_assigns_to_local
|
||||
assert_equal :arg , @first.left.slots[-1]
|
||||
assert_equal :local , @first.left.slots[-1]
|
||||
end
|
||||
def test_slot_assigns_something
|
||||
assert @stats.first.right
|
||||
@ -34,20 +34,19 @@ module Vool
|
||||
end
|
||||
|
||||
#otherwise as above, but assigning instance, so should get a SlotMove
|
||||
class TestAssignMomInstance < MiniTest::Test
|
||||
class TestAssignMomInstanceToLocal < MiniTest::Test
|
||||
include MomCompile
|
||||
def setup
|
||||
Risc.machine.boot
|
||||
@stats = compile_first_method( "arg = @a")
|
||||
@stats = compile_first_method( "local = @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
|
||||
class TestAssignToArg < MiniTest::Test
|
||||
include MomCompile
|
||||
|
||||
def setup
|
||||
@ -71,11 +70,20 @@ module Vool
|
||||
def test_slot_assigns_to_local
|
||||
assert_equal :arg , @first.left.slots[-1]
|
||||
end
|
||||
def test_slot_assigns_something
|
||||
assert @first.right
|
||||
end
|
||||
|
||||
class TestAssignMomToInstance < MiniTest::Test
|
||||
include MomCompile
|
||||
def setup
|
||||
Risc.machine.boot
|
||||
end
|
||||
def test_slot_assigns_int
|
||||
assert_equal IntegerStatement , @first.right.class
|
||||
def test_assigns_const
|
||||
@stats = compile_first_method( "@a = 5")
|
||||
assert_equal Mom::SlotConstant , @stats.first.class , @stats
|
||||
end
|
||||
def test_assigns_move
|
||||
@stats = compile_first_method( "@a = arg")
|
||||
assert_equal Mom::SlotMove , @stats.first.class , @stats
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user