2019-10-03 23:36:49 +02:00
|
|
|
module Sol
|
2018-07-30 13:45:37 +02:00
|
|
|
|
|
|
|
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
|
2020-02-17 08:29:45 +01:00
|
|
|
def to_slotted(_)
|
2020-02-15 15:02:03 +01:00
|
|
|
SlotMachine::Slotted.for(:message ,[ :return_value])
|
2018-07-30 13:45:37 +02:00
|
|
|
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
|