public CodeTreeBuilder returnNull() { return startReturn().string("null").end(); }
public CodeTreeBuilder returnNull() { return startReturn().string("null").end(); }
public CodeTreeBuilder returnFalse() { return startReturn().string("false").end(); }
public CodeTreeBuilder returnTrue() { return startReturn().string("true").end(); }
public CodeTreeBuilder returnDefault() { ExecutableElement method = findMethod(); if (ElementUtils.isVoid(method.getReturnType())) { returnStatement(); } else { startReturn().defaultValue(method.getReturnType()).end(); } return this; }
public CodeTreeBuilder returnDefault() { ExecutableElement method = findMethod(); if (ElementUtils.isVoid(method.getReturnType())) { returnStatement(); } else { startReturn().defaultValue(method.getReturnType()).end(); } return this; }
private Element createCreatePolymorphic(Map<SpecializationData, CodeTypeElement> generatedSpecializationClasses) { SpecializationData polymorphic = node.getPolymorphicSpecialization(); CodeTypeElement generatedPolymorphic = generatedSpecializationClasses.get(polymorphic); if (generatedPolymorphic == null) { return null; } TypeMirror returnType = getType(SpecializationNode.class); CodeExecutableElement method = new CodeExecutableElement(modifiers(PROTECTED, FINAL), returnType, "createPolymorphic"); method.getAnnotationMirrors().add(new CodeAnnotationMirror(context.getDeclaredType(Override.class))); method.createBuilder().startReturn().tree(createCallCreateMethod(polymorphic, null, null)).end(); return method; }
private Element createGetCostMethod() { TypeMirror returnType = getType(NodeCost.class); CodeExecutableElement executable = new CodeExecutableElement(modifiers(PUBLIC), returnType, "getCost"); executable.getAnnotationMirrors().add(new CodeAnnotationMirror(context.getDeclaredType(Override.class))); CodeTreeBuilder builder = executable.createBuilder(); if (singleSpecializable) { builder.startReturn().staticReference(getType(NodeCost.class), "MONOMORPHIC").end().end(); } else { builder.startReturn().startCall(specializationStartFieldName(), "getNodeCost").end().end(); } return executable; }
private Element createGetSuppliedChildrenMethod() { ArrayType nodeArray = context.getEnvironment().getTypeUtils().getArrayType(getType(Node.class)); CodeExecutableElement method = new CodeExecutableElement(modifiers(PROTECTED, FINAL), nodeArray, "getSuppliedChildren"); method.getAnnotationMirrors().add(new CodeAnnotationMirror(context.getDeclaredType(Override.class))); CodeTreeBuilder builder = method.createBuilder(); builder.startReturn().tree(createGetSuppliedChildren()).end(); return method; }
private CodeExecutableElement createInsertAccessor(boolean array) { CodeTypeParameterElement tVar = new CodeTypeParameterElement("T", context.getType(Node.class)); TypeMirror type = tVar.createMirror(null, null); if (array) { type = new ArrayCodeTypeMirror(type); } CodeExecutableElement insertAccessor = new CodeExecutableElement(modifiers(FINAL), type, INSERT_ACCESSOR_NAME); insertAccessor.getParameters().add(new CodeVariableElement(type, "node")); insertAccessor.getTypeParameters().add(tVar); insertAccessor.createBuilder().startReturn().string("super.insert(node)").end(); return insertAccessor; }
private Element createMethodGetSpecializationNode() { TypeMirror returntype = getType(SpecializationNode.class); CodeExecutableElement method = new CodeExecutableElement(modifiers(PUBLIC), returntype, "getSpecializationNode"); method.createBuilder().startReturn().string(specializationStartFieldName()).end(); return method; }
private Element createGetNext(CodeTypeElement type) { if (!nextUsed) { return null; } CodeExecutableElement method = new CodeExecutableElement(modifiers(PROTECTED, FINAL), type.asType(), "getNext"); CodeTreeBuilder builder = method.createBuilder(); builder.startReturn().cast(type.asType(), CodeTreeBuilder.singleString("this.next")).end(); return method; }
private Element createDeepCopyMethod() { if (singleSpecializable) { return null; } CodeExecutableElement executable = new CodeExecutableElement(modifiers(PUBLIC), getType(Node.class), "deepCopy"); executable.getAnnotationMirrors().add(new CodeAnnotationMirror(context.getDeclaredType(Override.class))); CodeTreeBuilder builder = executable.createBuilder(); builder.startReturn().startStaticCall(getType(SpecializationNode.class), "updateRoot").string("super.deepCopy()").end().end(); return executable; }
private Element createUnsupported() { SpecializationData fallback = node.getGenericSpecialization(); if (fallback == null || optimizeFallback(fallback) || fallback.getMethod() == null) { return null; } LocalContext locals = LocalContext.load(this); CodeExecutableElement method = locals.createMethod(modifiers(PROTECTED, FINAL), genericType, "unsupported", varArgsThreshold, FRAME_VALUE); method.getAnnotationMirrors().add(new CodeAnnotationMirror(context.getDeclaredType(Override.class))); CodeTreeBuilder builder = method.createBuilder(); builder.startReturn(); builder.tree(callTemplateMethod(accessParent(null), fallback, locals)); builder.end(); return method; }
private CodeExecutableElement createCreateGetNodeClass() { TypeMirror returnValue = ElementUtils.getDeclaredType(ElementUtils.fromTypeMirror(context.getType(Class.class)), node.getNodeType()); CodeExecutableElement method = new CodeExecutableElement(modifiers(PUBLIC), returnValue, "getNodeClass"); method.createBuilder().startReturn().typeLiteral(node.getNodeType()).end(); return method; }
private CodeExecutableElement createIsTypeMethod(TypeMirror type) { if (typeSystem.getCheck(type) != null) { return null; } CodeExecutableElement method = new CodeExecutableElement(modifiers(PUBLIC, STATIC), context.getType(boolean.class), TypeSystemCodeGenerator.isTypeMethodName(typeSystem, type)); method.addParameter(new CodeVariableElement(context.getType(Object.class), LOCAL_VALUE)); CodeTreeBuilder body = method.createBuilder(); body.startReturn().tree(check(typeSystem, type, LOCAL_VALUE)).end(); return method; }
private CodeExecutableElement createIsTypeMethod(TypeMirror type) { if (typeSystem.getCheck(type) != null) { return null; } CodeExecutableElement method = new CodeExecutableElement(modifiers(PUBLIC, STATIC), context.getType(boolean.class), TypeSystemCodeGenerator.isTypeMethodName(typeSystem, type)); method.addParameter(new CodeVariableElement(context.getType(Object.class), LOCAL_VALUE)); CodeTreeBuilder body = method.createBuilder(); body.startReturn().tree(check(typeSystem, type, LOCAL_VALUE)).end(); return method; }
private CodeExecutableElement createCreateGetExecutionSignature() { TypeMirror returnValue = ElementUtils.getDeclaredType(ElementUtils.fromTypeMirror(context.getType(List.class))); CodeExecutableElement method = new CodeExecutableElement(modifiers(PUBLIC), returnValue, "getExecutionSignature"); CodeTreeBuilder builder = method.createBuilder(); builder.startReturn(); builder.startStaticCall(context.getType(Arrays.class), "asList"); for (NodeExecutionData execution : node.getChildExecutions()) { builder.typeLiteral(execution.getNodeType()); } builder.end(); builder.end(); return method; }
private CodeExecutableElement createAsTypeMethod(TypeMirror type) { if (typeSystem.getCast(type) != null) { return null; } CodeExecutableElement method = new CodeExecutableElement(modifiers(PUBLIC, STATIC), type, TypeSystemCodeGenerator.asTypeMethodName(typeSystem, type)); method.addParameter(new CodeVariableElement(context.getType(Object.class), LOCAL_VALUE)); CodeTreeBuilder body = method.createBuilder(); String assertMessage = typeName(typeSystem) + "." + asTypeMethodName(typeSystem, type) + ": " + ElementUtils.getSimpleName(type) + " expected"; body.startAssert().tree(check(typeSystem, type, LOCAL_VALUE)).string(" : ").doubleQuote(assertMessage).end(); body.startReturn().tree(cast(typeSystem, type, LOCAL_VALUE)).end(); return method; }
private CodeExecutableElement createAsTypeMethod(TypeMirror type) { if (typeSystem.getCast(type) != null) { return null; } CodeExecutableElement method = new CodeExecutableElement(modifiers(PUBLIC, STATIC), type, TypeSystemCodeGenerator.asTypeMethodName(typeSystem, type)); method.addParameter(new CodeVariableElement(context.getType(Object.class), LOCAL_VALUE)); CodeTreeBuilder body = method.createBuilder(); String assertMessage = typeName(typeSystem) + "." + asTypeMethodName(typeSystem, type) + ": " + ElementUtils.getSimpleName(type) + " expected"; body.startAssert().tree(check(typeSystem, type, LOCAL_VALUE)).string(" : ").doubleQuote(assertMessage).end(); body.startReturn().tree(cast(typeSystem, type, LOCAL_VALUE)).end(); return method; }