public List<AnnotationNode> visit(AnnotationNode collector, AnnotationNode aliasAnnotationUsage, AnnotatedNode aliasAnnotated, SourceUnit source) { AnnotationNode node = new AnnotationNode(COMPILESTATIC_NODE); node.addMember("value", new PropertyExpression(new ClassExpression(TYPECHECKINGMODE_NODE), "SKIP")); return Collections.singletonList(node); } }
public static Expression getInvocationTarget(Expression expr) { if (expr instanceof PropertyExpression) return ((PropertyExpression) expr).getObjectExpression(); if (expr instanceof MethodCallExpression) return ((MethodCallExpression) expr).getObjectExpression(); if (expr instanceof StaticMethodCallExpression) return new ClassExpression(((StaticMethodCallExpression) expr).getOwnerType()); if (expr instanceof ConstructorCallExpression) return new ClassExpression(((ConstructorCallExpression) expr).getType()); return null; }
public static Expression getVariableType(BinaryExpression assignment) { ClassNode type = assignment.getLeftExpression().getType(); return type == null || type == ClassHelper.DYNAMIC_TYPE ? ConstantExpression.NULL : new ClassExpression(type); }
public static ListExpression classList2args(List<String> args) { ListExpression result = new ListExpression(); for (Object o : args) { result.addExpression(new ClassExpression(ClassHelper.make(o.toString()))); } return result; }
private static Expression findStaticField(ClassNode staticImportType, String fieldName) { if (staticImportType.isPrimaryClassNode() || staticImportType.isResolved()) { FieldNode field = getField(staticImportType, fieldName); if (field != null && field.isStatic()) return new PropertyExpression(new ClassExpression(staticImportType), fieldName); } return null; }
private TernaryExpression createStaticReceiver(final Expression receiver) { return new TernaryExpression( new BooleanExpression(new BinaryExpression( receiver, Token.newSymbol(Types.KEYWORD_INSTANCEOF, -1, -1), new ClassExpression(ClassHelper.CLASS_Type) )), receiver, new MethodCallExpression(createFieldHelperReceiver(), "getClass", ArgumentListExpression.EMPTY_ARGUMENTS) ); }
public FieldNode addLoggerFieldToClass(ClassNode classNode, String logFieldName, String categoryName) { return classNode.addField(logFieldName, Opcodes.ACC_FINAL | Opcodes.ACC_TRANSIENT | Opcodes.ACC_STATIC | Opcodes.ACC_PRIVATE, LOGGER_CLASSNODE, new MethodCallExpression( new ClassExpression(LOGGER_CLASSNODE), "getLogger", new ConstantExpression(getCategoryName(classNode, categoryName)))); }
private Expression serialize(AnnotationNode an) { MapExpression map = new MapExpression(); for (String key : an.getMembers().keySet()) { map.addMapEntryExpression(new ConstantExpression(key), serialize(an.getMember(key))); } List<Expression> l = new ArrayList<Expression>(2); l.add(new ClassExpression(an.getClassNode())); l.add(map); return new ArrayExpression(ClassHelper.OBJECT_TYPE, l); } }
private MethodCallExpression referenceToCurrentClosure() { return new MethodCallExpression( new VariableExpression("this"), new ConstantExpression("each"), new ArgumentListExpression( new PropertyExpression( new ClassExpression(ClassHelper.makeWithoutCaching(Closure.class)), new ConstantExpression("IDENTITY") ) ) ); }
public FieldNode addLoggerFieldToClass(ClassNode classNode, String logFieldName, String categoryName) { return classNode.addField(logFieldName, Opcodes.ACC_FINAL | Opcodes.ACC_TRANSIENT | Opcodes.ACC_STATIC | Opcodes.ACC_PRIVATE, classNode(LOGGER_NAME), new MethodCallExpression( new ClassExpression(classNode(LOGGERFACTORY_NAME)), "getLog", new ConstantExpression(getCategoryName(classNode, categoryName)))); }
public FieldNode addLoggerFieldToClass(ClassNode classNode, String logFieldName, String categoryName) { return classNode.addField(logFieldName, Opcodes.ACC_FINAL | Opcodes.ACC_TRANSIENT | Opcodes.ACC_STATIC | Opcodes.ACC_PRIVATE, classNode(LOGGER_NAME), new MethodCallExpression( new ClassExpression(classNode(FACTORY_NAME)), "getLogger", new ConstantExpression(getCategoryName(classNode, categoryName)))); }
public FieldNode addLoggerFieldToClass(ClassNode classNode, String logFieldName, String categoryName) { return classNode.addField(logFieldName, Opcodes.ACC_FINAL | Opcodes.ACC_TRANSIENT | Opcodes.ACC_STATIC | Opcodes.ACC_PRIVATE, classNode(LOGGER_NAME), new MethodCallExpression( new ClassExpression(classNode(LOGGER_NAME)), "getLogger", new ConstantExpression(getCategoryName(classNode, categoryName)))); }
public FieldNode addLoggerFieldToClass(ClassNode classNode, String logFieldName, String categoryName) { return classNode.addField(logFieldName, Opcodes.ACC_FINAL | Opcodes.ACC_TRANSIENT | Opcodes.ACC_STATIC | Opcodes.ACC_PRIVATE, classNode(LOGGER_NAME), new MethodCallExpression( new ClassExpression(classNode(LOG_MANAGER_NAME)), "getLogger", new ConstantExpression(getCategoryName(classNode, categoryName)))); }
private void addBlockMetadata(Block block, BlockKind kind) { AnnotationNode blockAnn = new AnnotationNode(nodeCache.BlockMetadata); blockAnn.setMember(BlockMetadata.KIND, new PropertyExpression( new ClassExpression(nodeCache.BlockKind), kind.name())); ListExpression textExprs = new ListExpression(); for (String text : block.getDescriptions()) textExprs.addExpression(new ConstantExpression(text)); blockAnn.setMember(BlockMetadata.TEXTS, textExprs); blockAnnElems.addExpression(new AnnotationConstantExpression(blockAnn)); }
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); }
public void writeInvokeStaticMethod(StaticMethodCallExpression call) { makeCall(call, new ClassExpression(call.getOwnerType()), new ConstantExpression(call.getMethod()), call.getArguments(), InvocationWriter.invokeStaticMethod, false, false, false); }
private void makeDynamicGetProperty(final Expression receiver, final String methodName, final boolean safe) { MethodNode target = safe?INVOKERHELPER_GETPROPERTYSAFE_METHOD:INVOKERHELPER_GETPROPERTY_METHOD; MethodCallExpression mce = new MethodCallExpression( new ClassExpression(INVOKERHELPER_TYPE), target.getName(), new ArgumentListExpression(receiver, new ConstantExpression(methodName)) ); mce.setSafe(false); mce.setImplicitThis(false); mce.setMethodTarget(target); mce.visit(controller.getAcg()); }
public void loadWrapper(Expression argument) { MethodVisitor mv = controller.getMethodVisitor(); ClassNode goalClass = argument.getType(); visitClassExpression(new ClassExpression(goalClass)); if (goalClass.isDerivedFromGroovyObject()) { createGroovyObjectWrapperMethod.call(mv); } else { createPojoWrapperMethod.call(mv); } controller.getOperandStack().remove(1); }
public void coerce(ClassNode from, ClassNode target) { if (from.isDerivedFrom(target)) return; MethodVisitor mv = controller.getMethodVisitor(); OperandStack os = controller.getOperandStack(); os.box(); (new ClassExpression(target)).visit(controller.getAcg()); os.remove(1); asTypeMethod.call(mv); BytecodeHelper.doCast(mv,target); os.replace(target); } }
@Override public void coerce(ClassNode from, ClassNode target) { ClassNode wrapper = ClassHelper.getWrapper(target); makeIndyCall(invokeMethod, EmptyExpression.INSTANCE, false, false, "asType", new ClassExpression(wrapper)); if (ClassHelper.boolean_TYPE.equals(target) || ClassHelper.Boolean_TYPE.equals(target)) { writeIndyCast(ClassHelper.OBJECT_TYPE,target); } else { BytecodeHelper.doCast(controller.getMethodVisitor(), wrapper); controller.getOperandStack().replace(wrapper); controller.getOperandStack().doGroovyCast(target); } }