def process_call(exp)
receiver_node_type = exp.first.nil? ? nil : exp.first.first
receiver = process exp.shift
receiver = "(#{receiver})" if
Ruby2Ruby::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 = process exp.shift
args << arg unless arg.empty?
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