public boolean visit(MethodInvocation node) {
if (!isActive()) {
return false;
}
IMethodBinding methodBinding = (IMethodBinding) node.getName().resolveBinding();
if (methodBinding == null) {
// could be the receiver is not visible - for example a private
// field access from super class
ASTNode root = node.getRoot();
if (root instanceof CompilationUnit) {
CompilationUnit cu = (CompilationUnit) root;
IProblem[] problems = cu.getProblems();
for (IProblem problem : problems) {
setHasError(true);
addErrorMessage(problem.getMessage());
}
}
}
if (hasErrors()) {
return false;
}
if (containsALocalType(methodBinding)) {
setHasError(true);
addErrorMessage(EvaluationEngineMessages.ASTInstructionCompiler_Method_which_contains_a_local_type_as_parameter_cannot_be_used_in_an_evaluation_expression_32);
return false;
}
int paramCount = methodBinding.getParameterTypes().length;
String selector = methodBinding.getName();
String signature = getMethodSignature(methodBinding, null).replace('.',
'/');
boolean isStatic = Flags.isStatic(methodBinding.getModifiers());
Expression expression = node.getExpression();
if (isStatic) {
String typeName = getTypeName(methodBinding.getDeclaringClass());
push(new SendStaticMessage(typeName, selector, signature,
paramCount, fCounter));
if (expression != null) {
node.getExpression().accept(this);
addPopInstruction();
}
} else {
push(new SendMessage(selector, signature, paramCount, null,
fCounter));
if (expression == null) {
push(new PushThis(getEnclosingLevel(node,
methodBinding.getDeclaringClass())));
storeInstruction();
} else {
node.getExpression().accept(this);
}
}