assert (JProgram.isClinit(clinit));
return new JMethodCall(sourceInfo, null, clinit);
}
private JMultiExpression createMultiExpressionForInstanceAndClinit(JExpression x) {
JMultiExpression multi = new JMultiExpression(x.getSourceInfo());
JMethodCall clinit = null;
if (x instanceof JMethodCall) {
JExpression instance = ((JMethodCall) x).getInstance();
// Any instance expression goes first (this can happen even with statics).
if (instance != null) {
multi.addExpressions(instance);
JLocal var = JProgram.createLocal(instance.getSourceInfo(), "$t", instance.getType(),
false, body);
JLocalRef localRef = new JLocalRef(var.getSourceInfo(), var);
instance = new JBinaryOperation(instance.getSourceInfo(), localRef.getType(),
JBinaryOperator.ASG, localRef, instance);
}
clinit = createClinitCall(x.getSourceInfo(),
((JMethodCall) x).getTarget().getEnclosingType());
} else if (x instanceof JFieldRef) {
clinit = createClinitCall(x.getSourceInfo(), ((JFieldRef) x).getEnclosingType());
}
// If we need a clinit call, add it first
if (clinit != null) {
multi.addExpressions(clinit);
}
multi.addExpressions(x);
return multi;
}
@Override
public void endVisit(JMethodCall x, Context ctx) {