def process_call(exp)
receiver_node_type = exp.first.nil? ? nil : exp.first.first
receiver = process exp.shift
receiver = "(#{receiver})" if ASSIGN_NODES.include? receiver_node_type
name = exp.shift
args = []
exp.push(*exp.pop[1..-1]) if exp.size == 1 && exp.first.first == :arglist
@calls.push name
in_context :arglist do
until exp.empty? do
arg_type = exp.first.sexp_type
arg = process exp.shift
next if arg.empty?
strip_hash = (arg_type == :hash and
not BINARY.include? name and
(exp.empty? or exp.first.sexp_type == :splat))
wrap_arg = Ruby2Ruby::ASSIGN_NODES.include? arg_type
arg = arg[2..-3] if strip_hash
arg = "(#{arg})" if wrap_arg
args << arg
end
end
case name
when *BINARY then
"(#{receiver} #{name} #{args.join(', ')})"
when :[] then
receiver ||= "self"
"#{receiver}[#{args.join(', ')}]"
when :[]= then
receiver ||= "self"
rhs = args.pop
"#{receiver}[#{args.join(', ')}] = #{rhs}"
when "-@""-@" then
"-#{receiver}"
when "+@""+@" then
"+#{receiver}"
else
args = nil if args.empty?
args = "(#{args.join(', ')})" if args
receiver = "#{receiver}." if receiver
"#{receiver}#{name}#{args}"
end
ensure
@calls.pop
end