Exemplo n.º 1
0
 public JCTree visitCompilationUnit(CompilationUnitTree node, P p) {
   JCCompilationUnit t = (JCCompilationUnit) node;
   List<JCAnnotation> packageAnnotations = copy(t.packageAnnotations, p);
   JCExpression pid = copy(t.pid, p);
   List<JCTree> defs = copy(t.defs, p);
   return M.at(t.pos).TopLevel(packageAnnotations, pid, defs);
 }
Exemplo n.º 2
0
 public JCTree visitNewArray(NewArrayTree node, P p) {
   JCNewArray t = (JCNewArray) node;
   JCExpression elemtype = copy(t.elemtype, p);
   List<JCExpression> dims = copy(t.dims, p);
   List<JCExpression> elems = copy(t.elems, p);
   return M.at(t.pos).NewArray(elemtype, dims, elems);
 }
Exemplo n.º 3
0
 public JCTree visitVariable(VariableTree node, P p) {
   JCVariableDecl t = (JCVariableDecl) node;
   JCModifiers mods = copy(t.mods, p);
   JCExpression vartype = copy(t.vartype, p);
   JCExpression init = copy(t.init, p);
   return M.at(t.pos).VarDef(mods, t.name, vartype, init);
 }
Exemplo n.º 4
0
 public JCTree visitMethodInvocation(MethodInvocationTree node, P p) {
   JCMethodInvocation t = (JCMethodInvocation) node;
   List<JCExpression> typeargs = copy(t.typeargs, p);
   JCExpression meth = copy(t.meth, p);
   List<JCExpression> args = copy(t.args, p);
   return M.at(t.pos).Apply(typeargs, meth, args);
 }
Exemplo n.º 5
0
 public JCTree visitEnhancedForLoop(EnhancedForLoopTree node, P p) {
   JCEnhancedForLoop t = (JCEnhancedForLoop) node;
   JCVariableDecl var = copy(t.var, p);
   JCExpression expr = copy(t.expr, p);
   JCStatement body = copy(t.body, p);
   return M.at(t.pos).ForeachLoop(var, expr, body);
 }
Exemplo n.º 6
0
 public JCTree visitIf(IfTree node, P p) {
   JCIf t = (JCIf) node;
   JCExpression cond = copy(t.cond, p);
   JCStatement thenpart = copy(t.thenpart, p);
   JCStatement elsepart = copy(t.elsepart, p);
   return M.at(t.pos).If(cond, thenpart, elsepart);
 }
Exemplo n.º 7
0
 public JCTree visitConditionalExpression(ConditionalExpressionTree node, P p) {
   JCConditional t = (JCConditional) node;
   JCExpression cond = copy(t.cond, p);
   JCExpression truepart = copy(t.truepart, p);
   JCExpression falsepart = copy(t.falsepart, p);
   return M.at(t.pos).Conditional(cond, truepart, falsepart);
 }
 /**
  * Process a single compound annotation, returning its Attribute. Used from MemberEnter for
  * attaching the attributes to the annotated symbol.
  */
 Attribute.Compound enterAnnotation(JCAnnotation a, Type expected, Env<AttrContext> env) {
   // The annotation might have had its type attributed (but not checked)
   // by attr.attribAnnotationTypes during MemberEnter, in which case we do not
   // need to do it again.
   Type at =
       (a.annotationType.type != null
           ? a.annotationType.type
           : attr.attribType(a.annotationType, env));
   a.type = chk.checkType(a.annotationType.pos(), at, expected);
   if (a.type.isErroneous())
     return new Attribute.Compound(a.type, List.<Pair<MethodSymbol, Attribute>>nil());
   if ((a.type.tsym.flags() & Flags.ANNOTATION) == 0) {
     log.error(a.annotationType.pos(), "not.annotation.type", a.type.toString());
     return new Attribute.Compound(a.type, List.<Pair<MethodSymbol, Attribute>>nil());
   }
   List<JCExpression> args = a.args;
   if (args.length() == 1 && args.head.getTag() != JCTree.ASSIGN) {
     // special case: elided "value=" assumed
     args.head = make.at(args.head.pos).Assign(make.Ident(names.value), args.head);
   }
   ListBuffer<Pair<MethodSymbol, Attribute>> buf = new ListBuffer<Pair<MethodSymbol, Attribute>>();
   for (List<JCExpression> tl = args; tl.nonEmpty(); tl = tl.tail) {
     JCExpression t = tl.head;
     if (t.getTag() != JCTree.ASSIGN) {
       log.error(t.pos(), "annotation.value.must.be.name.value");
       continue;
     }
     JCAssign assign = (JCAssign) t;
     if (assign.lhs.getTag() != JCTree.IDENT) {
       log.error(t.pos(), "annotation.value.must.be.name.value");
       continue;
     }
     JCIdent left = (JCIdent) assign.lhs;
     Symbol method =
         rs.resolveQualifiedMethod(left.pos(), env, a.type, left.name, List.<Type>nil(), null);
     left.sym = method;
     left.type = method.type;
     if (method.owner != a.type.tsym)
       log.error(left.pos(), "no.annotation.member", left.name, a.type);
     Type result = method.type.getReturnType();
     Attribute value = enterAttributeValue(result, assign.rhs, env);
     if (!method.type.isErroneous())
       buf.append(new Pair<MethodSymbol, Attribute>((MethodSymbol) method, value));
     t.type = result;
   }
   return new Attribute.Compound(a.type, buf.toList());
 }
