| OLD | NEW |
| 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 part of dart2js; | 5 part of dart2js; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * If true, print a warning for each method that was resolved, but not | 8 * If true, print a warning for each method that was resolved, but not |
| 9 * compiled. | 9 * compiled. |
| 10 */ | 10 */ |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 } | 295 } |
| 296 native.NativeEnqueuer nativeCodegenEnqueuer(world) { | 296 native.NativeEnqueuer nativeCodegenEnqueuer(world) { |
| 297 return new native.NativeEnqueuer(); | 297 return new native.NativeEnqueuer(); |
| 298 } | 298 } |
| 299 | 299 |
| 300 /// Generates the output and returns the total size of the generated code. | 300 /// Generates the output and returns the total size of the generated code. |
| 301 int assembleProgram(); | 301 int assembleProgram(); |
| 302 | 302 |
| 303 List<CompilerTask> get tasks; | 303 List<CompilerTask> get tasks; |
| 304 | 304 |
| 305 bool get canHandleCompilationFailed; | |
| 306 | |
| 307 void onResolutionComplete() {} | 305 void onResolutionComplete() {} |
| 308 void onTypeInferenceComplete() {} | 306 void onTypeInferenceComplete() {} |
| 309 | 307 |
| 310 ItemCompilationContext createItemCompilationContext() { | 308 ItemCompilationContext createItemCompilationContext() { |
| 311 return new ItemCompilationContext(); | 309 return new ItemCompilationContext(); |
| 312 } | 310 } |
| 313 | 311 |
| 314 bool classNeedsRti(ClassElement cls); | 312 bool classNeedsRti(ClassElement cls); |
| 315 bool methodNeedsRti(FunctionElement function); | 313 bool methodNeedsRti(FunctionElement function); |
| 316 | 314 |
| 317 /// Register deferred loading. Returns `true` if the backend supports deferred | 315 /// Enable compilation of code with compile time errors. Returns `true` if |
| 316 /// supported by the backend. |
| 317 bool enableCodegenWithErrorsIfSupported(Spannable node); |
| 318 |
| 319 /// Enable deferred loading. Returns `true` if the backend supports deferred |
| 318 /// loading. | 320 /// loading. |
| 319 bool registerDeferredLoading(Spannable node, Registry registry); | 321 bool enableDeferredLoadingIfSupported(Spannable node, Registry registry); |
| 320 | 322 |
| 321 /// Called during codegen when [constant] has been used. | 323 /// Called during codegen when [constant] has been used. |
| 322 void registerCompileTimeConstant(ConstantValue constant, Registry registry) {} | 324 void registerCompileTimeConstant(ConstantValue constant, Registry registry) {} |
| 323 | 325 |
| 324 /// Called during resolution when a constant value for [metadata] on | 326 /// Called during resolution when a constant value for [metadata] on |
| 325 /// [annotatedElement] has been evaluated. | 327 /// [annotatedElement] has been evaluated. |
| 326 void registerMetadataConstant(MetadataAnnotation metadata, | 328 void registerMetadataConstant(MetadataAnnotation metadata, |
| 327 Element annotatedElement, | 329 Element annotatedElement, |
| 328 Registry registry) {} | 330 Registry registry) {} |
| 329 | 331 |
| (...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 787 /// Temporary flag to enable `?.`, `??`, and `??=` until it becomes part of | 789 /// Temporary flag to enable `?.`, `??`, and `??=` until it becomes part of |
| 788 /// the spec. | 790 /// the spec. |
| 789 final bool enableNullAwareOperators; | 791 final bool enableNullAwareOperators; |
| 790 | 792 |
| 791 /// Output provider from user of Compiler API. | 793 /// Output provider from user of Compiler API. |
| 792 api.CompilerOutputProvider userOutputProvider; | 794 api.CompilerOutputProvider userOutputProvider; |
| 793 | 795 |
| 794 /// Generate output even when there are compile-time errors. | 796 /// Generate output even when there are compile-time errors. |
| 795 final bool generateCodeWithCompileTimeErrors; | 797 final bool generateCodeWithCompileTimeErrors; |
| 796 | 798 |
| 799 /// The compiler is run from the build bot. |
| 800 final bool testMode; |
| 801 |
| 797 bool disableInlining = false; | 802 bool disableInlining = false; |
| 798 | 803 |
| 799 List<Uri> librariesToAnalyzeWhenRun; | 804 List<Uri> librariesToAnalyzeWhenRun; |
| 800 | 805 |
| 801 Tracer tracer; | 806 Tracer tracer; |
| 802 | 807 |
| 803 CompilerTask measuredTask; | 808 CompilerTask measuredTask; |
| 804 Element _currentElement; | 809 Element _currentElement; |
| 805 LibraryElement coreLibrary; | 810 LibraryElement coreLibrary; |
| 806 LibraryElement asyncLibrary; | 811 LibraryElement asyncLibrary; |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1046 this.dumpInfo: false, | 1051 this.dumpInfo: false, |
| 1047 this.showPackageWarnings: false, | 1052 this.showPackageWarnings: false, |
| 1048 this.useContentSecurityPolicy: false, | 1053 this.useContentSecurityPolicy: false, |
| 1049 this.suppressWarnings: false, | 1054 this.suppressWarnings: false, |
| 1050 this.fatalWarnings: false, | 1055 this.fatalWarnings: false, |
| 1051 bool hasIncrementalSupport: false, | 1056 bool hasIncrementalSupport: false, |
| 1052 this.enableExperimentalMirrors: false, | 1057 this.enableExperimentalMirrors: false, |
| 1053 this.allowNativeExtensions: false, | 1058 this.allowNativeExtensions: false, |
| 1054 this.enableNullAwareOperators: false, | 1059 this.enableNullAwareOperators: false, |
| 1055 this.generateCodeWithCompileTimeErrors: false, | 1060 this.generateCodeWithCompileTimeErrors: false, |
| 1061 this.testMode: false, |
| 1056 api.CompilerOutputProvider outputProvider, | 1062 api.CompilerOutputProvider outputProvider, |
| 1057 List<String> strips: const []}) | 1063 List<String> strips: const []}) |
| 1058 : this.disableTypeInferenceFlag = | 1064 : this.disableTypeInferenceFlag = |
| 1059 disableTypeInferenceFlag || !emitJavaScript, | 1065 disableTypeInferenceFlag || !emitJavaScript, |
| 1060 this.analyzeOnly = | 1066 this.analyzeOnly = |
| 1061 analyzeOnly || analyzeSignaturesOnly || analyzeAllFlag, | 1067 analyzeOnly || analyzeSignaturesOnly || analyzeAllFlag, |
| 1062 this.analyzeSignaturesOnly = analyzeSignaturesOnly, | 1068 this.analyzeSignaturesOnly = analyzeSignaturesOnly, |
| 1063 this.analyzeAllFlag = analyzeAllFlag, | 1069 this.analyzeAllFlag = analyzeAllFlag, |
| 1064 this.hasIncrementalSupport = hasIncrementalSupport, | 1070 this.hasIncrementalSupport = hasIncrementalSupport, |
| 1065 cacheStrategy = new CacheStrategy(hasIncrementalSupport), | 1071 cacheStrategy = new CacheStrategy(hasIncrementalSupport), |
| (...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1614 } | 1620 } |
| 1615 reportDiagnostic(null, | 1621 reportDiagnostic(null, |
| 1616 kind.message({'warnings': info.warnings, | 1622 kind.message({'warnings': info.warnings, |
| 1617 'hints': info.hints, | 1623 'hints': info.hints, |
| 1618 'uri': uri}, | 1624 'uri': uri}, |
| 1619 terseDiagnostics), | 1625 terseDiagnostics), |
| 1620 api.Diagnostic.HINT); | 1626 api.Diagnostic.HINT); |
| 1621 }); | 1627 }); |
| 1622 } | 1628 } |
| 1623 | 1629 |
| 1624 // TODO(sigurdm): The dart backend should handle failed compilations. | 1630 if (compilationFailed){ |
| 1625 if (compilationFailed && !backend.canHandleCompilationFailed) { | 1631 if (!generateCodeWithCompileTimeErrors) return; |
| 1626 return; | 1632 if (!backend.enableCodegenWithErrorsIfSupported(NO_LOCATION_SPANNABLE)) { |
| 1633 return; |
| 1634 } |
| 1627 } | 1635 } |
| 1628 | 1636 |
| 1629 if (analyzeOnly) { | 1637 if (analyzeOnly) { |
| 1630 if (!analyzeAll && !compilationFailed) { | 1638 if (!analyzeAll && !compilationFailed) { |
| 1631 // No point in reporting unused code when [analyzeAll] is true: all | 1639 // No point in reporting unused code when [analyzeAll] is true: all |
| 1632 // code is artificially used. | 1640 // code is artificially used. |
| 1633 // If compilation failed, it is possible that the error prevents the | 1641 // If compilation failed, it is possible that the error prevents the |
| 1634 // compiler from analyzing all the code. | 1642 // compiler from analyzing all the code. |
| 1635 reportUnusedCode(); | 1643 reportUnusedCode(); |
| 1636 } | 1644 } |
| (...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2152 } | 2160 } |
| 2153 } | 2161 } |
| 2154 backend.forgetElement(element); | 2162 backend.forgetElement(element); |
| 2155 } | 2163 } |
| 2156 | 2164 |
| 2157 bool elementHasCompileTimeError(Element element) { | 2165 bool elementHasCompileTimeError(Element element) { |
| 2158 return elementsWithCompileTimeErrors.contains(element); | 2166 return elementsWithCompileTimeErrors.contains(element); |
| 2159 } | 2167 } |
| 2160 | 2168 |
| 2161 EventSink<String> outputProvider(String name, String extension) { | 2169 EventSink<String> outputProvider(String name, String extension) { |
| 2162 if (compilationFailed) return new NullSink('$name.$extension'); | 2170 if (compilationFailed) { |
| 2171 if (!generateCodeWithCompileTimeErrors || testMode) { |
| 2172 // Disable output in test mode: The build bot currently uses the time |
| 2173 // stamp of the generated file to determine whether the output is |
| 2174 // up-to-date. |
| 2175 return new NullSink('$name.$extension'); |
| 2176 } |
| 2177 } |
| 2163 return userOutputProvider(name, extension); | 2178 return userOutputProvider(name, extension); |
| 2164 } | 2179 } |
| 2165 } | 2180 } |
| 2166 | 2181 |
| 2167 class CompilerTask { | 2182 class CompilerTask { |
| 2168 final Compiler compiler; | 2183 final Compiler compiler; |
| 2169 final Stopwatch watch; | 2184 final Stopwatch watch; |
| 2170 UserTag profilerTag; | 2185 UserTag profilerTag; |
| 2171 | 2186 |
| 2172 CompilerTask(Compiler compiler) | 2187 CompilerTask(Compiler compiler) |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2493 InterfaceType streamType([DartType elementType]) { | 2508 InterfaceType streamType([DartType elementType]) { |
| 2494 InterfaceType type = streamClass.computeType(compiler); | 2509 InterfaceType type = streamClass.computeType(compiler); |
| 2495 if (elementType == null) { | 2510 if (elementType == null) { |
| 2496 return streamClass.rawType; | 2511 return streamClass.rawType; |
| 2497 } | 2512 } |
| 2498 return type.createInstantiation([elementType]); | 2513 return type.createInstantiation([elementType]); |
| 2499 } | 2514 } |
| 2500 } | 2515 } |
| 2501 | 2516 |
| 2502 typedef void InternalErrorFunction(Spannable location, String message); | 2517 typedef void InternalErrorFunction(Spannable location, String message); |
| OLD | NEW |