rubyx/lib/vool/call_statement.rb
Torsten Ruger 1d2ec8e8ac abstract CallStatement base class, just like in ruby
to_mom differs much more than the to_vool in ruby,
but data and base functionality still warrent unification
also we can check for CallStatement now
2018-07-30 14:45:37 +03:00

32 lines
799 B
Ruby

module Vool
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 slot_definition(compiler)
Mom::SlotDefinition.new(: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