@Override public void visit(PrimitiveType n, Void arg) { out.println("PrimitiveType: " + (extended ? n : n.getType())); super.visit(n, arg); }
/** * Given a variable declaration of some sort, check it's name and type and * if it looks like any of the key type changes between unsafe and atomic * queues, perform the conversion to change it's type. * * @param node * @param name */ private static void processSpecialNodeTypes(NodeWithType<?, Type> node, String name) { Type type = node.getType(); if (node instanceof MethodDeclaration && ("newBufferAndOffset".equals(name) || "nextArrayOffset".equals(name))) { node.setType(PrimitiveType.intType()); } else if (PrimitiveType.longType().equals(type)) { switch(name) { case "offset": case "offsetInNew": case "offsetInOld": case "lookAheadElementOffset": node.setType(PrimitiveType.intType()); } } else if (isRefType(type, "LinkedQueueNode")) { node.setType(simpleParametricType("LinkedQueueAtomicNode", "E")); } else if (isRefArray(type, "E")) { node.setType(atomicRefArrayType((ArrayType) type)); } }
@Override public PrimitiveType doMerge(PrimitiveType first, PrimitiveType second) { PrimitiveType pt = new PrimitiveType(); pt.setAnnotations(mergeCollections(first.getAnnotations(),second.getAnnotations())); pt.setType(first.getType()); return first; }
@Override public void visit(ClassOrInterfaceDeclaration node, Void arg) { super.visit(node, arg); replaceParentClassesForAtomics(node); node.setName(translateQueueName(node.getNameAsString())); if (isCommentPresent(node, GEN_DIRECTIVE_CLASS_CONTAINS_ORDERED_FIELD_ACCESSORS)) { node.setComment(null); removeStaticFieldsAndInitialisers(node); patchAtomicFieldUpdaterAccessorMethods(node); } for (MethodDeclaration method : node.getMethods()) { if (isCommentPresent(method, GEN_DIRECTIVE_METHOD_IGNORE)) { method.remove(); } } if (!node.getMethodsByName("failFastOffer").isEmpty()) { MethodDeclaration deprecatedMethodRedirect = node.addMethod("weakOffer", Modifier.PUBLIC); patchMethodAsDepreciatedRedirector(deprecatedMethodRedirect, "failFastOffer", PrimitiveType.intType(), new Parameter(classType("E"), "e")); } node.setJavadocComment(formatMultilineJavadoc(0, "NOTE: This class was automatically generated by " + JavaParsingAtomicArrayQueueGenerator.class.getName(), "which can found in the jctools-build module. The original source file is " + sourceFileName + ".") + node.getJavadocComment().orElse(new JavadocComment("")).getContent()); }
@Override public Type visit(final PrimitiveType n, final Context ctx) { Primitive type = n.getType(); switch (type) { case Byte: return Byte.class; case Boolean: return boolean.class; case Char: return char.class; case Short: return short.class; case Int: return int.class; case Long: return long.class; case Float: return float.class; default: return double.class; } }
/** * Given a variable declaration of some sort, check it's name and type and * if it looks like any of the key type changes between unsafe and atomic * queues, perform the conversion to change it's type. * * @param node * @param name */ private static void processSpecialNodeTypes(NodeWithType<?, Type> node, String name) { Type type = node.getType(); if ("buffer".equals(name) && isRefArray(type, "E")) { node.setType(atomicRefArrayType((ArrayType) type)); } else if ("sBuffer".equals(name) && isLongArray(type)) { node.setType(atomicLongArrayType()); } else if (PrimitiveType.longType().equals(type)) { switch(name) { case "mask": case "offset": case "seqOffset": case "lookAheadSeqOffset": case "lookAheadElementOffset": node.setType(PrimitiveType.intType()); } } }
@Nullable Class<?> typeOf( Type type ) { if ( type instanceof ReferenceType ) { ReferenceType referenceType = ( ReferenceType ) type; if ( referenceType.getArrayCount() > 0 ) { return Array.class; } // unwrap the reference type and try again return typeOf( referenceType.getType() ); } if ( type instanceof PrimitiveType ) { String typeName = ( ( PrimitiveType ) type ).getType().name(); return primitiveType( typeName ); } else if ( type instanceof ClassOrInterfaceType ) try { return classForName( ( ( ClassOrInterfaceType ) type ).getName() ); } catch ( ClassNotFoundException e ) { // class not found, ignore } return null; }
return ResolvedPrimitiveType.byName(((com.github.javaparser.ast.type.PrimitiveType) type).getType().name()); } else if (type instanceof WildcardType) { WildcardType wildcardType = (WildcardType) type;
return ResolvedPrimitiveType.byName(((com.github.javaparser.ast.type.PrimitiveType) type).getType().name()); } else if (type instanceof WildcardType) { WildcardType wildcardType = (WildcardType) type;
return ResolvedPrimitiveType.byName(((com.github.javaparser.ast.type.PrimitiveType) type).getType().name()); } else if (type instanceof WildcardType) { WildcardType wildcardType = (WildcardType) type;
ResolvedType rawType = null; if (parameter.getType() instanceof com.github.javaparser.ast.type.PrimitiveType) { rawType = ResolvedPrimitiveType.byName(((com.github.javaparser.ast.type.PrimitiveType) parameter.getType()).getType().name()); } else { rawType = JavaParserFacade.get(typeSolver).convertToUsage(parameter.getType(), wrappedNode);
ResolvedType rawType = null; if (parameter.getType() instanceof com.github.javaparser.ast.type.PrimitiveType) { rawType = ResolvedPrimitiveType.byName(((com.github.javaparser.ast.type.PrimitiveType) parameter.getType()).getType().name()); } else { rawType = JavaParserFacade.get(typeSolver).convertToUsage(parameter.getType(), wrappedNode);
final ResolvedType rawType; if (parameter.getType() instanceof com.github.javaparser.ast.type.PrimitiveType) { rawType = ResolvedPrimitiveType.byName(((com.github.javaparser.ast.type.PrimitiveType) parameter.getType()).getType().name()); } else { rawType = JavaParserFacade.get(typeSolver).convertToUsage(parameter.getType(), wrappedNode);