< prev index next >

src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeMaker.java

Print this page




 229     }
 230 
 231     public JCBlock Block(long flags, List<JCStatement> stats) {
 232         JCBlock tree = new JCBlock(flags, stats);
 233         tree.pos = pos;
 234         return tree;
 235     }
 236 
 237     public JCDoWhileLoop DoLoop(JCStatement body, JCExpression cond) {
 238         JCDoWhileLoop tree = new JCDoWhileLoop(body, cond);
 239         tree.pos = pos;
 240         return tree;
 241     }
 242 
 243     public JCWhileLoop WhileLoop(JCExpression cond, JCStatement body) {
 244         JCWhileLoop tree = new JCWhileLoop(cond, body);
 245         tree.pos = pos;
 246         return tree;
 247     }
 248 






 249     public JCForLoop ForLoop(List<JCStatement> init,
 250                            JCExpression cond,
 251                            List<JCExpressionStatement> step,
 252                            JCStatement body)
 253     {
 254         JCForLoop tree = new JCForLoop(init, cond, step, body);
 255         tree.pos = pos;
 256         return tree;
 257     }
 258 
 259     public JCEnhancedForLoop ForeachLoop(JCVariableDecl var, JCExpression expr, JCStatement body) {
 260         JCEnhancedForLoop tree = new JCEnhancedForLoop(var, expr, body);
 261         tree.pos = pos;
 262         return tree;
 263     }
 264 
 265     public JCLabeledStatement Labelled(Name label, JCStatement body) {
 266         JCLabeledStatement tree = new JCLabeledStatement(label, body);
 267         tree.pos = pos;
 268         return tree;


 801                 Type outer = t.getEnclosingType();
 802                 JCExpression clazz = outer.hasTag(CLASS) && t.tsym.owner.kind == TYP
 803                         ? Select(Type(outer), t.tsym)
 804                         : QualIdent(t.tsym);
 805                 tp = t.getTypeArguments().isEmpty()
 806                         ? clazz
 807                         : TypeApply(clazz, Types(t.getTypeArguments()));
 808                 break;
 809             }
 810             }
 811             break;
 812         case ARRAY:
 813             tp = TypeArray(Type(types.elemtype(t)));
 814             break;
 815         case ERROR:
 816             tp = TypeIdent(ERROR);
 817             break;
 818         default:
 819             throw new AssertionError("unexpected type: " + t);
 820         }


 821         return tp.setType(t);
 822     }
 823 
 824     /** Create a list of trees representing given list of types.
 825      */
 826     public List<JCExpression> Types(List<Type> ts) {
 827         ListBuffer<JCExpression> lb = new ListBuffer<>();
 828         for (List<Type> l = ts; l.nonEmpty(); l = l.tail)
 829             lb.append(Type(l.head));
 830         return lb.toList();
 831     }
 832 
 833     /** Create a variable definition from a variable symbol and an initializer
 834      *  expression.
 835      */
 836     public JCVariableDecl VarDef(VarSymbol v, JCExpression init) {
 837         return (JCVariableDecl)
 838             new JCVariableDecl(
 839                 Modifiers(v.flags(), Annotations(v.getRawAttributes())),
 840                 v.name,




 229     }
 230 
 231     public JCBlock Block(long flags, List<JCStatement> stats) {
 232         JCBlock tree = new JCBlock(flags, stats);
 233         tree.pos = pos;
 234         return tree;
 235     }
 236 
 237     public JCDoWhileLoop DoLoop(JCStatement body, JCExpression cond) {
 238         JCDoWhileLoop tree = new JCDoWhileLoop(body, cond);
 239         tree.pos = pos;
 240         return tree;
 241     }
 242 
 243     public JCWhileLoop WhileLoop(JCExpression cond, JCStatement body) {
 244         JCWhileLoop tree = new JCWhileLoop(cond, body);
 245         tree.pos = pos;
 246         return tree;
 247     }
 248 
 249     public JCWithField WithField(JCExpression field, JCExpression value) {
 250         JCWithField tree = new JCWithField(field, value);
 251         tree.pos = pos;
 252         return tree;
 253     }
 254 
 255     public JCForLoop ForLoop(List<JCStatement> init,
 256                            JCExpression cond,
 257                            List<JCExpressionStatement> step,
 258                            JCStatement body)
 259     {
 260         JCForLoop tree = new JCForLoop(init, cond, step, body);
 261         tree.pos = pos;
 262         return tree;
 263     }
 264 
 265     public JCEnhancedForLoop ForeachLoop(JCVariableDecl var, JCExpression expr, JCStatement body) {
 266         JCEnhancedForLoop tree = new JCEnhancedForLoop(var, expr, body);
 267         tree.pos = pos;
 268         return tree;
 269     }
 270 
 271     public JCLabeledStatement Labelled(Name label, JCStatement body) {
 272         JCLabeledStatement tree = new JCLabeledStatement(label, body);
 273         tree.pos = pos;
 274         return tree;


 807                 Type outer = t.getEnclosingType();
 808                 JCExpression clazz = outer.hasTag(CLASS) && t.tsym.owner.kind == TYP
 809                         ? Select(Type(outer), t.tsym)
 810                         : QualIdent(t.tsym);
 811                 tp = t.getTypeArguments().isEmpty()
 812                         ? clazz
 813                         : TypeApply(clazz, Types(t.getTypeArguments()));
 814                 break;
 815             }
 816             }
 817             break;
 818         case ARRAY:
 819             tp = TypeArray(Type(types.elemtype(t)));
 820             break;
 821         case ERROR:
 822             tp = TypeIdent(ERROR);
 823             break;
 824         default:
 825             throw new AssertionError("unexpected type: " + t);
 826         }
 827         if (t.tsym.isProjectedNullable())
 828             tp.setQuestioned();
 829         return tp.setType(t);
 830     }
 831 
 832     /** Create a list of trees representing given list of types.
 833      */
 834     public List<JCExpression> Types(List<Type> ts) {
 835         ListBuffer<JCExpression> lb = new ListBuffer<>();
 836         for (List<Type> l = ts; l.nonEmpty(); l = l.tail)
 837             lb.append(Type(l.head));
 838         return lb.toList();
 839     }
 840 
 841     /** Create a variable definition from a variable symbol and an initializer
 842      *  expression.
 843      */
 844     public JCVariableDecl VarDef(VarSymbol v, JCExpression init) {
 845         return (JCVariableDecl)
 846             new JCVariableDecl(
 847                 Modifiers(v.flags(), Annotations(v.getRawAttributes())),
 848                 v.name,


< prev index next >