public static String getMethodName(Expression invocation) { if (invocation instanceof MethodCallExpression) { return ((MethodCallExpression) invocation).getMethodAsString(); } if (invocation instanceof StaticMethodCallExpression) { return ((StaticMethodCallExpression) invocation).getMethod(); } return null; }
@Override public void visitStaticMethodCallExpression(StaticMethodCallExpression expression) { if (expression.getNodeMetaData(StatementMeta.class)!=null) return; super.visitStaticMethodCallExpression(expression); setMethodTarget(expression,expression.getMethod(), expression.getArguments(), true); }
public void writeInvokeStaticMethod(StaticMethodCallExpression call) { makeCall(call, new ClassExpression(call.getOwnerType()), new ConstantExpression(call.getMethod()), call.getArguments(), InvocationWriter.invokeStaticMethod, false, false, false); }
public void visitStaticMethodCallExpression(StaticMethodCallExpression call) { onLineNumber(call, "visitStaticMethodCallExpression: \"" + call.getMethod() + "\":"); controller.getInvocationWriter().writeInvokeStaticMethod(call); controller.getAssertionWriter().record(call); }
private Statement rewriteStaticMethodCondition(StaticMethodCallExpression condition, Expression message, boolean explicit) { StaticMethodCallExpression rewritten; int lastVariableNum; final Expression converted = convert(condition); rewritten = (StaticMethodCallExpression) unrecord(converted); lastVariableNum = extractVariableNumber(converted); List<Expression> args = new ArrayList<>(); args.add(new ClassExpression(rewritten.getOwnerType())); args.add(new ConstantExpression(rewritten.getMethod())); args.add(AstUtil.toArgumentArray(AstUtil.getArgumentList(rewritten), resources)); // rewriting has produced N/A's that haven't been realized yet, so do that now args.add(realizeNas(ConstantExpression.FALSE)); args.add(new ConstantExpression(explicit)); args.add(new ConstantExpression(lastVariableNum)); return surroundWithTryCatch( condition, message, rewriteToSpockRuntimeCall( resources.getAstNodeCache().SpockRuntime_VerifyMethodCondition, condition, message, args)); }
final String typename = expr.getOwnerType().getName(); assertImportIsAllowed(typename); assertStaticImportIsAllowed(expr.getMethod(), typename); } else if (expression instanceof MethodPointerExpression) { MethodPointerExpression expr = (MethodPointerExpression) expression;
@Override public void visitStaticMethodCallExpression(StaticMethodCallExpression expr) { StaticMethodCallExpression result = new StaticMethodCallExpression( expr.getOwnerType(), expr.getMethod(), replaceExpr(expr.getArguments())); result.setType(expr.getType()); result.setSourcePosition(expr); replaceVisitedExpressionWith(result); }
@Override public void visitStaticMethodCallExpression(StaticMethodCallExpression expr) { StaticMethodCallExpression conversion = new StaticMethodCallExpression( expr.getOwnerType(), recordNa(expr.getMethod()), convert(expr.getArguments())); conversion.setSourcePosition(expr); conversion.setMetaMethod(expr.getMetaMethod()); result = record(conversion); }
Expression transformStaticMethodCallExpression(final StaticMethodCallExpression orig) { MethodNode target = (MethodNode) orig.getNodeMetaData(StaticTypesMarker.DIRECT_METHOD_CALL_TARGET); if (target != null) { MethodCallExpression call = new MethodCallExpression( new ClassExpression(orig.getOwnerType()), orig.getMethod(), orig.getArguments() ); call.setMethodTarget(target); call.setSourcePosition(orig); call.copyNodeMetaData(orig); return transformer.transform(call); } return transformer.superTransform(orig); }
@Override public void visitStaticMethodCallExpression(final StaticMethodCallExpression call) { final String name = call.getMethod(); if (name == null) { addStaticTypeError("cannot resolve dynamic method name at compile time.", call);
protected Expression transformBinaryExpression(BinaryExpression be) { int type = be.getOperation().getType(); boolean oldInLeftExpression; Expression right = transform(be.getRightExpression()); be.setRightExpression(right); Expression left; if (type == Types.EQUAL && be.getLeftExpression() instanceof VariableExpression) { oldInLeftExpression = inLeftExpression; inLeftExpression = true; left = transform(be.getLeftExpression()); inLeftExpression = oldInLeftExpression; if (left instanceof StaticMethodCallExpression) { StaticMethodCallExpression smce = (StaticMethodCallExpression) left; StaticMethodCallExpression result = new StaticMethodCallExpression(smce.getOwnerType(), smce.getMethod(), right); setSourcePosition(result, be); return result; } } else { left = transform(be.getLeftExpression()); } be.setLeftExpression(left); return be; }
String baseName = fieldNode.isStatic() ? Traits.STATIC_INIT_METHOD : Traits.INIT_METHOD; StaticMethodCallExpression mce = callX(helperClassNode, baseName + fieldNode.getName(), args(varX("this"))); if (helperClassNode.hasPossibleStaticMethod(mce.getMethod(), mce.getArguments())) { Statement stmt = stmt(assignX(varX(fieldNode.getName(), fieldNode.getType()), mce)); if (isStatic == 0) {
MethodCallExpression result = new MethodCallExpression( new VariableExpression(weaved), call.getMethod(), transform(call.getArguments()) );
public void visitStaticMethodCallExpression(StaticMethodCallExpression call) { onLineNumber(call, "visitStaticMethodCallExpression: \"" + call.getMethod() + "\":"); makeCall( new ClassExpression(call.getOwnerType()), new ConstantExpression(call.getMethod()), call.getArguments(), invokeStaticMethod, false, false, false); }
public void visitStaticMethodCallExpression(StaticMethodCallExpression call) { onLineNumber(call, "visitStaticMethodCallExpression: \"" + call.getMethod() + "\":"); makeCall( new ClassExpression(call.getOwnerType()), new ConstantExpression(call.getMethod()), call.getArguments(), invokeStaticMethod, false, false, false); }
public void visitStaticMethodCallExpression(StaticMethodCallExpression call) { onLineNumber(call, "visitStaticMethodCallExpression: \"" + call.getMethod() + "\":"); makeCall( new ClassExpression(call.getOwnerType()), new ConstantExpression(call.getMethod()), call.getArguments(), invokeStaticMethod, false, false, false); }
@Override public void visitStaticMethodCallExpression(StaticMethodCallExpression expression) { if (expression.getNodeMetaData(StatementMeta.class)!=null) return; super.visitStaticMethodCallExpression(expression); setMethodTarget(expression,expression.getMethod(), expression.getArguments(), true); }
public void writeInvokeStaticMethod(StaticMethodCallExpression call) { makeCall(call, new ClassExpression(call.getOwnerType()), new ConstantExpression(call.getMethod()), call.getArguments(), InvocationWriter.invokeStaticMethod, false, false, false); }
@Override public void run() { loc(exp); literal(exp.getOwnerType()); literal(exp.getMethod()); visit(((TupleExpression) exp.getArguments()).getExpressions()); } });
@Override public void visitStaticMethodCallExpression(StaticMethodCallExpression expr) { StaticMethodCallExpression result = new StaticMethodCallExpression( expr.getOwnerType(), expr.getMethod(), replaceExpr(expr.getArguments())); result.setType(expr.getType()); result.setSourcePosition(expr); replaceVisitedExpressionWith(result); }