// RTValue.lastRef(x.evaluate(...), x = null)
// instead of:
// RTValue.lastRef(x, x = null).evaluate(...);
JavaExpression.Nameable evaluateTarget = isEvaluateInvocation(instanceInvocation);
if (evaluateTarget != null ) {
JavaExpression target = null;
if (instanceInvocation.getInvocationTarget() != null) {
target = (JavaExpression)instanceInvocation.getInvocationTarget().accept(new JavaModelCopier<Void>(), arg);
}
String varName = null;
if (evaluateTarget instanceof LocalName) {
varName = ( ((LocalName)evaluateTarget).getName());
} else if (evaluateTarget instanceof LocalVariable) {
varName = ( ((LocalVariable)evaluateTarget).getName());
} else if (evaluateTarget instanceof MethodVariable) {
varName = ( ((MethodVariable)evaluateTarget).getName());
} else {
throw new NullPointerException ("Unhandled sub type of Nameable in VarReleaser.visitInstanceMethodInvocation().");
}
JavaExpression newInvocation =
new MethodInvocation.Instance(
target,
instanceInvocation.getMethodName(),
instanceInvocation.getDeclaringClass(),
argValues,
argTypes,
instanceInvocation.getReturnType(),
instanceInvocation.getInvocationType());
if (shouldRelease(varName)) {
JavaTypeName varType = variablesOfInterest.get(varName);
variablesOfInterest.remove(varName);
return callLastRef(newInvocation, evaluateTarget, varType);
}
return newInvocation;
} else {
JavaExpression target = null;
if (instanceInvocation.getInvocationTarget() != null) {
target = (JavaExpression)instanceInvocation.getInvocationTarget().accept(this, arg);
}
JavaExpression newInvocation =
new MethodInvocation.Instance(
target,
instanceInvocation.getMethodName(),
instanceInvocation.getDeclaringClass(),
argValues,