Rename SlotDefinition to Slot

And the derived XXDefinitions to XXSlot

Just to be more consistent
And possibly free the Definition for the Language side
This commit is contained in:
2020-02-11 16:19:52 +07:00
parent ec8794191d
commit 3c762c4fe7
45 changed files with 102 additions and 106 deletions

View File

@ -3,7 +3,7 @@ require_relative "helper"
module SlotMachine
class TestArgumentTransfer < SlotMachineInstructionTest
def instruction
receiver = MessageDefinition.new( [:receiver])
receiver = MessageSlot.new( [:receiver])
arg = SlotLoad.new("test", [:message, :caller] , [:message,:type] )
ArgumentTransfer.new("" , receiver ,[arg])
end

View File

@ -2,11 +2,11 @@ require_relative "helper"
module SlotMachine
class TestSlotDefinitionConstant < MiniTest::Test
class TestSlotConstant < MiniTest::Test
def setup
Parfait.boot!(Parfait.default_test_options)
@compiler = Risc::FakeCompiler.new
@definition = SlotDefinition.for(StringConstant.new("hi") , [])
@definition = Slot.for(StringConstant.new("hi") , [])
@register = @definition.to_register(@compiler , InstructionMock.new)
@instruction = @compiler.instructions.first
end
@ -23,11 +23,11 @@ module SlotMachine
assert_equal "[StringConstant]" , @definition.to_s
end
end
class TestSlotDefinitionConstantType < MiniTest::Test
class TestSlotConstantType < MiniTest::Test
def setup
Parfait.boot!(Parfait.default_test_options)
@compiler = Risc::FakeCompiler.new
@definition = SlotDefinition.for(StringConstant.new("hi") , [:type])
@definition = Slot.for(StringConstant.new("hi") , [:type])
@register = @definition.to_register(@compiler , InstructionMock.new)
@instruction = @compiler.instructions.first
end

View File

@ -1,10 +1,10 @@
require_relative "helper"
module SlotMachine
class TestSlotDefinitionBasics < MiniTest::Test
class TestSlotBasics < MiniTest::Test
def slot(slot = :caller)
MessageDefinition.new(slot)
MessageSlot.new(slot)
end
def test_create_ok1
assert_equal :message , slot.known_object

View File

@ -3,7 +3,7 @@ require_relative "helper"
module SlotMachine
class TestNotSameCheck < SlotMachineInstructionTest
def instruction
target = SlotDefinition.for(:message , :caller)
target = Slot.for(:message , :caller)
NotSameCheck.new(target , target , Label.new("ok" , "target"))
end
def test_len

View File

@ -0,0 +1,23 @@
require_relative "helper"
module SlotMachine
class TestSlotBasics < MiniTest::Test
def slot(slot = :caller)
MessageSlot.new(slot)
end
def test_create_ok1
assert_equal :message , slot.known_object
end
def test_create_ok2
assert_equal Array , slot.slots.class
assert_equal :caller , slot.slots.first
end
def test_to_s
assert_equal "[message, caller]" , slot.to_s
end
def test_create_fail_none
assert_raises {slot(nil)}
end
end
end

View File

@ -1,11 +1,11 @@
require_relative "helper"
module SlotMachine
class TestSlotDefinitionKnown1 < MiniTest::Test
class TestSlotKnown1 < MiniTest::Test
def setup
Parfait.boot!(Parfait.default_test_options)
@compiler = Risc::FakeCompiler.new
@definition = MessageDefinition.new( :caller)
@definition = MessageSlot.new( :caller)
@register = @definition.to_register(@compiler , "fake source")
@instruction = @compiler.instructions.first
end

View File

@ -1,27 +0,0 @@
require_relative "helper"
module SlotMachine
class TestSlotDefinitionKnown2 < MiniTest::Test
def setup
Parfait.boot!(Parfait.default_test_options)
@compiler = Risc::FakeCompiler.new
@definition = MessageDefinition.new( [:caller , :type])
@register = @definition.to_register(@compiler , InstructionMock.new)
end
def test_def_next_class
assert_equal Risc::SlotToReg , @compiler.instructions[1].class
end
def test_def_next_next_class
assert_equal NilClass , @compiler.instructions[2].class
end
def test_def_next_index
assert_equal 0 , @compiler.instructions[1].index
end
def test_def_next_register
assert_equal :r1 , @compiler.instructions[1].register.symbol
end
def test_def_next_array
assert_equal :r1 , @compiler.instructions[1].array.symbol
end
end
end

