start with #11

by adding striaght to compiler
This commit is contained in:
Torsten Ruger
2018-08-19 12:56:44 +03:00
parent 5b2c7745fe
commit 047a36178f
4 changed files with 27 additions and 21 deletions

View File

@ -7,7 +7,8 @@ module Mom
Parfait.boot!
@compiler = Risc::FakeCompiler.new
@definition = SlotDefinition.new(StringConstant.new("hi") , [])
@instruction = @definition.to_register(@compiler , InstructionMock.new)
@register = @definition.to_register(@compiler , InstructionMock.new)
@instruction = @compiler.instructions.first
end
def test_def_class
assert_equal Risc::LoadConstant , @instruction.class

View File

@ -6,7 +6,8 @@ module Mom
Parfait.boot!
@compiler = Risc::FakeCompiler.new
@definition = SlotDefinition.new(:message , :caller)
@instruction = @definition.to_register(@compiler , InstructionMock.new)
@register = @definition.to_register(@compiler , "fake source")
@instruction = @compiler.instructions.first
end
def test_def_class
assert_equal Risc::SlotToReg , @instruction.class
@ -18,7 +19,7 @@ module Mom
assert_equal :r0 , @instruction.array.symbol
end
def test_def_register # to next free register r1
assert_equal :r1 , @instruction.register.symbol
assert_equal :r1 , @register.symbol
end
def test_def_index # at caller index 6
assert_equal 6 , @instruction.index

View File

@ -6,22 +6,22 @@ module Mom
Parfait.boot!
@compiler = Risc::FakeCompiler.new
@definition = SlotDefinition.new(:message , [:caller , :type])
@instruction = @definition.to_register(@compiler , InstructionMock.new)
@register = @definition.to_register(@compiler , InstructionMock.new)
end
def test_def_next_class
assert_equal Risc::SlotToReg , @instruction.next.class
assert_equal Risc::SlotToReg , @compiler.instructions[1].class
end
def test_def_next_next_class
assert_equal NilClass , @instruction.next.next.class
assert_equal NilClass , @compiler.instructions[2].class
end
def test_def_next_index
assert_equal 0 , @instruction.next.index
assert_equal 0 , @compiler.instructions[1].index
end
def test_def_next_register
assert_equal :r1 , @instruction.next.register.symbol
assert_equal :r1 , @compiler.instructions[1].register.symbol
end
def test_def_next_array
assert_equal :r1 , @instruction.next.array.symbol
assert_equal :r1 , @compiler.instructions[1].array.symbol
end
end
end