move each slot instruction into own file

This commit is contained in:
Torsten Ruger
2018-03-14 17:36:55 +05:30
parent a3890afc20
commit b854c075b2
4 changed files with 39 additions and 28 deletions

View File

@ -31,37 +31,12 @@ module Mom
left = SlotDefinition.new(left.shift , left) if left.is_a? Array
@left , @right = left , right
raise "left not SlotDefinition, #{left}" unless left.is_a? SlotDefinition
# raise "right not Mom, #{right.to_rxf}" unless right.class.name.include?("Mom")
end
def to_risc(compiler)
Risc::Label.new(self,"nosense")
end
end
# A SlotConstant moves a constant into a known Slot.
# Eg when you write a = 5 , the 5 becomes a constant, and so the right side
# the a is an instance variable on the current frame, and the frame is an instance
# of the current message, so the effect is something like message.frame.a = 5
# @left: See SlotLoad, an array of symbols
# @right: A Constant from parse, ie an instance of classes in basc_value, like TrueStatement
class SlotConstant < SlotLoad
def initialize(left , right)
super
raise "right not constant, #{right}" unless right.is_a? Mom::Constant
end
end
#SlotMove is a SlotLoad where the right side is a slot, just like the left.
class SlotMove < SlotLoad
def to_risc(compiler)
raise "right not Mom, #{right.to_rxf}" unless right.class.name.include?("Mom")
end
end
class SlotDefinition
attr_reader :known_object , :slots
def initialize( object , slots)