2019-10-05 18:37:24 +02:00
|
|
|
module SlotLanguage
|
2020-02-13 07:02:23 +01:00
|
|
|
# A Assignment makes SlotLoad. That means it stores the information
|
2020-02-12 09:41:16 +01:00
|
|
|
# to be able to create a SlotLoad
|
|
|
|
#
|
2020-02-13 07:10:04 +01:00
|
|
|
# Just like the SlotLoad stores two Slots, here we store two Variables
|
2020-02-12 09:41:16 +01:00
|
|
|
#
|
2020-02-13 07:02:23 +01:00
|
|
|
class Assignment
|
2020-02-13 07:10:04 +01:00
|
|
|
# The two Variables that become Slots in to_slot
|
2019-10-05 18:37:24 +02:00
|
|
|
attr_reader :left , :right
|
|
|
|
|
|
|
|
def initialize(left , right)
|
|
|
|
@left = left
|
|
|
|
@right = right
|
2020-02-13 07:10:04 +01:00
|
|
|
raise "No Slot #{left}" unless left.is_a?(Variable)
|
|
|
|
raise "No Slot #{right}" unless right.is_a?(Variable)
|
2019-10-05 18:37:24 +02:00
|
|
|
end
|
2019-10-07 19:14:40 +02:00
|
|
|
|
2020-02-13 07:10:04 +01:00
|
|
|
# create the SlotLoad, by creating the two Slots from the Variables
|
2019-10-07 19:14:40 +02:00
|
|
|
def to_slot(compiler)
|
2020-02-12 09:41:16 +01:00
|
|
|
left_d = @left.to_slot(compiler)
|
|
|
|
right_d = @right.to_slot(compiler)
|
2019-10-07 19:14:40 +02:00
|
|
|
SlotMachine::SlotLoad.new("source" , left_d , right_d)
|
|
|
|
end
|
2019-10-05 18:37:24 +02:00
|
|
|
end
|
|
|
|
end
|