Torsten Rüger
c1679bd6ff
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
32 lines
787 B
Ruby
32 lines
787 B
Ruby
module Sol
|
|
|
|
class CallStatement < Statement
|
|
attr_reader :name , :receiver , :arguments
|
|
|
|
def initialize(name , receiver , arguments )
|
|
@name , @receiver , @arguments = name , receiver , arguments
|
|
@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 = "#{receiver}.#{name}(#{@arguments.collect{|a| a.to_s}.join(', ')})"
|
|
at_depth(depth , sen)
|
|
end
|
|
|
|
def each(&block)
|
|
block.call(self)
|
|
block.call(@receiver)
|
|
@arguments.each do |arg|
|
|
block.call(arg)
|
|
end
|
|
end
|
|
|
|
end
|
|
end
|