View File

@ -3,7 +3,7 @@ require_relative "helper"
module SlotMachine
class TestSameCheck < SlotMachineInstructionTest
def instruction
target = MessageDefinition.new( :caller)
target = MessageSlot.new( :caller)
TruthCheck.new(target , Label.new("ok" , "target"))
end
def test_len

View File

@ -53,11 +53,11 @@ module Sol
assert_equal SlotLoad, @ins.class
end
def test_left
assert_equal MessageDefinition , @ins.left.class
assert_equal MessageSlot , @ins.left.class
assert_equal [:return_value] , @ins.left.slots
end
def test_right
assert_equal MessageDefinition , @ins.right.class
assert_equal MessageSlot , @ins.right.class
assert_equal [:receiver , :inst] , @ins.right.slots
end
end

View File

@ -31,7 +31,7 @@ module Sol
def test_receiver
assert_equal SlotMachine::ArgumentTransfer, @ins.next(1).class
assert_equal 0, @ins.next(1).arguments.length
assert_equal ObjectDefinition, @ins.next(1).receiver.class
assert_equal ObjectSlot, @ins.next(1).receiver.class
assert_equal Parfait::Class, @ins.next(1).receiver.known_object.class
assert_equal :Space, @ins.next(1).receiver.known_object.name
end

View File

@ -34,12 +34,12 @@ module Sol
assert_equal MessageSetup , @ins.class , @ins
end
def test_receiver
assert_equal SlotDefinition, @ins.next.receiver.class
assert_equal Slot, @ins.next.receiver.class
assert_equal Parfait::Class, @ins.next.receiver.known_object.class
assert_equal :Object , @ins.next.receiver.known_object.name
end
def test_receiver_move
assert_equal ObjectDefinition, @ins.next.receiver.class
assert_equal ObjectSlot, @ins.next.receiver.class
end
def test_receiver
assert_equal Parfait::Class, @ins.next.receiver.known_object.class

View File

@ -73,7 +73,7 @@ module SolBlocks
def test_assigns_move
@ins = compile_main_block( "@a = arg")
assert_equal SlotMachine::SlotLoad , @ins.class , @ins
assert_equal SlotMachine::MessageDefinition , @ins.right.class , @ins
assert_equal SlotMachine::MessageSlot , @ins.right.class , @ins
end
end

View File

@ -12,7 +12,7 @@ module SolBlocks
assert_equal TruthCheck , @ins.next(3).class
end
def test_condition_is_slot
assert_equal MessageDefinition , @ins.next(3).condition.class , @ins
assert_equal MessageSlot , @ins.next(3).condition.class , @ins
end
def test_simple_call
assert_equal SimpleCall , @ins.next(2).class

View File

@ -15,7 +15,7 @@ module SolBlocks
assert_equal TruthCheck , @ins.next.class , @ins
end
def test_condition_is_slot
assert_equal MessageDefinition , @ins.next.condition.class , @ins
assert_equal MessageSlot , @ins.next.condition.class , @ins
end
def test_array
check_array [Label, TruthCheck, SlotLoad, Jump, Label,

View File

@ -8,7 +8,7 @@ module Sol
"self.get_internal_word(0);return"
end
def test_receiver
assert_equal MessageDefinition, @ins.next.receiver.class
assert_equal MessageSlot, @ins.next.receiver.class
end
def test_arg_one
assert_equal SlotLoad, @ins.next(1).arguments[0].class
@ -23,7 +23,7 @@ module Sol
assert_equal :get_internal_word, @ins.next(2).method.name
end
def test_receiver_move
assert_equal MessageDefinition, @ins.next.receiver.class
assert_equal MessageSlot, @ins.next.receiver.class
end
end

View File

@ -14,7 +14,7 @@ module Sol
assert_equal :div4, @ins.next(2).method.name
end
def test_receiver_move
assert_equal ConstantDefinition, @ins.next.receiver.class
assert_equal ConstantSlot, @ins.next.receiver.class
end
end

View File

@ -24,7 +24,7 @@ module Sol
Label, ReturnSequence , Label] , @ins
end
def test_receiver_move
assert_equal ConstantDefinition, @ins.next.receiver.class
assert_equal ConstantSlot, @ins.next.receiver.class
end
end

