rubyx/lib/ruby/send_statement.rb
Torsten Ruger 61225c2f20 ifx most of the conversion
well . . it's still converting to ruby, minor detail
2018-07-19 14:59:10 +03:00

40 lines
1.0 KiB
Ruby

module Ruby
class SendStatement < Statement
attr_reader :name , :receiver , :arguments
def initialize(name , receiver , arguments )
@name , @receiver , @arguments = name , receiver , arguments
@arguments ||= []
end
def to_vool
statements = Statements.new([])
arguments = []
@arguments.each_with_index do |arg , index |
normalize_arg(arg , arguments , statements)
end
if statements.empty?
return SendStatement.new(@name, @receiver , @arguments)
else
statements << SendStatement.new(@name, @receiver , arguments)
return statements
end
end
def to_vool_arg(arg , arguments , statements)
if arg.respond_to?(:slot_definition) and !arg.is_a?(SendStatement)
arguments << arg
return
end
assign = LocalAssignment.new( "tmp_#{arg.object_id}".to_sym, arg)
statements << assign
arguments << LocalVariable.new(assign.name)
end
def to_s
"#{receiver}.#{name}(#{arguments.join(', ')})"
end
end
end