diff --git a/lib/slot_language/load_maker.rb b/lib/slot_language/assignment.rb similarity index 88% rename from lib/slot_language/load_maker.rb rename to lib/slot_language/assignment.rb index ca919531..075db043 100644 --- a/lib/slot_language/load_maker.rb +++ b/lib/slot_language/assignment.rb @@ -1,10 +1,10 @@ module SlotLanguage - # A LoadMaker makes SlotLoad. That means it stores the information + # A Assignment makes SlotLoad. That means it stores the information # to be able to create a SlotLoad # # Just like the SlotLoad stores two Slots, here we store two SlotMakers # - class LoadMaker + class Assignment # The two SlotMakers that become Slots in to_slot attr_reader :left , :right diff --git a/lib/slot_language/slot_compiler.rb b/lib/slot_language/slot_compiler.rb index d688b932..bcd2ee77 100644 --- a/lib/slot_language/slot_compiler.rb +++ b/lib/slot_language/slot_compiler.rb @@ -45,7 +45,7 @@ module SlotLanguage puts "lvasgn #{expression}" if DEBUG name = expression.children[0] value = process(expression.children[1]) - LoadMaker.new(SlotMaker.new(name),value) + Assignment.new(SlotMaker.new(name),value) end alias :on_ivasgn :on_lvasgn @@ -99,14 +99,14 @@ module SlotLanguage receiver.add_slot_name(name) right = process kids.shift puts "Assign #{name} , #{receiver}" if DEBUG - LoadMaker.new(receiver,right) + Assignment.new(receiver,right) end end end require_relative "named_slot" require_relative "message_slot" require_relative "slot_maker" -require_relative "load_maker" +require_relative "assignment" require_relative "macro_maker" require_relative "goto" require_relative "equal_goto" diff --git a/lib/slot_language/slot_maker.rb b/lib/slot_language/slot_maker.rb index 0f5c27e3..4d202443 100644 --- a/lib/slot_language/slot_maker.rb +++ b/lib/slot_language/slot_maker.rb @@ -3,8 +3,8 @@ module SlotLanguage # variable in an object. This Language level "Maker" holds the information # (names of instance variables) to be able to create the Slot instance # - # In the SlotLanguage this is used in the LoadMaker. Just as a Slotload stores - # two slots to define what is loaded where, the LoadMaker, that creates a SlotLoad, + # In the SlotLanguage this is used in the Assignment. Just as a Slotload stores + # two slots to define what is loaded where, the Assignment, that creates a SlotLoad, # uses two SlotMakers. class SlotMaker # stores the (instance) names that allow us to create a Slot diff --git a/test/slot_language/test_assignment.rb b/test/slot_language/test_assignment.rb new file mode 100644 index 00000000..c6900b3a --- /dev/null +++ b/test/slot_language/test_assignment.rb @@ -0,0 +1,41 @@ +require_relative "helper" + +module SlotLanguage + class TestAssignment < MiniTest::Test + include SlotHelper + + def test_slot_load_rinst + assert_equal Assignment , compile_class("a = @b") + end + def test_slot_load_linst + assert_equal Assignment , compile_class("@a = b") + end + def test_slot_load_lrinst + assert_equal Assignment , compile_class("@a = @b") + end + def test_slot_load_linst_trav + assert_equal Assignment , compile_class("@a = b.c") + end + def test_slot_load_linst_trav2 + assert_equal Assignment , compile_class("@a.c = b.c") + end + def test_assign + assign = compile("c = d") + assert_equal Assignment , assign.class + end + def test_assign1 + assign = compile("c = c.next") + assert_equal Assignment , assign.class + end + def test_assign2 + assign = compile("c.next = d") + assert_equal Assignment , assign.class + end + def test_shift + load = compile("word = name.member") + assert_equal Assignment , load.class + assert_equal :word , load.left.names.first + assert_equal SlotMaker , load.right.class + end + end +end diff --git a/test/slot_language/test_load_maker.rb b/test/slot_language/test_load_maker.rb deleted file mode 100644 index c54f6da0..00000000 --- a/test/slot_language/test_load_maker.rb +++ /dev/null @@ -1,16 +0,0 @@ -require_relative "helper" - -module SlotLanguage - class TestLoadMaker < MiniTest::Test - include SlotToHelper - def setup - super - left = SlotMaker.new(:hi ) - right = SlotMaker.new(:hi ) - @slot = LoadMaker.new( left,right ).to_slot(@compiler) - end - def test_to_slot - assert_equal SlotMachine::SlotLoad , @slot.class - end - end -end diff --git a/test/slot_language/test_slot_compiler.rb b/test/slot_language/test_slot_compiler.rb index 2d8f4528..a10dcedd 100644 --- a/test/slot_language/test_slot_compiler.rb +++ b/test/slot_language/test_slot_compiler.rb @@ -13,38 +13,5 @@ module SlotLanguage def test_compile assert_equal SlotMaker , compile("a").class end - def test_slot_load_rinst - assert_equal LoadMaker , compile_class("a = @b") - end - def test_slot_load_linst - assert_equal LoadMaker , compile_class("@a = b") - end - def test_slot_load_lrinst - assert_equal LoadMaker , compile_class("@a = @b") - end - def test_slot_load_linst_trav - assert_equal LoadMaker , compile_class("@a = b.c") - end - def test_slot_load_linst_trav2 - assert_equal LoadMaker , compile_class("@a.c = b.c") - end - def test_assign - assign = compile("c = d") - assert_equal LoadMaker , assign.class - end - def test_assign1 - assign = compile("c = c.next") - assert_equal LoadMaker , assign.class - end - def test_assign2 - assign = compile("c.next = d") - assert_equal LoadMaker , assign.class - end - def test_shift - load = compile("word = name.member") - assert_equal LoadMaker , load.class - assert_equal :word , load.left.names.first - assert_equal SlotMaker , load.right.class - end end end