< prev index next >

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

Print this page

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

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