private static boolean isLongArray(Type in) { if (in instanceof ArrayType) { ArrayType aType = (ArrayType) in; return PrimitiveType.longType().equals(aType.getComponentType()); } return false; }
/** * 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()); } } }
/** * 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)); } }
if (PrimitiveType.longType().equals(variable.getType())) { n.getMembers().add(0, declareLongFieldUpdater(className, variableName)); } else {