Chromium Code Reviews| 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 75a1eaacbc5fbe8e619089f933edfa3dd9f52158..7ba5216161c1647b0d23bf00f10ef4d4c013d984 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, |
| @@ -634,33 +638,64 @@ 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) { |
| + if (analyzeOnly) { |
| + log('analyzing $uri ($BUILD_ID)'); |
| + } else { |
| + 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 (mainApp != null) { |
| + main = mainApp.find(MAIN); |
| + if (main == null) { |
| + if (!analyzeOnly) { |
| + // Allow analyze only of libraries with no main. |
| + reportFatalError('Could not find $MAIN', mainApp); |
| + } else if (!analyzeAll) { |
| + reportFatalError( |
| + "Could not find $MAIN. " |
| + "No source will be analyzed. " |
| + "Use '--analyze-all' to analyze all code in the library.", |
| + mainApp); |
|
Johnni Winther
2013/01/24 10:06:15
This will allow us to analyze dart:core from the c
|
| + } |
| + } 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); |
| + }); |
| + } |
| } |
| log('Resolving...'); |
| phase = PHASE_RESOLVING; |
| - if (analyzeAll) libraries.forEach((_, lib) => fullyEnqueueLibrary(lib)); |
| + if (analyzeAll) { |
| + 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); |
| @@ -700,6 +735,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); |
| } |
| @@ -707,7 +745,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)); |