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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 import 'mirrors_used.dart' show | 85 import 'mirrors_used.dart' show |
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 ParserOptions, |
95 ScannerOptions; | 96 ScannerOptions; |
96 import 'parser/parser_task.dart' show | 97 import 'parser/parser_task.dart' show |
97 ParserTask; | 98 ParserTask; |
98 import 'patch_parser.dart' show | 99 import 'patch_parser.dart' show |
99 PatchParserTask; | 100 PatchParserTask; |
100 import 'resolution/registry.dart' show | 101 import 'resolution/registry.dart' show |
101 ResolutionRegistry; | 102 ResolutionRegistry; |
102 import 'resolution/resolution.dart' show | 103 import 'resolution/resolution.dart' show |
103 ResolverTask; | 104 ResolverTask; |
104 import 'resolution/tree_elements.dart' show | 105 import 'resolution/tree_elements.dart' show |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 final bool enableUserAssertions; | 196 final bool enableUserAssertions; |
196 final bool trustTypeAnnotations; | 197 final bool trustTypeAnnotations; |
197 final bool trustPrimitives; | 198 final bool trustPrimitives; |
198 final bool trustJSInteropTypeAnnotations; | 199 final bool trustJSInteropTypeAnnotations; |
199 final bool disableTypeInferenceFlag; | 200 final bool disableTypeInferenceFlag; |
200 final Uri deferredMapUri; | 201 final Uri deferredMapUri; |
201 final bool dumpInfo; | 202 final bool dumpInfo; |
202 final bool useContentSecurityPolicy; | 203 final bool useContentSecurityPolicy; |
203 final bool enableExperimentalMirrors; | 204 final bool enableExperimentalMirrors; |
204 final bool enableAssertMessage; | 205 final bool enableAssertMessage; |
| 206 final bool enableConditionalDirectives; |
| 207 final bool enableGenericMethods; |
205 | 208 |
206 /** | 209 /** |
207 * The maximum size of a concrete type before it widens to dynamic during | 210 * The maximum size of a concrete type before it widens to dynamic during |
208 * concrete type inference. | 211 * concrete type inference. |
209 */ | 212 */ |
210 final int maxConcreteTypeSize; | 213 final int maxConcreteTypeSize; |
211 final bool analyzeAllFlag; | 214 final bool analyzeAllFlag; |
212 final bool analyzeOnly; | 215 final bool analyzeOnly; |
213 | 216 |
214 /// If true, disable tree-shaking for the main script. | 217 /// If true, disable tree-shaking for the main script. |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
447 this.preserveComments: false, | 450 this.preserveComments: false, |
448 this.useCpsIr: false, | 451 this.useCpsIr: false, |
449 this.useFrequencyNamer: false, | 452 this.useFrequencyNamer: false, |
450 this.verbose: false, | 453 this.verbose: false, |
451 this.sourceMapUri: null, | 454 this.sourceMapUri: null, |
452 this.outputUri: null, | 455 this.outputUri: null, |
453 this.buildId: UNDETERMINED_BUILD_ID, | 456 this.buildId: UNDETERMINED_BUILD_ID, |
454 this.deferredMapUri: null, | 457 this.deferredMapUri: null, |
455 this.dumpInfo: false, | 458 this.dumpInfo: false, |
456 bool useStartupEmitter: false, | 459 bool useStartupEmitter: false, |
457 bool enableConditionalDirectives: false, | 460 this.enableConditionalDirectives: false, |
| 461 this.enableGenericMethods: false, |
458 this.useContentSecurityPolicy: false, | 462 this.useContentSecurityPolicy: false, |
459 bool hasIncrementalSupport: false, | 463 bool hasIncrementalSupport: false, |
460 this.enableExperimentalMirrors: false, | 464 this.enableExperimentalMirrors: false, |
461 this.enableAssertMessage: false, | 465 this.enableAssertMessage: false, |
462 this.allowNativeExtensions: false, | 466 this.allowNativeExtensions: false, |
463 this.generateCodeWithCompileTimeErrors: false, | 467 this.generateCodeWithCompileTimeErrors: false, |
464 this.testMode: false, | 468 this.testMode: false, |
465 DiagnosticOptions diagnosticOptions, | 469 DiagnosticOptions diagnosticOptions, |
466 api.CompilerOutput outputProvider, | 470 api.CompilerOutput outputProvider, |
467 List<String> strips: const []}) | 471 List<String> strips: const []}) |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
509 multiFile: dart2dartMultiFile); | 513 multiFile: dart2dartMultiFile); |
510 if (dumpInfo) { | 514 if (dumpInfo) { |
511 throw new ArgumentError('--dump-info is not supported for dart2dart.'); | 515 throw new ArgumentError('--dump-info is not supported for dart2dart.'); |
512 } | 516 } |
513 } | 517 } |
514 | 518 |
515 tasks = [ | 519 tasks = [ |
516 libraryLoader = new LibraryLoaderTask(this), | 520 libraryLoader = new LibraryLoaderTask(this), |
517 serialization = new SerializationTask(this), | 521 serialization = new SerializationTask(this), |
518 scanner = new ScannerTask(this), | 522 scanner = new ScannerTask(this), |
519 dietParser = new DietParserTask( | 523 dietParser = new DietParserTask(this, parsing.parserOptions), |
520 this, enableConditionalDirectives: enableConditionalDirectives), | 524 parser = new ParserTask(this, parsing.parserOptions), |
521 parser = new ParserTask( | 525 patchParser = new PatchParserTask(this, parsing.parserOptions), |
522 this, enableConditionalDirectives: enableConditionalDirectives), | |
523 patchParser = new PatchParserTask( | |
524 this, enableConditionalDirectives: enableConditionalDirectives), | |
525 resolver = new ResolverTask(this, backend.constantCompilerTask), | 526 resolver = new ResolverTask(this, backend.constantCompilerTask), |
526 closureToClassMapper = new closureMapping.ClosureTask(this), | 527 closureToClassMapper = new closureMapping.ClosureTask(this), |
527 checker = new TypeCheckerTask(this), | 528 checker = new TypeCheckerTask(this), |
528 typesTask = new ti.TypesTask(this), | 529 typesTask = new ti.TypesTask(this), |
529 constants = backend.constantCompilerTask, | 530 constants = backend.constantCompilerTask, |
530 deferredLoadTask = new DeferredLoadTask(this), | 531 deferredLoadTask = new DeferredLoadTask(this), |
531 mirrorUsageAnalyzerTask = new MirrorUsageAnalyzerTask(this), | 532 mirrorUsageAnalyzerTask = new MirrorUsageAnalyzerTask(this), |
532 enqueuer = new EnqueueTask(this), | 533 enqueuer = new EnqueueTask(this), |
533 dumpInfoTask = new DumpInfoTask(this), | 534 dumpInfoTask = new DumpInfoTask(this), |
534 reuseLibraryTask = new GenericTask('Reuse library', this), | 535 reuseLibraryTask = new GenericTask('Reuse library', this), |
(...skipping 1641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2176 if (cls.isPatch) { | 2177 if (cls.isPatch) { |
2177 compiler.patchParser.parsePatchClassNode(cls); | 2178 compiler.patchParser.parsePatchClassNode(cls); |
2178 } | 2179 } |
2179 }); | 2180 }); |
2180 } | 2181 } |
2181 | 2182 |
2182 ScannerOptions getScannerOptionsFor(Element element) { | 2183 ScannerOptions getScannerOptionsFor(Element element) { |
2183 return new ScannerOptions( | 2184 return new ScannerOptions( |
2184 canUseNative: compiler.backend.canLibraryUseNative(element.library)); | 2185 canUseNative: compiler.backend.canLibraryUseNative(element.library)); |
2185 } | 2186 } |
| 2187 |
| 2188 @override |
| 2189 ParserOptions get parserOptions { |
| 2190 return new ParserOptions( |
| 2191 enableConditionalDirectives: compiler.enableConditionalDirectives, |
| 2192 enableGenericMethods: compiler.enableGenericMethods); |
| 2193 } |
2186 } | 2194 } |
2187 | 2195 |
2188 class GlobalDependencyRegistry extends EagerRegistry { | 2196 class GlobalDependencyRegistry extends EagerRegistry { |
2189 final Compiler compiler; | 2197 final Compiler compiler; |
2190 Setlet<Element> _otherDependencies; | 2198 Setlet<Element> _otherDependencies; |
2191 | 2199 |
2192 GlobalDependencyRegistry(this.compiler) : super('GlobalDependencies', null); | 2200 GlobalDependencyRegistry(this.compiler) : super('GlobalDependencies', null); |
2193 | 2201 |
2194 // TODO(johnniwinther): Rename world/universe/enqueuer through out the | 2202 // TODO(johnniwinther): Rename world/universe/enqueuer through out the |
2195 // compiler. | 2203 // compiler. |
2196 @override | 2204 @override |
2197 Enqueuer get world => compiler.enqueuer.codegen; | 2205 Enqueuer get world => compiler.enqueuer.codegen; |
2198 | 2206 |
2199 void registerDependency(Element element) { | 2207 void registerDependency(Element element) { |
2200 if (element == null) return; | 2208 if (element == null) return; |
2201 if (_otherDependencies == null) { | 2209 if (_otherDependencies == null) { |
2202 _otherDependencies = new Setlet<Element>(); | 2210 _otherDependencies = new Setlet<Element>(); |
2203 } | 2211 } |
2204 _otherDependencies.add(element.implementation); | 2212 _otherDependencies.add(element.implementation); |
2205 } | 2213 } |
2206 | 2214 |
2207 Iterable<Element> get otherDependencies { | 2215 Iterable<Element> get otherDependencies { |
2208 return _otherDependencies != null ? _otherDependencies : const <Element>[]; | 2216 return _otherDependencies != null ? _otherDependencies : const <Element>[]; |
2209 } | 2217 } |
2210 } | 2218 } |
OLD | NEW |