Exemplo n.º 9
0
 public JCTree visitForLoop(ForLoopTree node, P p) {
   JCForLoop t = (JCForLoop) node;
   List<JCStatement> init = copy(t.init, p);
   JCExpression cond = copy(t.cond, p);
   List<JCExpressionStatement> step = copy(t.step, p);
   JCStatement body = copy(t.body, p);
   return M.at(t.pos).ForLoop(init, cond, step, body);
 }
Exemplo n.º 10
0
 public JCTree visitTry(TryTree node, P p) {
   JCTry t = (JCTry) node;
   List<JCTree> resources = copy(t.resources, p);
   JCBlock body = copy(t.body, p);
   List<JCCatch> catchers = copy(t.catchers, p);
   JCBlock finalizer = copy(t.finalizer, p);
   return M.at(t.pos).Try(resources, body, catchers, finalizer);
 }
Exemplo n.º 11
0
 public JCTree visitNewClass(NewClassTree node, P p) {
   JCNewClass t = (JCNewClass) node;
   JCExpression encl = copy(t.encl, p);
   List<JCExpression> typeargs = copy(t.typeargs, p);
   JCExpression clazz = copy(t.clazz, p);
   List<JCExpression> args = copy(t.args, p);
   JCClassDecl def = copy(t.def, p);
   return M.at(t.pos).NewClass(encl, typeargs, clazz, args, def);
 }
Exemplo n.º 12
0
 public JCTree visitClass(ClassTree node, P p) {
   JCClassDecl t = (JCClassDecl) node;
   JCModifiers mods = copy(t.mods, p);
   List<JCTypeParameter> typarams = copy(t.typarams, p);
   JCExpression extending = copy(t.extending, p);
   List<JCExpression> implementing = copy(t.implementing, p);
   List<JCTree> defs = copy(t.defs, p);
   return M.at(t.pos).ClassDef(mods, t.name, typarams, extending, implementing, defs);
 }
Exemplo n.º 13
0
  protected Enter(Context context) {
    context.put(enterKey, this);

    log = Log.instance(context);
    reader = ClassReader.instance(context);
    make = TreeMaker.instance(context);
    syms = Symtab.instance(context);
    chk = Check.instance(context);
    memberEnter = MemberEnter.instance(context);
    types = Types.instance(context);
    annotate = Annotate.instance(context);
    lint = Lint.instance(context);

    predefClassDef =
        make.ClassDef(make.Modifiers(PUBLIC), syms.predefClass.name, null, null, null, null);
    predefClassDef.sym = syms.predefClass;
    todo = Todo.instance(context);
    fileManager = context.get(JavaFileManager.class);
  }
Exemplo n.º 14
0
 public JCTree visitMethod(MethodTree node, P p) {
   JCMethodDecl t = (JCMethodDecl) node;
   JCModifiers mods = copy(t.mods, p);
   JCExpression restype = copy(t.restype, p);
   List<JCTypeParameter> typarams = copy(t.typarams, p);
   List<JCVariableDecl> params = copy(t.params, p);
   List<JCExpression> thrown = copy(t.thrown, p);
   JCBlock body = copy(t.body, p);
   JCExpression defaultValue = copy(t.defaultValue, p);
   return M.at(t.pos)
       .MethodDef(mods, t.name, restype, typarams, params, thrown, body, defaultValue);
 }
 protected Annotate(Context context) {
   context.put(annotateKey, this);
   attr = Attr.instance(context);
   make = TreeMaker.instance(context);
   log = Log.instance(context);
   syms = Symtab.instance(context);
   names = Names.instance(context);
   rs = Resolve.instance(context);
   types = Types.instance(context);
   cfolder = ConstFold.instance(context);
   chk = Check.instance(context);
 }
