26 package com.sun.tools.javac.comp; |
26 package com.sun.tools.javac.comp; |
27 |
27 |
28 import java.util.*; |
28 import java.util.*; |
29 |
29 |
30 import com.sun.tools.javac.code.*; |
30 import com.sun.tools.javac.code.*; |
|
31 import com.sun.tools.javac.code.Kinds.KindSelector; |
31 import com.sun.tools.javac.code.Scope.WriteableScope; |
32 import com.sun.tools.javac.code.Scope.WriteableScope; |
32 import com.sun.tools.javac.jvm.*; |
33 import com.sun.tools.javac.jvm.*; |
33 import com.sun.tools.javac.main.Option.PkgInfo; |
34 import com.sun.tools.javac.main.Option.PkgInfo; |
34 import com.sun.tools.javac.tree.*; |
35 import com.sun.tools.javac.tree.*; |
35 import com.sun.tools.javac.util.*; |
36 import com.sun.tools.javac.util.*; |
43 import com.sun.tools.javac.jvm.Target; |
44 import com.sun.tools.javac.jvm.Target; |
44 import com.sun.tools.javac.tree.EndPosTable; |
45 import com.sun.tools.javac.tree.EndPosTable; |
45 |
46 |
46 import static com.sun.tools.javac.code.Flags.*; |
47 import static com.sun.tools.javac.code.Flags.*; |
47 import static com.sun.tools.javac.code.Flags.BLOCK; |
48 import static com.sun.tools.javac.code.Flags.BLOCK; |
48 import static com.sun.tools.javac.code.Kinds.*; |
|
49 import static com.sun.tools.javac.code.Scope.LookupKind.NON_RECURSIVE; |
49 import static com.sun.tools.javac.code.Scope.LookupKind.NON_RECURSIVE; |
50 import static com.sun.tools.javac.code.TypeTag.*; |
50 import static com.sun.tools.javac.code.TypeTag.*; |
|
51 import static com.sun.tools.javac.code.Kinds.Kind.*; |
51 import static com.sun.tools.javac.jvm.ByteCodes.*; |
52 import static com.sun.tools.javac.jvm.ByteCodes.*; |
52 import static com.sun.tools.javac.tree.JCTree.Tag.*; |
53 import static com.sun.tools.javac.tree.JCTree.Tag.*; |
53 |
54 |
54 /** This pass translates away some syntactic sugar: inner classes, |
55 /** This pass translates away some syntactic sugar: inner classes, |
55 * class literals, assertions, foreach loops, etc. |
56 * class literals, assertions, foreach loops, etc. |
356 ClassSymbol ownerToCopyFreeVarsFrom(ClassSymbol c) { |
357 ClassSymbol ownerToCopyFreeVarsFrom(ClassSymbol c) { |
357 if (!c.isLocal()) { |
358 if (!c.isLocal()) { |
358 return null; |
359 return null; |
359 } |
360 } |
360 Symbol currentOwner = c.owner; |
361 Symbol currentOwner = c.owner; |
361 while ((currentOwner.owner.kind & TYP) != 0 && currentOwner.isLocal()) { |
362 while (currentOwner.owner.kind.matches(KindSelector.TYP) && currentOwner.isLocal()) { |
362 currentOwner = currentOwner.owner; |
363 currentOwner = currentOwner.owner; |
363 } |
364 } |
364 if ((currentOwner.owner.kind & (VAR | MTH)) != 0 && c.isSubClass(currentOwner, types)) { |
365 if (currentOwner.owner.kind.matches(KindSelector.VAL_MTH) && c.isSubClass(currentOwner, types)) { |
365 return (ClassSymbol)currentOwner; |
366 return (ClassSymbol)currentOwner; |
366 } |
367 } |
367 return null; |
368 return null; |
368 } |
369 } |
369 |
370 |
374 List<VarSymbol> freevars(ClassSymbol c) { |
375 List<VarSymbol> freevars(ClassSymbol c) { |
375 List<VarSymbol> fvs = freevarCache.get(c); |
376 List<VarSymbol> fvs = freevarCache.get(c); |
376 if (fvs != null) { |
377 if (fvs != null) { |
377 return fvs; |
378 return fvs; |
378 } |
379 } |
379 if ((c.owner.kind & (VAR | MTH)) != 0) { |
380 if (c.owner.kind.matches(KindSelector.VAL_MTH)) { |
380 FreeVarCollector collector = new FreeVarCollector(c); |
381 FreeVarCollector collector = new FreeVarCollector(c); |
381 collector.scan(classDef(c)); |
382 collector.scan(classDef(c)); |
382 fvs = collector.fvs; |
383 fvs = collector.fvs; |
383 freevarCache.put(c, fvs); |
384 freevarCache.put(c, fvs); |
384 return fvs; |
385 return fvs; |
2088 case DOUBLE: case BOOLEAN: case VOID: |
2089 case DOUBLE: case BOOLEAN: case VOID: |
2089 // replace with <BoxedClass>.TYPE |
2090 // replace with <BoxedClass>.TYPE |
2090 ClassSymbol c = types.boxedClass(type); |
2091 ClassSymbol c = types.boxedClass(type); |
2091 Symbol typeSym = |
2092 Symbol typeSym = |
2092 rs.accessBase( |
2093 rs.accessBase( |
2093 rs.findIdentInType(attrEnv, c.type, names.TYPE, VAR), |
2094 rs.findIdentInType(attrEnv, c.type, names.TYPE, KindSelector.VAR), |
2094 pos, c.type, names.TYPE, true); |
2095 pos, c.type, names.TYPE, true); |
2095 if (typeSym.kind == VAR) |
2096 if (typeSym.kind == VAR) |
2096 ((VarSymbol)typeSym).getConstValue(); // ensure initializer is evaluated |
2097 ((VarSymbol)typeSym).getConstValue(); // ensure initializer is evaluated |
2097 return make.QualIdent(typeSym); |
2098 return make.QualIdent(typeSym); |
2098 case CLASS: case ARRAY: |
2099 case CLASS: case ARRAY: |