< prev index next >

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

Print this page

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

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