rubyx/lib/sol/macro_expression.rb
Torsten Rüger c1679bd6ff Makes slots linked list
slots used to ba an array of symbols
Now we have an object for each slot, that holds the name and the next_slot
relatively easy change, though quite broad
2020-02-17 14:29:45 +07:00

28 lines
730 B
Ruby

module Sol
class MacroExpression < CallStatement
def initialize(name , arguments )
super(name , SelfExpression.new , arguments)
end
def to_slot(compiler)
parts = name.to_s.split("_")
class_name = "SlotMachine::#{parts.collect{|s| s.capitalize}.join}"
eval(class_name).new( self , *arguments)
end
# When used as right hand side, this tells what data to move to get the result into
# a varaible. It is (off course) the return value of the message
def to_slotted(_)
SlotMachine::Slotted.for(:message ,[ :return_value])
end
def to_s(depth = 0)
sen = "X.#{name}(#{@arguments.collect{|a| a.to_s}.join(', ')})"
at_depth(depth , sen)
end
end
end