src/share/classes/com/sun/tools/javac/main/JavaCompiler.java

changeset 359
8227961c64d3
parent 310
7c154fdc3547
child 372
7dbb79875a63
equal deleted inserted replaced
358:62073a5becc5 359:8227961c64d3
1205 for (Env<AttrContext> env: envs) 1205 for (Env<AttrContext> env: envs)
1206 desugar(env, results); 1206 desugar(env, results);
1207 return stopIfError(CompileState.FLOW, results); 1207 return stopIfError(CompileState.FLOW, results);
1208 } 1208 }
1209 1209
1210 HashMap<Env<AttrContext>, Queue<Pair<Env<AttrContext>, JCClassDecl>>> desugaredEnvs =
1211 new HashMap<Env<AttrContext>, Queue<Pair<Env<AttrContext>, JCClassDecl>>>();
1212
1210 /** 1213 /**
1211 * Prepare attributed parse trees, in conjunction with their attribution contexts, 1214 * Prepare attributed parse trees, in conjunction with their attribution contexts,
1212 * for source or code generation. If the file was not listed on the command line, 1215 * for source or code generation. If the file was not listed on the command line,
1213 * the current implicitSourcePolicy is taken into account. 1216 * the current implicitSourcePolicy is taken into account.
1214 * The preparation stops as soon as an error is found. 1217 * The preparation stops as soon as an error is found.
1220 if (implicitSourcePolicy == ImplicitSourcePolicy.NONE 1223 if (implicitSourcePolicy == ImplicitSourcePolicy.NONE
1221 && !inputFiles.contains(env.toplevel.sourcefile)) { 1224 && !inputFiles.contains(env.toplevel.sourcefile)) {
1222 return; 1225 return;
1223 } 1226 }
1224 1227
1228 if (compileStates.isDone(env, CompileState.LOWER)) {
1229 results.addAll(desugaredEnvs.get(env));
1230 return;
1231 }
1232
1225 /** 1233 /**
1226 * As erasure (TransTypes) destroys information needed in flow analysis, 1234 * Ensure that superclasses of C are desugared before C itself. This is
1227 * including information in supertypes, we need to ensure that supertypes 1235 * required for two reasons: (i) as erasure (TransTypes) destroys
1228 * are processed through attribute and flow before subtypes are translated. 1236 * information needed in flow analysis and (ii) as some checks carried
1237 * out during lowering require that all synthetic fields/methods have
1238 * already been added to C and its superclasses.
1229 */ 1239 */
1230 class ScanNested extends TreeScanner { 1240 class ScanNested extends TreeScanner {
1231 Set<Env<AttrContext>> dependencies = new LinkedHashSet<Env<AttrContext>>(); 1241 Set<Env<AttrContext>> dependencies = new LinkedHashSet<Env<AttrContext>>();
1232 @Override 1242 @Override
1233 public void visitClassDef(JCClassDecl node) { 1243 public void visitClassDef(JCClassDecl node) {
1244 } 1254 }
1245 } 1255 }
1246 ScanNested scanner = new ScanNested(); 1256 ScanNested scanner = new ScanNested();
1247 scanner.scan(env.tree); 1257 scanner.scan(env.tree);
1248 for (Env<AttrContext> dep: scanner.dependencies) { 1258 for (Env<AttrContext> dep: scanner.dependencies) {
1249 if (!compileStates.isDone(dep, CompileState.FLOW)) 1259 if (!compileStates.isDone(dep, CompileState.FLOW))
1250 flow(attribute(dep)); 1260 desugaredEnvs.put(dep, desugar(flow(attribute(dep))));
1251 } 1261 }
1252 1262
1253 //We need to check for error another time as more classes might 1263 //We need to check for error another time as more classes might
1254 //have been attributed and analyzed at this stage 1264 //have been attributed and analyzed at this stage
1255 if (shouldStop(CompileState.TRANSTYPES)) 1265 if (shouldStop(CompileState.TRANSTYPES))
1296 1306
1297 if (shouldStop(CompileState.TRANSTYPES)) 1307 if (shouldStop(CompileState.TRANSTYPES))
1298 return; 1308 return;
1299 1309
1300 env.tree = transTypes.translateTopLevelClass(env.tree, localMake); 1310 env.tree = transTypes.translateTopLevelClass(env.tree, localMake);
1311 compileStates.put(env, CompileState.TRANSTYPES);
1301 1312
1302 if (shouldStop(CompileState.LOWER)) 1313 if (shouldStop(CompileState.LOWER))
1303 return; 1314 return;
1304 1315
1305 if (sourceOutput) { 1316 if (sourceOutput) {
1313 return; 1324 return;
1314 } 1325 }
1315 1326
1316 //translate out inner classes 1327 //translate out inner classes
1317 List<JCTree> cdefs = lower.translateTopLevelClass(env, env.tree, localMake); 1328 List<JCTree> cdefs = lower.translateTopLevelClass(env, env.tree, localMake);
1329 compileStates.put(env, CompileState.LOWER);
1318 1330
1319 if (shouldStop(CompileState.LOWER)) 1331 if (shouldStop(CompileState.LOWER))
1320 return; 1332 return;
1321 1333
1322 //generate code for each class 1334 //generate code for each class

mercurial