< prev index next >

src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java

Print this page

 254         ListBuffer<Name> idents = new ListBuffer<>();
 255         for (List<JCTree> defs = classDef.defs; defs.nonEmpty(); defs=defs.tail) {
 256             if (defs.head.hasTag(VARDEF) &&
 257                 (((JCVariableDecl) defs.head).mods.flags & ENUM) != 0) {
 258                 JCVariableDecl var = (JCVariableDecl)defs.head;
 259                 idents.append(var.name);
 260             }
 261         }
 262         return idents.toList();
 263     }
 264 
 265     /** A hash table mapping class symbols to lists of free variables.
 266      *  accessed by them. Only free variables of the method immediately containing
 267      *  a class are associated with that class.
 268      */
 269     Map<ClassSymbol,List<VarSymbol>> freevarCache;
 270 
 271     /** A navigator class for collecting the free variables accessed
 272      *  from a local class.
 273      */
 274     class FreeVarCollector extends CaptureScanner {
 275 
 276         FreeVarCollector(JCTree ownerTree) {
 277             super(ownerTree);
 278         }
 279 
 280         void addFreeVars(ClassSymbol c) {
 281             List<VarSymbol> fvs = freevarCache.get(c);
 282             if (fvs != null) {
 283                 for (List<VarSymbol> l = fvs; l.nonEmpty(); l = l.tail) {
 284                     addFreeVar(l.head);
 285                 }
 286             }
 287         }
 288 
 289         /** If tree refers to a class instance creation expression
 290          *  add all free variables of the freshly created class.
 291          */
 292         public void visitNewClass(JCNewClass tree) {
 293             ClassSymbol c = (ClassSymbol)tree.constructor.owner;
 294             addFreeVars(c);
 295             super.visitNewClass(tree);
 296         }
 297 
 298         /** If tree refers to a superclass constructor call,
 299          *  add all free variables of the superclass.
 300          */

 254         ListBuffer<Name> idents = new ListBuffer<>();
 255         for (List<JCTree> defs = classDef.defs; defs.nonEmpty(); defs=defs.tail) {
 256             if (defs.head.hasTag(VARDEF) &&
 257                 (((JCVariableDecl) defs.head).mods.flags & ENUM) != 0) {
 258                 JCVariableDecl var = (JCVariableDecl)defs.head;
 259                 idents.append(var.name);
 260             }
 261         }
 262         return idents.toList();
 263     }
 264 
 265     /** A hash table mapping class symbols to lists of free variables.
 266      *  accessed by them. Only free variables of the method immediately containing
 267      *  a class are associated with that class.
 268      */
 269     Map<ClassSymbol,List<VarSymbol>> freevarCache;
 270 
 271     /** A navigator class for collecting the free variables accessed
 272      *  from a local class.
 273      */
 274     public class FreeVarCollector extends CaptureScanner {
 275 
 276         protected FreeVarCollector(JCTree ownerTree) {
 277             super(ownerTree);
 278         }
 279 
 280         protected void addFreeVars(ClassSymbol c) {
 281             List<VarSymbol> fvs = freevarCache.get(c);
 282             if (fvs != null) {
 283                 for (List<VarSymbol> l = fvs; l.nonEmpty(); l = l.tail) {
 284                     addFreeVar(l.head);
 285                 }
 286             }
 287         }
 288 
 289         /** If tree refers to a class instance creation expression
 290          *  add all free variables of the freshly created class.
 291          */
 292         public void visitNewClass(JCNewClass tree) {
 293             ClassSymbol c = (ClassSymbol)tree.constructor.owner;
 294             addFreeVars(c);
 295             super.visitNewClass(tree);
 296         }
 297 
 298         /** If tree refers to a superclass constructor call,
 299          *  add all free variables of the superclass.
 300          */
< prev index next >