< prev index next >

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

Print this page

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

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