View File

@ -79,7 +79,7 @@ module Sol
@compiler = compile_main( "@a = arg;return")
@ins = @compiler.slot_instructions.next
assert_equal SlotMachine::SlotLoad , @ins.class , @ins
assert_equal SlotMachine::MessageDefinition , @ins.right.class , @ins
assert_equal SlotMachine::MessageSlot , @ins.right.class , @ins
end
end

View File

@ -18,7 +18,7 @@ module Sol
assert_equal TruthCheck , @ins.next.class , @ins
end
def test_condition_is_slot
assert_equal MessageDefinition , @ins.next.condition.class , @ins
assert_equal MessageSlot , @ins.next.condition.class , @ins
end
def test_label_after_check
assert_equal Label , @ins.next(2).class , @ins

View File

@ -14,7 +14,7 @@ module Sol
assert_equal TruthCheck , @ins.class , @ins
end
def test_condition_is_slot
assert_equal MessageDefinition , @ins.condition.class , @ins
assert_equal MessageSlot , @ins.condition.class , @ins
end
def test_label_after_check
assert_equal Label , @ins.next.class , @ins

View File

@ -14,7 +14,7 @@ module Sol
assert_equal TruthCheck , @ins.class , @ins
end
def test_condition_is_slot
assert_equal MessageDefinition , @ins.condition.class , @ins
assert_equal MessageSlot , @ins.condition.class , @ins
end
def test_label_after_check
assert_equal Label , @ins.next.class , @ins

View File

@ -14,7 +14,7 @@ module Sol
assert_equal TruthCheck , @ins.class , @ins
end
def test_condition_is_slot
assert_equal MessageDefinition , @ins.condition.class , @ins
assert_equal MessageSlot , @ins.condition.class , @ins
end
def test_label_after_check
assert_equal Label , @ins.next.class , @ins

View File

@ -13,7 +13,7 @@ module Sol
assert_equal TruthCheck , @ins.next(3).class
end
def test_condition_is_slot
assert_equal MessageDefinition , @ins.next(3).condition.class , @ins
assert_equal MessageSlot , @ins.next(3).condition.class , @ins
end
def test_hoisted_call
assert_equal SimpleCall , @ins.next(2).class

View File

@ -16,7 +16,7 @@ module Sol
assert_equal TruthCheck , @ins.next.class , @ins
end
def test_condition_is_slot
assert_equal MessageDefinition , @ins.next.condition.class , @ins
assert_equal MessageSlot , @ins.next.condition.class , @ins
end
def test_array
check_array [Label, TruthCheck, SlotLoad, Jump, Label ,

View File

@ -14,7 +14,7 @@ module Sol
assert_equal TruthCheck , @ins.next(4).class
end
def test_condition_is_slot
assert_equal MessageDefinition , @ins.next(4).condition.class , @ins
assert_equal MessageSlot , @ins.next(4).condition.class , @ins
end
def test_hoisetd
jump = @ins.next(8)

View File

@ -28,13 +28,13 @@ module Sol
assert_equal [:next_message, :arg1], left.slots
end
def test_check_left
assert_equal ObjectDefinition, @ins.left.class
assert_equal ObjectSlot, @ins.left.class
assert_equal Parfait::CallableMethod, @ins.left.known_object.class
assert_equal :main, @ins.left.known_object.name
assert @ins.left.slots.empty?
end
def test_check_right
assert_equal MessageDefinition, @ins.right.class
assert_equal MessageSlot, @ins.right.class
assert_equal :message, @ins.right.known_object
assert_equal [:method] , @ins.right.slots
end