rename LoadMaker to Assignment
This commit is contained in:
parent
99d2868400
commit
c194d373fb
@ -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
|
||||
|
@ -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"
|
||||
|
@ -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
|
||||
|
41
test/slot_language/test_assignment.rb
Normal file
41
test/slot_language/test_assignment.rb
Normal file
@ -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
|
@ -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
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user