< prev index next >

src/jdk.compiler/share/classes/com/sun/tools/javac/main/JavaCompiler.java

Print this page

   1 /*
   2  * Copyright (c) 1999, 2023, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  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

1592 
1593             make.at(Position.FIRSTPOS);
1594             TreeMaker localMake = make.forToplevel(env.toplevel);
1595 
1596             if (env.tree.hasTag(JCTree.Tag.PACKAGEDEF) || env.tree.hasTag(JCTree.Tag.MODULEDEF)) {
1597                 if (!(sourceOutput)) {
1598                     if (shouldStop(CompileState.LOWER))
1599                         return;
1600                     List<JCTree> def = lower.translateTopLevelClass(env, env.tree, localMake);
1601                     if (def.head != null) {
1602                         Assert.check(def.tail.isEmpty());
1603                         results.add(new Pair<>(env, (JCClassDecl)def.head));
1604                     }
1605                 }
1606                 return;
1607             }
1608 
1609             if (shouldStop(CompileState.TRANSTYPES))
1610                 return;
1611 




1612             env.tree = transTypes.translateTopLevelClass(env.tree, localMake);
1613             compileStates.put(env, CompileState.TRANSTYPES);
1614 
1615             if (shouldStop(CompileState.TRANSPATTERNS))
1616                 return;
1617 
1618             if (scanner.hasPatterns) {
1619                 env.tree = TransPatterns.instance(context).translateTopLevelClass(env, env.tree, localMake);
1620             }
1621 
1622             compileStates.put(env, CompileState.TRANSPATTERNS);
1623 
1624             if (scanner.hasLambdas) {
1625                 if (shouldStop(CompileState.UNLAMBDA))
1626                     return;
1627 
1628                 env.tree = LambdaToMethod.instance(context).translateTopLevelClass(env, env.tree, localMake);
1629                 compileStates.put(env, CompileState.UNLAMBDA);
1630             }
1631 

   1 /*
   2  * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  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

1592 
1593             make.at(Position.FIRSTPOS);
1594             TreeMaker localMake = make.forToplevel(env.toplevel);
1595 
1596             if (env.tree.hasTag(JCTree.Tag.PACKAGEDEF) || env.tree.hasTag(JCTree.Tag.MODULEDEF)) {
1597                 if (!(sourceOutput)) {
1598                     if (shouldStop(CompileState.LOWER))
1599                         return;
1600                     List<JCTree> def = lower.translateTopLevelClass(env, env.tree, localMake);
1601                     if (def.head != null) {
1602                         Assert.check(def.tail.isEmpty());
1603                         results.add(new Pair<>(env, (JCClassDecl)def.head));
1604                     }
1605                 }
1606                 return;
1607             }
1608 
1609             if (shouldStop(CompileState.TRANSTYPES))
1610                 return;
1611 
1612             if (Feature.REFLECT_METHODS.allowedInSource(source)) {
1613                 env.tree = ReflectMethods.instance(context).translateTopLevelClass(env.tree, localMake);
1614             }
1615 
1616             env.tree = transTypes.translateTopLevelClass(env.tree, localMake);
1617             compileStates.put(env, CompileState.TRANSTYPES);
1618 
1619             if (shouldStop(CompileState.TRANSPATTERNS))
1620                 return;
1621 
1622             if (scanner.hasPatterns) {
1623                 env.tree = TransPatterns.instance(context).translateTopLevelClass(env, env.tree, localMake);
1624             }
1625 
1626             compileStates.put(env, CompileState.TRANSPATTERNS);
1627 
1628             if (scanner.hasLambdas) {
1629                 if (shouldStop(CompileState.UNLAMBDA))
1630                     return;
1631 
1632                 env.tree = LambdaToMethod.instance(context).translateTopLevelClass(env, env.tree, localMake);
1633                 compileStates.put(env, CompileState.UNLAMBDA);
1634             }
1635 
< prev index next >