public PropertyNode( String name, int modifiers, ClassNode type, ClassNode owner, Expression initialValueExpression, Statement getterBlock, Statement setterBlock) { this(new FieldNode(name, modifiers & ACC_STATIC, type, owner, initialValueExpression), modifiers, getterBlock, setterBlock); }
private static FieldNode createFieldCopy(ClassNode buildee, String fieldName, ClassNode fieldType) { return new FieldNode(fieldName, ACC_PRIVATE, fieldType, buildee, DEFAULT_INITIAL_VALUE); }
public static FieldNode newStatic(Class theClass, String name) throws SecurityException, NoSuchFieldException { Field field = theClass.getField(name); ClassNode fldType = ClassHelper.make(field.getType()); return new FieldNode(name, ACC_PUBLIC | ACC_STATIC, fldType, ClassHelper.make(theClass), null); }
public FieldNode addField(String name, int modifiers, ClassNode type, Expression initialValue) { FieldNode node = new FieldNode(name, modifiers, type, redirect(), initialValue); addField(node); return node; }
public FieldNode addFieldFirst(String name, int modifiers, ClassNode type, Expression initialValue) { FieldNode node = new FieldNode(name, modifiers, type, redirect(), initialValue); addFieldFirst(node); return node; }
private static FieldNode createFieldCopy(ClassNode builderClass, PropertyInfo prop) { String propName = prop.getName(); return new FieldNode(propName.equals("class") ? "clazz" : propName, ACC_PRIVATE, newClass(prop.getType()), builderClass, DEFAULT_INITIAL_VALUE); }
public void visit(ASTNode[] nodes, SourceUnit sourceUnit) { ClassNode classNode = (ClassNode) nodes[1]; classNode.addField(new FieldNode("f1", ACC_PUBLIC, ClassHelper.OBJECT_TYPE, classNode, null)); }
private void completeEnum(ClassNode enumClass) { boolean isAic = isAnonymousInnerClass(enumClass); // create MIN_VALUE and MAX_VALUE fields FieldNode minValue = null, maxValue = null, values = null; if (!isAic) { ClassNode enumRef = enumClass.getPlainNodeReference(); // create values field values = new FieldNode("$VALUES", PRIVATE_FS | Opcodes.ACC_SYNTHETIC, enumRef.makeArray(), enumClass, null); values.setSynthetic(true); addMethods(enumClass, values); checkForAbstractMethods(enumClass); // create MIN_VALUE and MAX_VALUE fields minValue = new FieldNode("MIN_VALUE", PUBLIC_FS, enumRef, enumClass, null); maxValue = new FieldNode("MAX_VALUE", PUBLIC_FS, enumRef, enumClass, null); } addInit(enumClass, minValue, maxValue, values, isAic); }
public void visit(ASTNode[] nodes, SourceUnit sourceUnit) { ClassNode classNode = (ClassNode) nodes[1]; classNode.addField(new FieldNode("f2", ACC_PUBLIC, ClassHelper.OBJECT_TYPE, classNode, null)); }
public void visit(ASTNode[] nodes, SourceUnit sourceUnit) { ClassNode classNode = (ClassNode) nodes[1]; classNode.addField(new FieldNode("f3", ACC_PUBLIC, ClassHelper.OBJECT_TYPE, classNode, null)); }
private static List<FieldNode> convertParamsToFields(ClassNode builder, Parameter[] parameters) { List<FieldNode> fieldNodes = new ArrayList<FieldNode>(); for(Parameter parameter: parameters) { Map<String,ClassNode> genericsSpec = createGenericsSpec(builder); ClassNode correctedType = correctToGenericsSpecRecurse(genericsSpec, parameter.getType()); FieldNode fieldNode = new FieldNode(parameter.getName(), parameter.getModifiers(), correctedType, builder, DEFAULT_INITIAL_VALUE); fieldNodes.add(fieldNode); builder.addField(fieldNode); } return fieldNodes; }
public static FieldNode addEnumConstant(ClassNode enumClass, String name, Expression init) { int modifiers = PUBLIC_FS | Opcodes.ACC_ENUM; if (init != null && !(init instanceof ListExpression)) { ListExpression list = new ListExpression(); list.addExpression(init); init = list; } FieldNode fn = new FieldNode(name, modifiers, enumClass.getPlainNodeReference(), enumClass, init); enumClass.addField(fn); return fn; } }
protected void addTimeStamp(ClassNode node) { if (node.getDeclaredField(Verifier.__TIMESTAMP) == null) { // in case if verifier visited the call already FieldNode timeTagField = new FieldNode( Verifier.__TIMESTAMP, ACC_PUBLIC | ACC_STATIC | ACC_SYNTHETIC, ClassHelper.long_TYPE, //"", node, new ConstantExpression(System.currentTimeMillis())); // alternatively, FieldNode timeTagField = SourceUnit.createFieldNode("public static final long __timeStamp = " + System.currentTimeMillis() + "L"); timeTagField.setSynthetic(true); node.addField(timeTagField); timeTagField = new FieldNode( Verifier.__TIMESTAMP__ + String.valueOf(System.currentTimeMillis()), ACC_PUBLIC | ACC_STATIC | ACC_SYNTHETIC, ClassHelper.long_TYPE, //"", node, new ConstantExpression((long) 0)); // alternatively, FieldNode timeTagField = SourceUnit.createFieldNode("public static final long __timeStamp = " + System.currentTimeMillis() + "L"); timeTagField.setSynthetic(true); node.addField(timeTagField); } }
private Expression createFieldHelperCall(Expression exp, ClassNode weavedType, String propName) { String method = Traits.helperGetterName(new FieldNode(propName, 0, ClassHelper.OBJECT_TYPE, weavedType, null)); MethodCallExpression mce = new MethodCallExpression( createFieldHelperReceiver(), method, ArgumentListExpression.EMPTY_ARGUMENTS ); mce.setSourcePosition(exp); mce.setImplicitThis(false); return mce; }
static FieldNode createFieldNode(FieldStub field, AsmReferenceResolver resolver, DecompiledClassNode owner) { final ClassNode[] type = {resolver.resolveType(Type.getType(field.desc))}; if (field.signature != null) { new SignatureReader(field.signature).accept(new TypeSignatureParser(resolver) { @Override void finished(ClassNode result) { type[0] = applyErasure(result, type[0]); } }); } ConstantExpression value = field.value == null ? null : new ConstantExpression(field.value); return new FieldNode(field.fieldName, field.accessModifiers, type[0], owner, value); } }
private void setConstField(ConstantExpression constantExpression) { final Object n = constantExpression.getValue(); if (!(n instanceof Number)) return; if (n instanceof Integer || n instanceof Double) return; if (n instanceof Long && (0L == (Long) n || 1L == (Long) n)) return; // LCONST_0, LCONST_1 boolean isPrimitive = isPrimitiveType(constantExpression.getType()); FieldNode field = isPrimitive ? const2Prims.get(n) : const2Objects.get(n); if (field != null) { constantExpression.setConstantName(field.getName()); return; } String name; do { name = "$const$" + index++; } while (currentClass.getDeclaredField(name) != null); // TODO consider moving initcode to <clinit> and remaking field final field = new FieldNode(name, Opcodes.ACC_PRIVATE | Opcodes.ACC_STATIC | Opcodes.ACC_SYNTHETIC, constantExpression.getType(), currentClass, constantExpression); field.setSynthetic(true); missingFields.add(field); constantExpression.setConstantName(field.getName()); if (isPrimitive) { const2Prims.put(n, field); } else { const2Objects.put(n, field); } }
private static FieldNode createFieldCopy(ClassNode buildee, Parameter param) { Map<String,ClassNode> genericsSpec = createGenericsSpec(buildee); extractSuperClassGenerics(param.getType(), buildee, genericsSpec); ClassNode correctedParamType = correctToGenericsSpecRecurse(genericsSpec, param.getType()); return new FieldNode(param.getName(), ACC_PRIVATE, correctedParamType, buildee, param.getInitialExpression()); }
private static FieldNode createFieldCopy(ClassNode buildee, FieldNode fNode) { Map<String,ClassNode> genericsSpec = createGenericsSpec(fNode.getDeclaringClass()); extractSuperClassGenerics(fNode.getType(), buildee, genericsSpec); ClassNode correctedType = correctToGenericsSpecRecurse(genericsSpec, fNode.getType()); return new FieldNode(fNode.getName(), fNode.getModifiers(), correctedType, buildee, DEFAULT_INITIAL_VALUE); }
new BinaryExpression( new FieldExpression( new FieldNode("bar", ACC_PRIVATE, ClassHelper.STRING_TYPE, classNode, ConstantExpression.NULL)), Token.newSymbol("==", 0, 0), new ConstantExpression("abc"))); new BinaryExpression( new FieldExpression( new FieldNode("result", ACC_PRIVATE, ClassHelper.STRING_TYPE, classNode, ConstantExpression.NULL)), Token.newSymbol("=", 0, 0), new ConstantExpression("worked")));
FieldNode memoizedClosureField = new FieldNode(memoizedClosureFieldName, modifiers, newClass(ClassHelper.CLOSURE_TYPE), null, memoizeClosureCallExpression); ownerClassNode.addField(memoizedClosureField);