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

Unified Diff: sdk/lib/_internal/compiler/implementation/compiler.dart

Issue 11882017: Add --analyze-only flag to dart2js (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebased Created 7 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/apiimpl.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/compiler/implementation/compiler.dart
diff --git a/sdk/lib/_internal/compiler/implementation/compiler.dart b/sdk/lib/_internal/compiler/implementation/compiler.dart
index 8f8e077459cd3a9e837338147753d70b210cdc7f..fb37b030a52d3c16e338315557ff2f8f3e9a3933 100644
--- a/sdk/lib/_internal/compiler/implementation/compiler.dart
+++ b/sdk/lib/_internal/compiler/implementation/compiler.dart
@@ -193,6 +193,7 @@ abstract class Compiler implements DiagnosticListener {
*/
final int maxConcreteTypeSize;
final bool analyzeAll;
+ final bool analyzeOnly;
final bool enableNativeLiveTypeAnalysis;
final bool rejectDeprecatedFeatures;
final bool checkDeprecationInSdk;
@@ -204,6 +205,8 @@ abstract class Compiler implements DiagnosticListener {
bool disableInlining = false;
+ List<Uri> librariesToAnalyzeWhenRun;
+
final Tracer tracer;
CompilerTask measuredTask;
@@ -324,6 +327,7 @@ abstract class Compiler implements DiagnosticListener {
bool generateSourceMap: true,
bool disallowUnsafeEval: false,
this.analyzeAll: false,
+ this.analyzeOnly: false,
this.rejectDeprecatedFeatures: false,
this.checkDeprecationInSdk: false,
this.preserveComments: false,
@@ -633,33 +637,49 @@ abstract class Compiler implements DiagnosticListener {
}
void runCompiler(Uri uri) {
- log('compiling $uri ($BUILD_ID)');
+ assert(uri != null || analyzeOnly);
scanBuiltinLibraries();
- mainApp = libraryLoader.loadLibrary(uri, null, uri);
+ if (librariesToAnalyzeWhenRun != null) {
+ for (Uri libraryUri in librariesToAnalyzeWhenRun) {
+ log('analyzing $libraryUri ($BUILD_ID)');
+ libraryLoader.loadLibrary(libraryUri, null, libraryUri);
+ }
+ }
+ if (uri != null) {
+ log('compiling $uri ($BUILD_ID)');
+ mainApp = libraryLoader.loadLibrary(uri, null, uri);
+ }
libraries.forEach((_, library) {
maybeEnableJSHelper(library);
maybeEnableIsolateHelper(library);
});
- final Element main = mainApp.find(MAIN);
- if (main == null) {
- reportFatalError('Could not find $MAIN', mainApp);
- } else {
- if (!main.isFunction()) reportFatalError('main is not a function', main);
- FunctionElement mainMethod = main;
- FunctionSignature parameters = mainMethod.computeSignature(this);
- parameters.forEachParameter((Element parameter) {
- reportFatalError('main cannot have parameters', parameter);
- });
+ Element main = null;
+ if (!analyzeOnly) {
ahe 2013/01/21 12:23:21 I think this should be: if (mainApp != null) {
+ main = mainApp.find(MAIN);
+ if (main == null) {
+ reportFatalError('Could not find $MAIN', mainApp);
+ } else {
+ if (!main.isFunction()) reportFatalError('main is not a function', main);
ahe 2013/01/21 12:23:21 Long line.
Johnni Winther 2013/01/22 16:06:55 Done.
+ FunctionElement mainMethod = main;
+ FunctionSignature parameters = mainMethod.computeSignature(this);
+ parameters.forEachParameter((Element parameter) {
+ reportFatalError('main cannot have parameters', parameter);
+ });
+ }
}
log('Resolving...');
phase = PHASE_RESOLVING;
- if (analyzeAll) libraries.forEach((_, lib) => fullyEnqueueLibrary(lib));
+ if (analyzeAll || analyzeOnly) {
ahe 2013/01/21 12:23:21 I don't think analyzeOnly should imply analyzeAll.
Johnni Winther 2013/01/22 16:06:55 Done.
+ libraries.forEach((_, lib) => fullyEnqueueLibrary(lib));
+ }
backend.enqueueHelpers(enqueuer.resolution);
processQueue(enqueuer.resolution, main);
enqueuer.resolution.logSummary(log);
if (compilationFailed) return;
+ if (analyzeOnly) return;
+ assert(main != null);
log('Inferring types...');
typesTask.onResolutionComplete(main);
@@ -699,6 +719,9 @@ abstract class Compiler implements DiagnosticListener {
ClassElement cls = element;
cls.ensureResolved(this);
cls.forEachLocalMember(enqueuer.resolution.addToWorkList);
+ } else if (element.isTypedef()) {
+ TypedefElement typdef = element;
+ typdef.computeType(this);
} else {
enqueuer.resolution.addToWorkList(element);
}
@@ -706,7 +729,9 @@ abstract class Compiler implements DiagnosticListener {
void processQueue(Enqueuer world, Element main) {
world.nativeEnqueuer.processNativeClasses(libraries.values);
- world.addToWorkList(main);
+ if (main != null) {
+ world.addToWorkList(main);
+ }
progress.reset();
world.forEach((WorkItem work) {
withCurrentElement(work.element, () => work.run(this, world));
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/apiimpl.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698