| 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 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 MirrorUsageAnalyzerTask; | 86 MirrorUsageAnalyzerTask; |
| 87 import 'common/names.dart' show | 87 import 'common/names.dart' show |
| 88 Selectors; | 88 Selectors; |
| 89 import 'null_compiler_output.dart' show | 89 import 'null_compiler_output.dart' show |
| 90 NullCompilerOutput, | 90 NullCompilerOutput, |
| 91 NullSink; | 91 NullSink; |
| 92 import 'parser/diet_parser_task.dart' show | 92 import 'parser/diet_parser_task.dart' show |
| 93 DietParserTask; | 93 DietParserTask; |
| 94 import 'parser/element_listener.dart' show | 94 import 'parser/element_listener.dart' show |
| 95 ScannerOptions; | 95 ScannerOptions; |
| 96 import 'parser/parser.dart' show |
| 97 ParserOptions; |
| 96 import 'parser/parser_task.dart' show | 98 import 'parser/parser_task.dart' show |
| 97 ParserTask; | 99 ParserTask; |
| 98 import 'patch_parser.dart' show | 100 import 'patch_parser.dart' show |
| 99 PatchParserTask; | 101 PatchParserTask; |
| 100 import 'resolution/registry.dart' show | 102 import 'resolution/registry.dart' show |
| 101 ResolutionRegistry; | 103 ResolutionRegistry; |
| 102 import 'resolution/resolution.dart' show | 104 import 'resolution/resolution.dart' show |
| 103 ResolverTask; | 105 ResolverTask; |
| 104 import 'resolution/tree_elements.dart' show | 106 import 'resolution/tree_elements.dart' show |
| 105 TreeElementMapping; | 107 TreeElementMapping; |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 final bool trustTypeAnnotations; | 198 final bool trustTypeAnnotations; |
| 197 final bool trustPrimitives; | 199 final bool trustPrimitives; |
| 198 final bool trustJSInteropTypeAnnotations; | 200 final bool trustJSInteropTypeAnnotations; |
| 199 final bool disableTypeInferenceFlag; | 201 final bool disableTypeInferenceFlag; |
| 200 final Uri deferredMapUri; | 202 final Uri deferredMapUri; |
| 201 final bool dumpInfo; | 203 final bool dumpInfo; |
| 202 final bool useContentSecurityPolicy; | 204 final bool useContentSecurityPolicy; |
| 203 final bool enableExperimentalMirrors; | 205 final bool enableExperimentalMirrors; |
| 204 final bool enableAssertMessage; | 206 final bool enableAssertMessage; |
| 205 | 207 |
| 208 /// Bundle all parser related options. |
| 209 final ParserOptions _parserOptions; |
| 210 |
| 206 /** | 211 /** |
| 207 * The maximum size of a concrete type before it widens to dynamic during | 212 * The maximum size of a concrete type before it widens to dynamic during |
| 208 * concrete type inference. | 213 * concrete type inference. |
| 209 */ | 214 */ |
| 210 final int maxConcreteTypeSize; | 215 final int maxConcreteTypeSize; |
| 211 final bool analyzeAllFlag; | 216 final bool analyzeAllFlag; |
| 212 final bool analyzeOnly; | 217 final bool analyzeOnly; |
| 213 | 218 |
| 214 /// If true, disable tree-shaking for the main script. | 219 /// If true, disable tree-shaking for the main script. |
| 215 final bool analyzeMain; | 220 final bool analyzeMain; |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 List<String> strips: const []}) | 473 List<String> strips: const []}) |
| 469 : this.disableTypeInferenceFlag = | 474 : this.disableTypeInferenceFlag = |
| 470 disableTypeInferenceFlag || !emitJavaScript, | 475 disableTypeInferenceFlag || !emitJavaScript, |
| 471 this.analyzeOnly = | 476 this.analyzeOnly = |
| 472 analyzeOnly || analyzeSignaturesOnly || analyzeAllFlag, | 477 analyzeOnly || analyzeSignaturesOnly || analyzeAllFlag, |
| 473 this.analyzeSignaturesOnly = analyzeSignaturesOnly, | 478 this.analyzeSignaturesOnly = analyzeSignaturesOnly, |
| 474 this.analyzeAllFlag = analyzeAllFlag, | 479 this.analyzeAllFlag = analyzeAllFlag, |
| 475 this.hasIncrementalSupport = hasIncrementalSupport, | 480 this.hasIncrementalSupport = hasIncrementalSupport, |
| 476 cacheStrategy = new CacheStrategy(hasIncrementalSupport), | 481 cacheStrategy = new CacheStrategy(hasIncrementalSupport), |
| 477 this.userOutputProvider = outputProvider == null | 482 this.userOutputProvider = outputProvider == null |
| 478 ? const NullCompilerOutput() : outputProvider { | 483 ? const NullCompilerOutput() : outputProvider, |
| 484 this._parserOptions = new ParserOptions( |
| 485 enableConditionalDirectives: enableConditionalDirectives) { |
| 479 if (hasIncrementalSupport) { | 486 if (hasIncrementalSupport) { |
| 480 // TODO(ahe): This is too much. Any method from platform and package | 487 // TODO(ahe): This is too much. Any method from platform and package |
| 481 // libraries can be inlined. | 488 // libraries can be inlined. |
| 482 disableInlining = true; | 489 disableInlining = true; |
| 483 } | 490 } |
| 484 world = new World(this); | 491 world = new World(this); |
| 485 // TODO(johnniwinther): Initialize core types in [initializeCoreClasses] and | 492 // TODO(johnniwinther): Initialize core types in [initializeCoreClasses] and |
| 486 // make its field final. | 493 // make its field final. |
| 487 _reporter = new _CompilerDiagnosticReporter(this, diagnosticOptions); | 494 _reporter = new _CompilerDiagnosticReporter(this, diagnosticOptions); |
| 488 _parsing = new _CompilerParsing(this); | 495 _parsing = new _CompilerParsing(this, _parserOptions); |
| 489 _resolution = new _CompilerResolution(this); | 496 _resolution = new _CompilerResolution(this); |
| 490 _coreTypes = new _CompilerCoreTypes(_resolution); | 497 _coreTypes = new _CompilerCoreTypes(_resolution); |
| 491 types = new Types(_resolution); | 498 types = new Types(_resolution); |
| 492 tracer = new Tracer(this, this.outputProvider); | 499 tracer = new Tracer(this, this.outputProvider); |
| 493 | 500 |
| 494 if (verbose) { | 501 if (verbose) { |
| 495 progress = new Stopwatch()..start(); | 502 progress = new Stopwatch()..start(); |
| 496 } | 503 } |
| 497 | 504 |
| 498 // TODO(johnniwinther): Separate the dependency tracking from the enqueuing | 505 // TODO(johnniwinther): Separate the dependency tracking from the enqueuing |
| (...skipping 12 matching lines...) Expand all Loading... |
| 511 multiFile: dart2dartMultiFile); | 518 multiFile: dart2dartMultiFile); |
| 512 if (dumpInfo) { | 519 if (dumpInfo) { |
| 513 throw new ArgumentError('--dump-info is not supported for dart2dart.'); | 520 throw new ArgumentError('--dump-info is not supported for dart2dart.'); |
| 514 } | 521 } |
| 515 } | 522 } |
| 516 | 523 |
| 517 tasks = [ | 524 tasks = [ |
| 518 libraryLoader = new LibraryLoaderTask(this), | 525 libraryLoader = new LibraryLoaderTask(this), |
| 519 serialization = new SerializationTask(this), | 526 serialization = new SerializationTask(this), |
| 520 scanner = new ScannerTask(this), | 527 scanner = new ScannerTask(this), |
| 521 dietParser = new DietParserTask( | 528 dietParser = new DietParserTask(this, _parserOptions), |
| 522 this, enableConditionalDirectives: enableConditionalDirectives), | 529 parser = new ParserTask(this, _parserOptions), |
| 523 parser = new ParserTask( | 530 patchParser = new PatchParserTask(this, _parserOptions), |
| 524 this, enableConditionalDirectives: enableConditionalDirectives), | |
| 525 patchParser = new PatchParserTask( | |
| 526 this, enableConditionalDirectives: enableConditionalDirectives), | |
| 527 resolver = new ResolverTask(this, backend.constantCompilerTask), | 531 resolver = new ResolverTask(this, backend.constantCompilerTask), |
| 528 closureToClassMapper = new closureMapping.ClosureTask(this), | 532 closureToClassMapper = new closureMapping.ClosureTask(this), |
| 529 checker = new TypeCheckerTask(this), | 533 checker = new TypeCheckerTask(this), |
| 530 typesTask = new ti.TypesTask(this), | 534 typesTask = new ti.TypesTask(this), |
| 531 constants = backend.constantCompilerTask, | 535 constants = backend.constantCompilerTask, |
| 532 deferredLoadTask = new DeferredLoadTask(this), | 536 deferredLoadTask = new DeferredLoadTask(this), |
| 533 mirrorUsageAnalyzerTask = new MirrorUsageAnalyzerTask(this), | 537 mirrorUsageAnalyzerTask = new MirrorUsageAnalyzerTask(this), |
| 534 enqueuer = new EnqueueTask(this), | 538 enqueuer = new EnqueueTask(this), |
| 535 dumpInfoTask = new DumpInfoTask(this), | 539 dumpInfoTask = new DumpInfoTask(this), |
| 536 reuseLibraryTask = new GenericTask('Reuse library', this), | 540 reuseLibraryTask = new GenericTask('Reuse library', this), |
| (...skipping 1619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2156 @override | 2160 @override |
| 2157 bool hasBeenResolved(Element element) { | 2161 bool hasBeenResolved(Element element) { |
| 2158 return _worldImpactCache.containsKey(element); | 2162 return _worldImpactCache.containsKey(element); |
| 2159 } | 2163 } |
| 2160 } | 2164 } |
| 2161 | 2165 |
| 2162 // TODO(johnniwinther): Move [ParserTask], [PatchParserTask], [DietParserTask] | 2166 // TODO(johnniwinther): Move [ParserTask], [PatchParserTask], [DietParserTask] |
| 2163 // and [ScannerTask] here. | 2167 // and [ScannerTask] here. |
| 2164 class _CompilerParsing implements Parsing { | 2168 class _CompilerParsing implements Parsing { |
| 2165 final Compiler compiler; | 2169 final Compiler compiler; |
| 2170 final ParserOptions parserOptions; |
| 2166 | 2171 |
| 2167 _CompilerParsing(this.compiler); | 2172 _CompilerParsing(this.compiler, this.parserOptions); |
| 2168 | 2173 |
| 2169 @override | 2174 @override |
| 2170 DiagnosticReporter get reporter => compiler.reporter; | 2175 DiagnosticReporter get reporter => compiler.reporter; |
| 2171 | 2176 |
| 2172 @override | 2177 @override |
| 2173 measure(f()) => compiler.parser.measure(f); | 2178 measure(f()) => compiler.parser.measure(f); |
| 2174 | 2179 |
| 2175 @override | 2180 @override |
| 2176 void parsePatchClass(ClassElement cls) { | 2181 void parsePatchClass(ClassElement cls) { |
| 2177 compiler.patchParser.measure(() { | 2182 compiler.patchParser.measure(() { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 2203 if (_otherDependencies == null) { | 2208 if (_otherDependencies == null) { |
| 2204 _otherDependencies = new Setlet<Element>(); | 2209 _otherDependencies = new Setlet<Element>(); |
| 2205 } | 2210 } |
| 2206 _otherDependencies.add(element.implementation); | 2211 _otherDependencies.add(element.implementation); |
| 2207 } | 2212 } |
| 2208 | 2213 |
| 2209 Iterable<Element> get otherDependencies { | 2214 Iterable<Element> get otherDependencies { |
| 2210 return _otherDependencies != null ? _otherDependencies : const <Element>[]; | 2215 return _otherDependencies != null ? _otherDependencies : const <Element>[]; |
| 2211 } | 2216 } |
| 2212 } | 2217 } |
| OLD | NEW |