public static StaticMethodCallExpression callX(ClassNode receiver, String methodName, Expression args) { return new StaticMethodCallExpression(receiver, methodName, args); }
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 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); }
@Override public void visitStaticMethodCallExpression(StaticMethodCallExpression expression) { if (expression.getNodeMetaData(StatementMeta.class)!=null) return; super.visitStaticMethodCallExpression(expression); setMethodTarget(expression,expression.getMethod(), expression.getArguments(), true); }
public Expression transformExpression(ExpressionTransformer transformer) { Expression ret = new StaticMethodCallExpression(getOwnerType(), method, transformer.transform(arguments)); ret.setSourcePosition(this); ret.copyNodeMetaData(this); return ret; }
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; }
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); }
(hasPossibleStaticMethod(currentClass, methodName, args, true)) || hasPossibleStaticProperty(currentClass, methodName)) { StaticMethodCallExpression smce = new StaticMethodCallExpression(currentClass, methodName, args); setSourcePosition(smce, mce); return smce; } else if (hasPossibleStaticMethod(currentClass.getOuterClass(), methodName, args, true) || hasPossibleStaticProperty(currentClass.getOuterClass(), methodName)) { StaticMethodCallExpression smce = new StaticMethodCallExpression(currentClass.getOuterClass(), methodName, args); setSourcePosition(smce, mce); return smce; StaticMethodCallExpression result = new StaticMethodCallExpression(currentClass, methodName, args); result.setSourcePosition(mce); return result;
public String toString() { return super.toString() + "[" + getOwnerType().getName() + "#" + method + " arguments: " + arguments + "]"; }
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)); }
public void visitStaticMethodCallExpression(StaticMethodCallExpression call) { call.getArguments().visit(this); }
public void visitStaticMethodCallExpression(final StaticMethodCallExpression call) { assertExpressionAuthorized(call); final String typeName = call.getOwnerType().getName(); if (receiversWhiteList != null && !receiversWhiteList.contains(typeName)) { throw new SecurityException("Method calls not allowed on [" + typeName + "]"); } else if (receiversBlackList != null && receiversBlackList.contains(typeName)) { throw new SecurityException("Method calls not allowed on [" + typeName + "]"); } call.getArguments().visit(this); }
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) {
@Override public void visitStaticMethodCallExpression(StaticMethodCallExpression expression) { List<MethodNode> possibleMethods = expression.getOwnerType().getMethods(expression.getMethodAsString()); if (!possibleMethods.isEmpty() && expression.getArguments() instanceof ArgumentListExpression) { ArgumentListExpression actualArguments = (ArgumentListExpression) expression.getArguments(); possibleMethods.stream() .filter(method -> areEquals(method.getParameters(), actualArguments)) .forEach(method -> indexer.addReference(createLocation(method), createLocation(expression))); } super.visitStaticMethodCallExpression(expression); }
public static String getMethodName(Expression invocation) { if (invocation instanceof MethodCallExpression) { return ((MethodCallExpression) invocation).getMethodAsString(); } if (invocation instanceof StaticMethodCallExpression) { return ((StaticMethodCallExpression) invocation).getMethod(); } return null; }
public Expression transformExpression(ExpressionTransformer transformer) { Expression ret = new StaticMethodCallExpression(getOwnerType(), method, transformer.transform(arguments)); ret.setSourcePosition(this); return ret; }
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; }
@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); Expression callArguments = call.getArguments(); final ClassNode receiver = call.getOwnerType(); visitMethodCallArguments(receiver, argumentList, false, null); visitMethodCallArguments(receiver, argumentList, true, (MethodNode) call.getNodeMetaData(StaticTypesMarker.DIRECT_METHOD_CALL_TARGET));
StaticMethodCallExpression smce = new StaticMethodCallExpression(currentClass, methodName, args); smce.setSourcePosition(mce); return smce;