Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(66)

Side by Side Diff: pkg/compiler/lib/src/compiler.dart

Issue 1314973003: Add support for analyzing individual URIs. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Updated cf. comment Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « pkg/compiler/lib/src/apiimpl.dart ('k') | pkg/compiler/lib/src/diagnostics/source_span.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library dart2js.compiler_base; 5 library dart2js.compiler_base;
6 6
7 import 'dart:async' show 7 import 'dart:async' show
8 EventSink, 8 EventSink,
9 Future; 9 Future;
10 10
(...skipping 1028 matching lines...) Expand 10 before | Expand all | Expand 10 after
1039 } 1039 }
1040 if (errorElement != null && 1040 if (errorElement != null &&
1041 errorElement.isSynthesized && 1041 errorElement.isSynthesized &&
1042 !mainApp.isSynthesized) { 1042 !mainApp.isSynthesized) {
1043 reportWarning( 1043 reportWarning(
1044 errorElement, errorElement.messageKind, 1044 errorElement, errorElement.messageKind,
1045 errorElement.messageArguments); 1045 errorElement.messageArguments);
1046 } 1046 }
1047 } 1047 }
1048 1048
1049 /// Analyze all member of the library in [libraryUri].
1050 ///
1051 /// If [skipLibraryWithPartOfTag] is `true`, member analysis is skipped if the
1052 /// library has a `part of` tag, assuming it is a part and not a library.
1053 ///
1054 /// This operation assumes an unclosed resolution queue and is only supported
1055 /// when the '--analyze-main' option is used.
1056 Future<LibraryElement> analyzeUri(
1057 Uri libraryUri,
1058 {bool skipLibraryWithPartOfTag: true}) {
1059 assert(analyzeMain);
1060 log('Analyzing $libraryUri ($buildId)');
1061 return libraryLoader.loadLibrary(libraryUri).then((LibraryElement library) {
1062 var compilationUnit = library.compilationUnit;
1063 if (skipLibraryWithPartOfTag && compilationUnit.partTag != null) {
1064 return null;
1065 }
1066 fullyEnqueueLibrary(library, enqueuer.resolution);
1067 emptyQueue(enqueuer.resolution);
1068 enqueuer.resolution.logSummary(log);
1069 return library;
1070 });
1071 }
1072
1049 /// Performs the compilation when all libraries have been loaded. 1073 /// Performs the compilation when all libraries have been loaded.
1050 void compileLoadedLibraries() { 1074 void compileLoadedLibraries() {
1051 computeMain(); 1075 computeMain();
1052 1076
1053 mirrorUsageAnalyzerTask.analyzeUsage(mainApp); 1077 mirrorUsageAnalyzerTask.analyzeUsage(mainApp);
1054 1078
1055 // In order to see if a library is deferred, we must compute the 1079 // In order to see if a library is deferred, we must compute the
1056 // compile-time constants that are metadata. This means adding 1080 // compile-time constants that are metadata. This means adding
1057 // something to the resolution queue. So we cannot wait with 1081 // something to the resolution queue. So we cannot wait with
1058 // this until after the resolution queue is processed. 1082 // this until after the resolution queue is processed.
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
1176 void resolveLibraryMetadata() { 1200 void resolveLibraryMetadata() {
1177 for (LibraryElement library in libraryLoader.libraries) { 1201 for (LibraryElement library in libraryLoader.libraries) {
1178 if (library.metadata != null) { 1202 if (library.metadata != null) {
1179 for (MetadataAnnotation metadata in library.metadata) { 1203 for (MetadataAnnotation metadata in library.metadata) {
1180 metadata.ensureResolved(this); 1204 metadata.ensureResolved(this);
1181 } 1205 }
1182 } 1206 }
1183 } 1207 }
1184 } 1208 }
1185 1209
1210 /**
1211 * Empty the [world] queue.
1212 */
1213 void emptyQueue(Enqueuer world) {
1214 world.forEach((WorkItem work) {
1215 withCurrentElement(work.element, () {
1216 world.applyImpact(work.element, work.run(this, world));
1217 });
1218 });
1219 }
1220
1186 void processQueue(Enqueuer world, Element main) { 1221 void processQueue(Enqueuer world, Element main) {
1187 world.nativeEnqueuer.processNativeClasses(libraryLoader.libraries); 1222 world.nativeEnqueuer.processNativeClasses(libraryLoader.libraries);
1188 if (main != null && !main.isErroneous) { 1223 if (main != null && !main.isErroneous) {
1189 FunctionElement mainMethod = main; 1224 FunctionElement mainMethod = main;
1190 mainMethod.computeType(this); 1225 mainMethod.computeType(this);
1191 if (mainMethod.functionSignature.parameterCount != 0) { 1226 if (mainMethod.functionSignature.parameterCount != 0) {
1192 // The first argument could be a list of strings. 1227 // The first argument could be a list of strings.
1193 backend.listImplementation.ensureResolved(this); 1228 backend.listImplementation.ensureResolved(this);
1194 world.registerInstantiatedType( 1229 world.registerInstantiatedType(
1195 backend.listImplementation.rawType, globalDependencies); 1230 backend.listImplementation.rawType, globalDependencies);
1196 backend.stringImplementation.ensureResolved(this); 1231 backend.stringImplementation.ensureResolved(this);
1197 world.registerInstantiatedType( 1232 world.registerInstantiatedType(
1198 backend.stringImplementation.rawType, globalDependencies); 1233 backend.stringImplementation.rawType, globalDependencies);
1199 1234
1200 backend.registerMainHasArguments(world); 1235 backend.registerMainHasArguments(world);
1201 } 1236 }
1202 world.addToWorkList(main); 1237 world.addToWorkList(main);
1203 } 1238 }
1204 if (verbose) { 1239 if (verbose) {
1205 progress.reset(); 1240 progress.reset();
1206 } 1241 }
1207 world.forEach((WorkItem work) { 1242 emptyQueue(world);
1208 withCurrentElement(work.element, () {
1209 world.applyImpact(work.element, work.run(this, world));
1210 });
1211 });
1212 world.queueIsClosed = true; 1243 world.queueIsClosed = true;
1213 assert(compilationFailed || world.checkNoEnqueuedInvokedInstanceMethods()); 1244 assert(compilationFailed || world.checkNoEnqueuedInvokedInstanceMethods());
1214 } 1245 }
1215 1246
1216 /** 1247 /**
1217 * Perform various checks of the queues. This includes checking that 1248 * Perform various checks of the queues. This includes checking that
1218 * the queues are empty (nothing was added after we stopped 1249 * the queues are empty (nothing was added after we stopped
1219 * processing the queues). Also compute the number of methods that 1250 * processing the queues). Also compute the number of methods that
1220 * were resolved, but not compiled (aka excess resolution). 1251 * were resolved, but not compiled (aka excess resolution).
1221 */ 1252 */
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
1388 SourceSpan spanFromTokens(Token begin, Token end, [Uri uri]) { 1419 SourceSpan spanFromTokens(Token begin, Token end, [Uri uri]) {
1389 if (begin == null || end == null) { 1420 if (begin == null || end == null) {
1390 // TODO(ahe): We can almost always do better. Often it is only 1421 // TODO(ahe): We can almost always do better. Often it is only
1391 // end that is null. Otherwise, we probably know the current 1422 // end that is null. Otherwise, we probably know the current
1392 // URI. 1423 // URI.
1393 throw 'Cannot find tokens to produce error message.'; 1424 throw 'Cannot find tokens to produce error message.';
1394 } 1425 }
1395 if (uri == null && currentElement != null) { 1426 if (uri == null && currentElement != null) {
1396 uri = currentElement.compilationUnit.script.resourceUri; 1427 uri = currentElement.compilationUnit.script.resourceUri;
1397 } 1428 }
1398 return SourceSpan.withCharacterOffsets(begin, end, 1429 return new SourceSpan.fromTokens(uri, begin, end);
1399 (beginOffset, endOffset) => new SourceSpan(uri, beginOffset, endOffset));
1400 } 1430 }
1401 1431
1402 SourceSpan spanFromNode(Node node) { 1432 SourceSpan spanFromNode(Node node) {
1403 return spanFromTokens(node.getBeginToken(), node.getEndToken()); 1433 return spanFromTokens(node.getBeginToken(), node.getEndToken());
1404 } 1434 }
1405 1435
1406 SourceSpan spanFromElement(Element element) { 1436 SourceSpan spanFromElement(Element element) {
1407 if (element != null && element.sourcePosition != null) { 1437 if (element != null && element.sourcePosition != null) {
1408 return element.sourcePosition; 1438 return element.sourcePosition;
1409 } 1439 }
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
1760 1790
1761 @override 1791 @override
1762 InterfaceType streamType([DartType elementType]) { 1792 InterfaceType streamType([DartType elementType]) {
1763 InterfaceType type = streamClass.computeType(compiler); 1793 InterfaceType type = streamClass.computeType(compiler);
1764 if (elementType == null) { 1794 if (elementType == null) {
1765 return streamClass.rawType; 1795 return streamClass.rawType;
1766 } 1796 }
1767 return type.createInstantiation([elementType]); 1797 return type.createInstantiation([elementType]);
1768 } 1798 }
1769 } 1799 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/apiimpl.dart ('k') | pkg/compiler/lib/src/diagnostics/source_span.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698