@Override public Void visitExecutable(CodeExecutableElement e, Void p) { visitAnnotations(e, e.getAnnotationMirrors()); if (e.getReturnType() != null) { visitTypeReference(e, e.getReturnType()); } for (TypeMirror type : e.getThrownTypes()) { visitTypeReference(e, type); } return super.visitExecutable(e, p); }
executable = currentLocals.createMethod(modifiers(PUBLIC), returnType, methodName, varArgs, FRAME_VALUE); executable.getThrownTypes().clear(); executable.getThrownTypes().add(context.getDeclaredType(UnexpectedResultException.class));
private CodeTree wrapInAMethod(CodeTreeBuilder parent, SpecializationGroup group, FrameState frameState, String suffix, CodeTree codeTree) { CodeExecutableElement parentMethod = (CodeExecutableElement) parent.findMethod(); CodeTypeElement parentClass = (CodeTypeElement) parentMethod.getEnclosingElement(); String name = parentMethod.getSimpleName().toString() + "_" + suffix + (boxingSplitIndex++); CodeExecutableElement method = parentClass.add( frameState.createMethod(modifiers(Modifier.PRIVATE), parentMethod.getReturnType(), name, FRAME_VALUE, STATE_VALUE)); CodeTreeBuilder builder = method.createBuilder(); builder.tree(codeTree); method.getThrownTypes().addAll(parentMethod.getThrownTypes()); addExplodeLoop(builder, group); CodeTreeBuilder parentBuilder = parent.create(); parentBuilder.startReturn(); parentBuilder.startCall(method.getSimpleName().toString()); frameState.addReferencesTo(parentBuilder, FRAME_VALUE, STATE_VALUE); parentBuilder.end(); parentBuilder.end(); return parentBuilder.build(); }
@Override public Void visitExecutable(CodeExecutableElement e, Void p) { visitAnnotations(e, e.getAnnotationMirrors()); if (e.getReturnType() != null) { visitTypeReference(e, e.getReturnType()); } for (TypeMirror type : e.getThrownTypes()) { visitTypeReference(e, type); } return super.visitExecutable(e, p); }
executable = frameState.createMethod(modifiers(PUBLIC), returnType, methodName, FRAME_VALUE); executable.getThrownTypes().clear(); executable.getThrownTypes().add(context.getDeclaredType(UnexpectedResultException.class));
private CodeExecutableElement createExecuteChildMethod(NodeExecutionData execution, TypeMirror targetType) { if (!usedExecuteChildMethods.contains(execution)) { return null; } LocalContext locals = LocalContext.load(this, createSpecializationNodeSignature(0), Integer.MAX_VALUE); CodeExecutableElement method = locals.createMethod(modifiers(PROTECTED, FINAL), targetType, executeChildMethodName(execution, targetType), Integer.MAX_VALUE, FRAME_VALUE); if (hasChildUnexpectedResult(execution, targetType)) { method.getThrownTypes().add(getType(UnexpectedResultException.class)); } CodeVariableElement implicitProfile = createImplicitProfileParameter(execution, targetType); if (implicitProfile != null) { method.addParameter(implicitProfile); } for (int i = 0; i < execution.getChild().getExecuteWith().size(); i++) { NodeExecutionData executeWith = node.getChildExecutions().get(i); LocalVariable var = locals.createValue(executeWith, genericType); method.addParameter(var.createParameter()); locals.setValue(executeWith, var); } CodeTreeBuilder builder = method.createBuilder(); CodeTree executeChild = createExecuteChild(execution, locals.createValue(execution, targetType), locals, true); if (executeChild.isSingleLine()) { builder.statement(executeChild); } else { builder.tree(executeChild); } return method; }
List<TypeMirror> throwables = e.getThrownTypes(); if (throwables.size() > 0) { write(" throws ");
builder.startStatement().startCall(FIELD_PROBE, METHOD_ON_RETURN_VALUE).string(frameParameterName).string(returnName).end().end(); builder.statement("break"); if (wrappedExecute.getThrownTypes().contains(context.getType(UnexpectedResultException.class))) { builder.end().startCatchBlock(context.getType(UnexpectedResultException.class), "e"); builder.startStatement().string(VAR_RETURN_CALLED).string(" = true").end(); } else { boolean objectReturnType = "java.lang.Object".equals(ElementUtils.getQualifiedName(returnTypeMirror)) && returnTypeMirror.getKind() != TypeKind.ARRAY; boolean throwsUnexpectedResult = wrappedExecute.getThrownTypes().contains(context.getType(UnexpectedResultException.class)); if (objectReturnType || !throwsUnexpectedResult) { builder.string("result != null").end();
List<TypeMirror> throwables = e.getThrownTypes(); if (throwables.size() > 0) { write(" throws ");
method.addParameter(new CodeVariableElement(context.getType(int.class), "state")); method.addParameter(new CodeVariableElement(context.getType(Object.class), LOCAL_VALUE)); method.getThrownTypes().add(context.getType(UnexpectedResultException.class)); List<TypeMirror> sourceTypes = typeSystem.lookupSourceTypes(type);
method.addParameter(new CodeVariableElement(context.getType(Class.class), "typeHint")); method.getThrownTypes().add(context.getType(UnexpectedResultException.class));
method.addParameter(new CodeVariableElement(context.getType(Object.class), "value")); if (expect) { method.getThrownTypes().add(context.getType(UnexpectedResultException.class));