private void replaceForPrunedParameters(JMethodCall x, JMethodCall newCall,
Context ctx) {
assert !x.getTarget().canBePolymorphic();
List<JParameter> originalParams = methodToOriginalParamsMap.get(x.getTarget());
JMultiExpression currentMulti = null;
for (int i = 0, c = x.getArgs().size(); i < c; ++i) {
JExpression arg = x.getArgs().get(i);
JParameter param = null;
if (i < originalParams.size()) {
param = originalParams.get(i);
}
if (param != null && referencedNonTypes.contains(param)) {
// If there is an existing multi, terminate it.
if (currentMulti != null) {
currentMulti.exprs.add(arg);
newCall.addArg(currentMulti);
currentMulti = null;
} else {
newCall.addArg(arg);
}
} else if (arg.hasSideEffects()) {
// The argument is only needed for side effects, add it to a multi.
if (currentMulti == null) {
currentMulti = new JMultiExpression(x.getSourceInfo());
}
currentMulti.exprs.add(arg);
}
}