1617 }
1618 @Override
1619 public void visitRecordPattern(JCRecordPattern that) {
1620 hasPatterns = true;
1621 super.visitRecordPattern(that);
1622 }
1623 @Override
1624 public void visitSwitch(JCSwitch tree) {
1625 hasPatterns |= tree.patternSwitch;
1626 super.visitSwitch(tree);
1627 }
1628 @Override
1629 public void visitSwitchExpression(JCSwitchExpression tree) {
1630 hasPatterns |= tree.patternSwitch;
1631 super.visitSwitchExpression(tree);
1632 }
1633 }
1634 ScanNested scanner = new ScanNested();
1635 scanner.scan(env.tree);
1636 for (Env<AttrContext> dep: scanner.dependencies) {
1637 if (!compileStates.isDone(dep, CompileState.WARN))
1638 desugaredEnvs.put(dep, desugar(warn(flow(attribute(dep)))));
1639 }
1640
1641 //We need to check for error another time as more classes might
1642 //have been attributed and analyzed at this stage
1643 if (shouldStop(CompileState.TRANSTYPES))
1644 return;
1645
1646 if (verboseCompilePolicy)
1647 printNote("[desugar " + env.enclClass.sym + "]");
1648
1649 JavaFileObject prev = log.useSource(env.enclClass.sym.sourcefile != null ?
1650 env.enclClass.sym.sourcefile :
1651 env.toplevel.sourcefile);
1652 try {
1653 //save tree prior to rewriting
1654 JCTree untranslated = env.tree;
1655
1656 make.at(Position.FIRSTPOS);
1657 TreeMaker localMake = make.forToplevel(env.toplevel);
1658
1698 return;
1699 }
1700
1701 //translate out inner classes
1702 List<JCTree> cdefs = lower.translateTopLevelClass(env, env.tree, localMake);
1703 compileStates.put(env, CompileState.LOWER);
1704
1705 if (shouldStop(CompileState.LOWER))
1706 return;
1707
1708 if (scanner.hasLambdas) {
1709 if (shouldStop(CompileState.UNLAMBDA))
1710 return;
1711
1712 for (JCTree def : cdefs) {
1713 LambdaToMethod.instance(context).translateTopLevelClass(env, def, localMake);
1714 }
1715 compileStates.put(env, CompileState.UNLAMBDA);
1716 }
1717
1718 //generate code for each class
1719 for (List<JCTree> l = cdefs; l.nonEmpty(); l = l.tail) {
1720 JCClassDecl cdef = (JCClassDecl)l.head;
1721 results.add(new Pair<>(env, cdef));
1722 }
1723 }
1724 finally {
1725 log.useSource(prev);
1726 }
1727
1728 }
1729
1730 /** Generates the source or class file for a list of classes.
1731 * The decision to generate a source file or a class file is
1732 * based upon the compiler's options.
1733 * Generation stops if an error occurs while writing files.
1734 */
1735 public void generate(Queue<Pair<Env<AttrContext>, JCClassDecl>> queue) {
1736 generate(queue, null);
1737 }
|
1617 }
1618 @Override
1619 public void visitRecordPattern(JCRecordPattern that) {
1620 hasPatterns = true;
1621 super.visitRecordPattern(that);
1622 }
1623 @Override
1624 public void visitSwitch(JCSwitch tree) {
1625 hasPatterns |= tree.patternSwitch;
1626 super.visitSwitch(tree);
1627 }
1628 @Override
1629 public void visitSwitchExpression(JCSwitchExpression tree) {
1630 hasPatterns |= tree.patternSwitch;
1631 super.visitSwitchExpression(tree);
1632 }
1633 }
1634 ScanNested scanner = new ScanNested();
1635 scanner.scan(env.tree);
1636 for (Env<AttrContext> dep: scanner.dependencies) {
1637 if (!compileStates.isDone(dep, CompileState.WARN))
1638 desugaredEnvs.put(dep, desugar(warn(flow(attribute(dep)))));
1639 }
1640
1641 //We need to check for error another time as more classes might
1642 //have been attributed and analyzed at this stage
1643 if (shouldStop(CompileState.TRANSTYPES))
1644 return;
1645
1646 if (verboseCompilePolicy)
1647 printNote("[desugar " + env.enclClass.sym + "]");
1648
1649 JavaFileObject prev = log.useSource(env.enclClass.sym.sourcefile != null ?
1650 env.enclClass.sym.sourcefile :
1651 env.toplevel.sourcefile);
1652 try {
1653 //save tree prior to rewriting
1654 JCTree untranslated = env.tree;
1655
1656 make.at(Position.FIRSTPOS);
1657 TreeMaker localMake = make.forToplevel(env.toplevel);
1658
1698 return;
1699 }
1700
1701 //translate out inner classes
1702 List<JCTree> cdefs = lower.translateTopLevelClass(env, env.tree, localMake);
1703 compileStates.put(env, CompileState.LOWER);
1704
1705 if (shouldStop(CompileState.LOWER))
1706 return;
1707
1708 if (scanner.hasLambdas) {
1709 if (shouldStop(CompileState.UNLAMBDA))
1710 return;
1711
1712 for (JCTree def : cdefs) {
1713 LambdaToMethod.instance(context).translateTopLevelClass(env, def, localMake);
1714 }
1715 compileStates.put(env, CompileState.UNLAMBDA);
1716 }
1717
1718 if (shouldStop(CompileState.STRICT_FIELDS_PROXIES))
1719 return;
1720 for (JCTree def : cdefs) {
1721 LocalProxyVarsGen.instance(context).translateTopLevelClass(def, localMake);
1722 }
1723 compileStates.put(env, CompileState.STRICT_FIELDS_PROXIES);
1724
1725 //generate code for each class
1726 for (List<JCTree> l = cdefs; l.nonEmpty(); l = l.tail) {
1727 JCClassDecl cdef = (JCClassDecl)l.head;
1728 results.add(new Pair<>(env, cdef));
1729 }
1730 }
1731 finally {
1732 log.useSource(prev);
1733 }
1734
1735 }
1736
1737 /** Generates the source or class file for a list of classes.
1738 * The decision to generate a source file or a class file is
1739 * based upon the compiler's options.
1740 * Generation stops if an error occurs while writing files.
1741 */
1742 public void generate(Queue<Pair<Env<AttrContext>, JCClassDecl>> queue) {
1743 generate(queue, null);
1744 }
|