Rename SlotMaker to Variable

Feels like now with better names, i can start to work.
This commit is contained in:
2020-02-13 13:10:04 +07:00
parent c194d373fb
commit 6194148fc5
8 changed files with 31 additions and 35 deletions

View File

@ -2,20 +2,20 @@ module SlotLanguage
# 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
# Just like the SlotLoad stores two Slots, here we store two Variables
#
class Assignment
# The two SlotMakers that become Slots in to_slot
# The two Variables that become Slots in to_slot
attr_reader :left , :right
def initialize(left , right)
@left = left
@right = right
raise "No Slot #{left}" unless left.is_a?(SlotMaker)
raise "No Slot #{right}" unless right.is_a?(SlotMaker)
raise "No Slot #{left}" unless left.is_a?(Variable)
raise "No Slot #{right}" unless right.is_a?(Variable)
end
# create the SlotLoad, by creating the two Slots from the SlotMakers
# create the SlotLoad, by creating the two Slots from the Variables
def to_slot(compiler)
left_d = @left.to_slot(compiler)
right_d = @right.to_slot(compiler)

View File

@ -35,17 +35,17 @@ module SlotLanguage
return check(name,receiver, kids) if SlotCompiler.checks.include?(name)
return assign(receiver, name , kids) if(name.to_s.end_with?("="))
puts "Send #{name} , #{receiver} kids=#{kids}" if DEBUG
SlotMaker.new( name )
Variable.new( name )
end
def on_lvar(lvar)
puts "lvar #{lvar}" if DEBUG
SlotMaker.new(lvar.children.first )
Variable.new(lvar.children.first )
end
def on_lvasgn( expression)
puts "lvasgn #{expression}" if DEBUG
name = expression.children[0]
value = process(expression.children[1])
Assignment.new(SlotMaker.new(name),value)
Assignment.new(Variable.new(name),value)
end
alias :on_ivasgn :on_lvasgn
@ -64,7 +64,7 @@ module SlotLanguage
end
def on_ivar( expression)
puts "ivar #{expression}" if DEBUG
SlotMaker.new(expression.children.first)
Variable.new(expression.children.first)
end
private
@ -105,7 +105,7 @@ module SlotLanguage
end
require_relative "named_slot"
require_relative "message_slot"
require_relative "slot_maker"
require_relative "variable"
require_relative "assignment"
require_relative "macro_maker"
require_relative "goto"

View File

@ -1,12 +1,12 @@
module SlotLanguage
# A SlotMaker makes Slots. A Slot s the central SlotMachines description of a
# variable in an object. This Language level "Maker" holds the information
# A Variable makes Slots. A Slot is the central SlotMachines description of a
# variable in an object. At the Language level this holds the information
# (names of instance variables) to be able to create the Slot instance
#
# 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
# uses two Variables.
class Variable
# stores the (instance) names that allow us to create a Slot
attr_reader :names