< prev index next >

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

Print this page
rev 51104 : imported patch switch


  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package com.sun.tools.javac.tree;
  27 
  28 import java.util.Iterator;
  29 

  30 import com.sun.source.tree.ModuleTree.ModuleKind;
  31 import com.sun.source.tree.Tree.Kind;
  32 import com.sun.tools.javac.code.*;
  33 import com.sun.tools.javac.code.Attribute.UnresolvedClass;
  34 import com.sun.tools.javac.code.Symbol.*;
  35 import com.sun.tools.javac.code.Type.*;
  36 import com.sun.tools.javac.util.*;
  37 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
  38 
  39 import com.sun.tools.javac.tree.JCTree.*;
  40 
  41 import static com.sun.tools.javac.code.Flags.*;
  42 import static com.sun.tools.javac.code.Kinds.Kind.*;
  43 import static com.sun.tools.javac.code.TypeTag.*;
  44 
  45 /** Factory class for trees.
  46  *
  47  *  <p><b>This is NOT part of any supported API.
  48  *  If you write code that depends on this, you do so at your own risk.
  49  *  This code and its internal interfaces are subject to change or


 256     }
 257 
 258     public JCEnhancedForLoop ForeachLoop(JCVariableDecl var, JCExpression expr, JCStatement body) {
 259         JCEnhancedForLoop tree = new JCEnhancedForLoop(var, expr, body);
 260         tree.pos = pos;
 261         return tree;
 262     }
 263 
 264     public JCLabeledStatement Labelled(Name label, JCStatement body) {
 265         JCLabeledStatement tree = new JCLabeledStatement(label, body);
 266         tree.pos = pos;
 267         return tree;
 268     }
 269 
 270     public JCSwitch Switch(JCExpression selector, List<JCCase> cases) {
 271         JCSwitch tree = new JCSwitch(selector, cases);
 272         tree.pos = pos;
 273         return tree;
 274     }
 275 
 276     public JCCase Case(JCExpression pat, List<JCStatement> stats) {
 277         JCCase tree = new JCCase(pat, stats);







 278         tree.pos = pos;
 279         return tree;
 280     }
 281 
 282     public JCSynchronized Synchronized(JCExpression lock, JCBlock body) {
 283         JCSynchronized tree = new JCSynchronized(lock, body);
 284         tree.pos = pos;
 285         return tree;
 286     }
 287 
 288     public JCTry Try(JCBlock body, List<JCCatch> catchers, JCBlock finalizer) {
 289         return Try(List.nil(), body, catchers, finalizer);
 290     }
 291 
 292     public JCTry Try(List<JCTree> resources,
 293                      JCBlock body,
 294                      List<JCCatch> catchers,
 295                      JCBlock finalizer) {
 296         JCTry tree = new JCTry(resources, body, catchers, finalizer);
 297         tree.pos = pos;


 308                                    JCExpression thenpart,
 309                                    JCExpression elsepart)
 310     {
 311         JCConditional tree = new JCConditional(cond, thenpart, elsepart);
 312         tree.pos = pos;
 313         return tree;
 314     }
 315 
 316     public JCIf If(JCExpression cond, JCStatement thenpart, JCStatement elsepart) {
 317         JCIf tree = new JCIf(cond, thenpart, elsepart);
 318         tree.pos = pos;
 319         return tree;
 320     }
 321 
 322     public JCExpressionStatement Exec(JCExpression expr) {
 323         JCExpressionStatement tree = new JCExpressionStatement(expr);
 324         tree.pos = pos;
 325         return tree;
 326     }
 327 
 328     public JCBreak Break(Name label) {
 329         JCBreak tree = new JCBreak(label, null);
 330         tree.pos = pos;
 331         return tree;
 332     }
 333 
 334     public JCContinue Continue(Name label) {
 335         JCContinue tree = new JCContinue(label, null);
 336         tree.pos = pos;
 337         return tree;
 338     }
 339 
 340     public JCReturn Return(JCExpression expr) {
 341         JCReturn tree = new JCReturn(expr);
 342         tree.pos = pos;
 343         return tree;
 344     }
 345 
 346     public JCThrow Throw(JCExpression expr) {
 347         JCThrow tree = new JCThrow(expr);
 348         tree.pos = pos;


 582         tree.pos = pos;
 583         return tree;
 584     }
 585 
 586     public JCAnnotatedType AnnotatedType(List<JCAnnotation> annotations, JCExpression underlyingType) {
 587         JCAnnotatedType tree = new JCAnnotatedType(annotations, underlyingType);
 588         tree.pos = pos;
 589         return tree;
 590     }
 591 
 592     public JCErroneous Erroneous() {
 593         return Erroneous(List.nil());
 594     }
 595 
 596     public JCErroneous Erroneous(List<? extends JCTree> errs) {
 597         JCErroneous tree = new JCErroneous(errs);
 598         tree.pos = pos;
 599         return tree;
 600     }
 601 
 602     public LetExpr LetExpr(List<JCVariableDecl> defs, JCExpression expr) {
 603         LetExpr tree = new LetExpr(defs, expr);
 604         tree.pos = pos;
 605         return tree;
 606     }
 607 
 608 /* ***************************************************************************
 609  * Derived building blocks.
 610  ****************************************************************************/
 611 
 612     public JCClassDecl AnonymousClassDef(JCModifiers mods,
 613                                          List<JCTree> defs)
 614     {
 615         return ClassDef(mods,
 616                         names.empty,
 617                         List.nil(),
 618                         null,
 619                         List.nil(),
 620                         defs);
 621     }
 622 




  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package com.sun.tools.javac.tree;
  27 
  28 import java.util.Iterator;
  29 
  30 import com.sun.source.tree.CaseTree.CaseKind;
  31 import com.sun.source.tree.ModuleTree.ModuleKind;
  32 import com.sun.source.tree.Tree.Kind;
  33 import com.sun.tools.javac.code.*;
  34 import com.sun.tools.javac.code.Attribute.UnresolvedClass;
  35 import com.sun.tools.javac.code.Symbol.*;
  36 import com.sun.tools.javac.code.Type.*;
  37 import com.sun.tools.javac.util.*;
  38 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
  39 
  40 import com.sun.tools.javac.tree.JCTree.*;
  41 
  42 import static com.sun.tools.javac.code.Flags.*;
  43 import static com.sun.tools.javac.code.Kinds.Kind.*;
  44 import static com.sun.tools.javac.code.TypeTag.*;
  45 
  46 /** Factory class for trees.
  47  *
  48  *  <p><b>This is NOT part of any supported API.
  49  *  If you write code that depends on this, you do so at your own risk.
  50  *  This code and its internal interfaces are subject to change or


 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;
 269     }
 270 
 271     public JCSwitch Switch(JCExpression selector, List<JCCase> cases) {
 272         JCSwitch tree = new JCSwitch(selector, cases);
 273         tree.pos = pos;
 274         return tree;
 275     }
 276 
 277     public JCCase Case(@SuppressWarnings("removal") CaseKind caseKind, List<JCExpression> pats,
 278                        List<JCStatement> stats, JCTree body) {
 279         JCCase tree = new JCCase(caseKind, pats, stats, body);
 280         tree.pos = pos;
 281         return tree;
 282     }
 283 
 284     public JCSwitchExpression SwitchExpression(JCExpression selector, List<JCCase> cases) {
 285         JCSwitchExpression tree = new JCSwitchExpression(selector, cases);
 286         tree.pos = pos;
 287         return tree;
 288     }
 289 
 290     public JCSynchronized Synchronized(JCExpression lock, JCBlock body) {
 291         JCSynchronized tree = new JCSynchronized(lock, body);
 292         tree.pos = pos;
 293         return tree;
 294     }
 295 
 296     public JCTry Try(JCBlock body, List<JCCatch> catchers, JCBlock finalizer) {
 297         return Try(List.nil(), body, catchers, finalizer);
 298     }
 299 
 300     public JCTry Try(List<JCTree> resources,
 301                      JCBlock body,
 302                      List<JCCatch> catchers,
 303                      JCBlock finalizer) {
 304         JCTry tree = new JCTry(resources, body, catchers, finalizer);
 305         tree.pos = pos;


 316                                    JCExpression thenpart,
 317                                    JCExpression elsepart)
 318     {
 319         JCConditional tree = new JCConditional(cond, thenpart, elsepart);
 320         tree.pos = pos;
 321         return tree;
 322     }
 323 
 324     public JCIf If(JCExpression cond, JCStatement thenpart, JCStatement elsepart) {
 325         JCIf tree = new JCIf(cond, thenpart, elsepart);
 326         tree.pos = pos;
 327         return tree;
 328     }
 329 
 330     public JCExpressionStatement Exec(JCExpression expr) {
 331         JCExpressionStatement tree = new JCExpressionStatement(expr);
 332         tree.pos = pos;
 333         return tree;
 334     }
 335 
 336     public JCBreak Break(JCExpression label) {
 337         JCBreak tree = new JCBreak(label, null);
 338         tree.pos = pos;
 339         return tree;
 340     }
 341 
 342     public JCContinue Continue(Name label) {
 343         JCContinue tree = new JCContinue(label, null);
 344         tree.pos = pos;
 345         return tree;
 346     }
 347 
 348     public JCReturn Return(JCExpression expr) {
 349         JCReturn tree = new JCReturn(expr);
 350         tree.pos = pos;
 351         return tree;
 352     }
 353 
 354     public JCThrow Throw(JCExpression expr) {
 355         JCThrow tree = new JCThrow(expr);
 356         tree.pos = pos;


 590         tree.pos = pos;
 591         return tree;
 592     }
 593 
 594     public JCAnnotatedType AnnotatedType(List<JCAnnotation> annotations, JCExpression underlyingType) {
 595         JCAnnotatedType tree = new JCAnnotatedType(annotations, underlyingType);
 596         tree.pos = pos;
 597         return tree;
 598     }
 599 
 600     public JCErroneous Erroneous() {
 601         return Erroneous(List.nil());
 602     }
 603 
 604     public JCErroneous Erroneous(List<? extends JCTree> errs) {
 605         JCErroneous tree = new JCErroneous(errs);
 606         tree.pos = pos;
 607         return tree;
 608     }
 609 
 610     public LetExpr LetExpr(List<JCStatement> defs, JCExpression expr) {
 611         LetExpr tree = new LetExpr(defs, expr);
 612         tree.pos = pos;
 613         return tree;
 614     }
 615 
 616 /* ***************************************************************************
 617  * Derived building blocks.
 618  ****************************************************************************/
 619 
 620     public JCClassDecl AnonymousClassDef(JCModifiers mods,
 621                                          List<JCTree> defs)
 622     {
 623         return ClassDef(mods,
 624                         names.empty,
 625                         List.nil(),
 626                         null,
 627                         List.nil(),
 628                         defs);
 629     }
 630 


< prev index next >