Exemplo n.º 16
0
 public JCTree visitOther(Tree node, P p) {
   JCTree tree = (JCTree) node;
   switch (tree.getTag()) {
     case JCTree.LETEXPR:
       {
         LetExpr t = (LetExpr) node;
         List<JCVariableDecl> defs = copy(t.defs, p);
         JCTree expr = copy(t.expr, p);
         return M.at(t.pos).LetExpr(defs, expr);
       }
     default:
       throw new AssertionError("unknown tree tag: " + tree.getTag());
   }
 }
Exemplo n.º 17
0
 public JCTree visitCompoundAssignment(CompoundAssignmentTree node, P p) {
   JCAssignOp t = (JCAssignOp) node;
   JCTree lhs = copy(t.lhs, p);
   JCTree rhs = copy(t.rhs, p);
   return M.at(t.pos).Assignop(t.getTag(), lhs, rhs);
 }
Exemplo n.º 18
0
 public JCTree visitAssignment(AssignmentTree node, P p) {
   JCAssign t = (JCAssign) node;
   JCExpression lhs = copy(t.lhs, p);
   JCExpression rhs = copy(t.rhs, p);
   return M.at(t.pos).Assign(lhs, rhs);
 }
Exemplo n.º 19
0
 public JCTree visitAssert(AssertTree node, P p) {
   JCAssert t = (JCAssert) node;
   JCExpression cond = copy(t.cond, p);
   JCExpression detail = copy(t.detail, p);
   return M.at(t.pos).Assert(cond, detail);
 }
Exemplo n.º 20
0
 public JCTree visitAnnotation(AnnotationTree node, P p) {
   JCAnnotation t = (JCAnnotation) node;
   JCTree annotationType = copy(t.annotationType, p);
   List<JCExpression> args = copy(t.args, p);
   return M.at(t.pos).Annotation(annotationType, args);
 }
Exemplo n.º 21
0
 public JCTree visitWildcard(WildcardTree node, P p) {
   JCWildcard t = (JCWildcard) node;
   TypeBoundKind kind = M.at(t.kind.pos).TypeBoundKind(t.kind.kind);
   JCTree inner = copy(t.inner, p);
   return M.at(t.pos).Wildcard(kind, inner);
 }
Exemplo n.º 22
0
 public JCTree visitArrayType(ArrayTypeTree node, P p) {
   JCArrayTypeTree t = (JCArrayTypeTree) node;
   JCExpression elemtype = copy(t.elemtype, p);
   return M.at(t.pos).TypeArray(elemtype);
 }
Exemplo n.º 23
0
 public JCTree visitUnary(UnaryTree node, P p) {
   JCUnary t = (JCUnary) node;
   JCExpression arg = copy(t.arg, p);
   return M.at(t.pos).Unary(t.getTag(), arg);
 }
Exemplo n.º 24
0
 public JCTree visitInstanceOf(InstanceOfTree node, P p) {
   JCInstanceOf t = (JCInstanceOf) node;
   JCExpression expr = copy(t.expr, p);
   JCTree clazz = copy(t.clazz, p);
   return M.at(t.pos).TypeTest(expr, clazz);
 }
Exemplo n.º 25
0
 public JCTree visitTypeParameter(TypeParameterTree node, P p) {
   JCTypeParameter t = (JCTypeParameter) node;
   List<JCExpression> bounds = copy(t.bounds, p);
   return M.at(t.pos).TypeParameter(t.name, bounds);
 }
Exemplo n.º 26
0
 public JCTree visitPrimitiveType(PrimitiveTypeTree node, P p) {
   JCPrimitiveTypeTree t = (JCPrimitiveTypeTree) node;
   return M.at(t.pos).TypeIdent(t.typetag);
 }
Exemplo n.º 27
0
 public JCTree visitBinary(BinaryTree node, P p) {
   JCBinary t = (JCBinary) node;
   JCExpression lhs = copy(t.lhs, p);
   JCExpression rhs = copy(t.rhs, p);
   return M.at(t.pos).Binary(t.getTag(), lhs, rhs);
 }
Exemplo n.º 28
0
 public JCTree visitWhileLoop(WhileLoopTree node, P p) {
   JCWhileLoop t = (JCWhileLoop) node;
   JCStatement body = copy(t.body, p);
   JCExpression cond = copy(t.cond, p);
   return M.at(t.pos).WhileLoop(cond, body);
 }
Exemplo n.º 29
0
 public JCTree visitTypeCast(TypeCastTree node, P p) {
   JCTypeCast t = (JCTypeCast) node;
   JCTree clazz = copy(t.clazz, p);
   JCExpression expr = copy(t.expr, p);
   return M.at(t.pos).TypeCast(clazz, expr);
 }
Exemplo n.º 30
0
 public JCTree visitUnionType(UnionTypeTree node, P p) {
   JCTypeUnion t = (JCTypeUnion) node;
   List<JCExpression> components = copy(t.alternatives, p);
   return M.at(t.pos).TypeUnion(components);
 }