private static boolean isThisOrSuper(Expression expression) { return isThisExpression(expression) || isSuperExpression(expression); }
private static boolean isGroovyObject(Expression objectExpression) { return isThisExpression(objectExpression) || objectExpression.getType().isDerivedFromGroovyObject() && !(objectExpression instanceof ClassExpression); }
private boolean isStaticInvocation(MethodCallExpression call) { if (!AsmClassGenerator.isThisExpression(call.getObjectExpression())) return false; if (controller.isStaticMethod()) return true; return controller.isStaticContext() && !call.isImplicitThis(); }
public void makeCall( Expression origin, Expression receiver, Expression message, Expression arguments, MethodCallerMultiAdapter adapter, boolean safe, boolean spreadSafe, boolean implicitThis ) { ClassNode cn = controller.getClassNode(); if (controller.isInClosure() && !implicitThis && AsmClassGenerator.isThisExpression(receiver)) cn=cn.getOuterClass(); makeCall(origin, new ClassExpression(cn), receiver, message, arguments, adapter, safe, spreadSafe, implicitThis); }
@Override public void visitMethodCallExpression(MethodCallExpression expression) { if (expression.getNodeMetaData(StatementMeta.class)!=null) return; super.visitMethodCallExpression(expression); Expression object = expression.getObjectExpression(); boolean setTarget = AsmClassGenerator.isThisExpression(object); if (!setTarget) { if (!(object instanceof ClassExpression)) return; setTarget = object.equals(node); } if (!setTarget) return; setMethodTarget(expression, expression.getMethodAsString(), expression.getArguments(), true); }
private boolean isClosureCall(MethodCallExpression call) { // are we a local variable? // it should not be an explicitly "this" qualified method call // and the current class should have a possible method ClassNode classNode = controller.getClassNode(); String methodName = call.getMethodAsString(); if (methodName==null) return false; if (!call.isImplicitThis()) return false; if (!AsmClassGenerator.isThisExpression(call.getObjectExpression())) return false; FieldNode field = classNode.getDeclaredField(methodName); if (field == null) return false; if (isStaticInvocation(call) && !field.isStatic()) return false; Expression arguments = call.getArguments(); return ! classNode.hasPossibleMethod(methodName, arguments); }
public void writeInvokeMethod(MethodCallExpression call) { if (isClosureCall(call)) { // let's invoke the closure method invokeClosure(call.getArguments(), call.getMethodAsString()); } else { boolean isSuperMethodCall = usesSuper(call); MethodCallerMultiAdapter adapter = invokeMethod; if (isSuperMethodCall && call.isSafe()) { // safe is not necessary here because "super" is always not null // but keeping the flag would trigger a VerifyError (see GROOVY-6045) call.setSafe(false); } if (AsmClassGenerator.isThisExpression(call.getObjectExpression())) adapter = invokeMethodOnCurrent; if (isSuperMethodCall) adapter = invokeMethodOnSuper; if (isStaticInvocation(call)) adapter = invokeStaticMethod; makeInvokeMethodCall(call, isSuperMethodCall, adapter); } }
&& isThisExpression(objectExpression) && controller.isStaticContext()) {
protected boolean isGroovyObject(Expression objectExpression) { return isThisExpression(objectExpression) || objectExpression.getType().isDerivedFromGroovyObject() && !(objectExpression instanceof ClassExpression); }
private static boolean isGroovyObject(Expression objectExpression) { return isThisExpression(objectExpression) || objectExpression.getType().isDerivedFromGroovyObject() && !(objectExpression instanceof ClassExpression); }
private boolean isStaticInvocation(MethodCallExpression call) { if (!AsmClassGenerator.isThisExpression(call.getObjectExpression())) return false; if (controller.isStaticMethod()) return true; return controller.isStaticContext() && !call.isImplicitThis(); }
private boolean isStaticInvocation(MethodCallExpression call) { if (!isThisExpression(call.getObjectExpression())) return false; if (isStaticMethod()) return true; return isStaticContext() && !call.isImplicitThis(); }
private boolean isStaticInvocation(MethodCallExpression call) { if (!isThisExpression(call.getObjectExpression())) return false; if (isStaticMethod()) return true; return isStaticContext() && !call.isImplicitThis(); }
private boolean isStaticInvocation(MethodCallExpression call) { if (!isThisExpression(call.getObjectExpression())) return false; if (isStaticMethod()) return true; return isStaticContext() && !call.isImplicitThis(); }
@Override public void visitMethodCallExpression(MethodCallExpression expression) { if (expression.getNodeMetaData(StatementMeta.class)!=null) return; super.visitMethodCallExpression(expression); Expression object = expression.getObjectExpression(); boolean setTarget = AsmClassGenerator.isThisExpression(object); if (!setTarget) { if (!(object instanceof ClassExpression)) return; setTarget = object.equals(node); } if (!setTarget) return; setMethodTarget(expression, expression.getMethodAsString(), expression.getArguments(), true); }
public void makeCall( Expression origin, Expression receiver, Expression message, Expression arguments, MethodCallerMultiAdapter adapter, boolean safe, boolean spreadSafe, boolean implicitThis ) { ClassNode cn = controller.getClassNode(); if (controller.isInClosure() && !implicitThis && AsmClassGenerator.isThisExpression(receiver)) cn=cn.getOuterClass(); makeCall(origin, new ClassExpression(cn), receiver, message, arguments, adapter, safe, spreadSafe, implicitThis); }
private boolean isClosureCall(MethodCallExpression call) { // are we a local variable? // it should not be an explicitly "this" qualified method call // and the current class should have a possible method String methodName = call.getMethodAsString(); if (methodName==null) return false; if (!call.isImplicitThis()) return false; if (!isThisExpression(call.getObjectExpression())) return false; //if (isNotExplicitThisInClosure(call.isImplicitThis()) return false; if (classNode.getDeclaredField(methodName) == null) return false; Expression arguments = call.getArguments(); return ! classNode.hasPossibleMethod(methodName, arguments); }
private boolean isClosureCall(MethodCallExpression call) { // are we a local variable? // it should not be an explicitly "this" qualified method call // and the current class should have a possible method String methodName = call.getMethodAsString(); if (methodName==null) return false; if (!call.isImplicitThis()) return false; if (!isThisExpression(call.getObjectExpression())) return false; //if (isNotExplicitThisInClosure(call.isImplicitThis()) return false; if (classNode.getDeclaredField(methodName) == null) return false; Expression arguments = call.getArguments(); return ! classNode.hasPossibleMethod(methodName, arguments); }
public void writeInvokeMethod(MethodCallExpression call) { if (isClosureCall(call)) { // let's invoke the closure method invokeClosure(call.getArguments(), call.getMethodAsString()); } else { boolean isSuperMethodCall = usesSuper(call); MethodCallerMultiAdapter adapter = invokeMethod; if (AsmClassGenerator.isThisExpression(call.getObjectExpression())) adapter = invokeMethodOnCurrent; if (isSuperMethodCall) adapter = invokeMethodOnSuper; if (isStaticInvocation(call)) adapter = invokeStaticMethod; makeInvokeMethodCall(call, isSuperMethodCall, adapter); } }
private boolean isClosureCall(MethodCallExpression call) { // are we a local variable? // it should not be an explicitly "this" qualified method call // and the current class should have a possible method String methodName = call.getMethodAsString(); if (methodName==null) return false; if (!call.isImplicitThis()) return false; if (!isThisExpression(call.getObjectExpression())) return false; FieldNode field = classNode.getDeclaredField(methodName); if (field == null) return false; if (isStaticInvocation(call) && !field.isStatic()) return false; Expression arguments = call.getArguments(); return ! classNode.hasPossibleMethod(methodName, arguments); }