| 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 EventSink, Future; | 7 import 'dart:async' show EventSink, Future; |
| 8 | 8 |
| 9 import '../compiler_new.dart' as api; | 9 import '../compiler_new.dart' as api; |
| 10 import 'cache_strategy.dart' show CacheStrategy; | 10 import 'cache_strategy.dart' show CacheStrategy; |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 if (options.resolveOnly) { | 272 if (options.resolveOnly) { |
| 273 serialization.supportSerialization = true; | 273 serialization.supportSerialization = true; |
| 274 } | 274 } |
| 275 | 275 |
| 276 _parsingContext = | 276 _parsingContext = |
| 277 new ParsingContext(reporter, parser, patchParser, backend); | 277 new ParsingContext(reporter, parser, patchParser, backend); |
| 278 | 278 |
| 279 tasks.addAll(backend.tasks); | 279 tasks.addAll(backend.tasks); |
| 280 } | 280 } |
| 281 | 281 |
| 282 /// The world currently being computed by resolution. This forms a basis for | |
| 283 /// the [inferenceWorld] and later the [closedWorld]. | |
| 284 OpenWorld get openWorld => _world; | |
| 285 | |
| 286 /// The closed world after resolution but currently refined by inference. | |
| 287 ClosedWorldRefiner get inferenceWorld => _world; | |
| 288 | |
| 289 /// The closed world after resolution and inference. | 282 /// The closed world after resolution and inference. |
| 290 ClosedWorld get closedWorld { | 283 ClosedWorld get closedWorld { |
| 291 assert(invariant(CURRENT_ELEMENT_SPANNABLE, _world.isClosed, | 284 assert(invariant(CURRENT_ELEMENT_SPANNABLE, _world.isClosed, |
| 292 message: "Closed world not computed yet.")); | 285 message: "Closed world not computed yet.")); |
| 293 return _world; | 286 return _world; |
| 294 } | 287 } |
| 295 | 288 |
| 296 /// Creates the backend. | 289 /// Creates the backend. |
| 297 /// | 290 /// |
| 298 /// Override this to mock the backend for testing. | 291 /// Override this to mock the backend for testing. |
| (...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 721 // If compilation failed, it is possible that the error prevents the | 714 // If compilation failed, it is possible that the error prevents the |
| 722 // compiler from analyzing all the code. | 715 // compiler from analyzing all the code. |
| 723 // TODO(johnniwinther): Reenable this when the reporting is more | 716 // TODO(johnniwinther): Reenable this when the reporting is more |
| 724 // precise. | 717 // precise. |
| 725 //reportUnusedCode(); | 718 //reportUnusedCode(); |
| 726 } | 719 } |
| 727 return; | 720 return; |
| 728 } | 721 } |
| 729 assert(mainFunction != null); | 722 assert(mainFunction != null); |
| 730 | 723 |
| 731 closeResolution(); | 724 ClosedWorldRefiner closedWorldRefiner = closeResolution(); |
| 732 | 725 |
| 733 reporter.log('Inferring types...'); | 726 reporter.log('Inferring types...'); |
| 734 globalInference.runGlobalTypeInference(mainFunction); | 727 globalInference.runGlobalTypeInference( |
| 728 mainFunction, closedWorld, closedWorldRefiner); |
| 735 | 729 |
| 736 if (stopAfterTypeInference) return; | 730 if (stopAfterTypeInference) return; |
| 737 | 731 |
| 738 backend.onTypeInferenceComplete(); | 732 backend.onTypeInferenceComplete(); |
| 739 | 733 |
| 740 reporter.log('Compiling...'); | 734 reporter.log('Compiling...'); |
| 741 phase = PHASE_COMPILING; | 735 phase = PHASE_COMPILING; |
| 742 | 736 |
| 743 enqueuer.codegen.applyImpact(backend.onCodegenStart()); | 737 enqueuer.codegen.applyImpact(backend.onCodegenStart()); |
| 744 if (compileAll) { | 738 if (compileAll) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 756 dumpInfoTask.reportSize(programSize); | 750 dumpInfoTask.reportSize(programSize); |
| 757 dumpInfoTask.dumpInfo(); | 751 dumpInfoTask.dumpInfo(); |
| 758 } | 752 } |
| 759 | 753 |
| 760 backend.sourceInformationStrategy.onComplete(); | 754 backend.sourceInformationStrategy.onComplete(); |
| 761 | 755 |
| 762 checkQueues(); | 756 checkQueues(); |
| 763 }); | 757 }); |
| 764 | 758 |
| 765 /// Perform the steps needed to fully end the resolution phase. | 759 /// Perform the steps needed to fully end the resolution phase. |
| 766 void closeResolution() { | 760 ClosedWorldRefiner closeResolution() { |
| 767 phase = PHASE_DONE_RESOLVING; | 761 phase = PHASE_DONE_RESOLVING; |
| 768 | 762 |
| 769 resolverWorld.openWorld.closeWorld(reporter); | 763 WorldImpl world = resolverWorld.openWorld.closeWorld(reporter); |
| 770 // Compute whole-program-knowledge that the backend needs. (This might | 764 // Compute whole-program-knowledge that the backend needs. (This might |
| 771 // require the information computed in [world.closeWorld].) | 765 // require the information computed in [world.closeWorld].) |
| 772 backend.onResolutionComplete(); | 766 backend.onResolutionComplete(world); |
| 773 | 767 |
| 774 deferredLoadTask.onResolutionComplete(mainFunction); | 768 deferredLoadTask.onResolutionComplete(mainFunction); |
| 775 | 769 |
| 776 // TODO(johnniwinther): Move this after rti computation but before | 770 // TODO(johnniwinther): Move this after rti computation but before |
| 777 // reflection members computation, and (re-)close the world afterwards. | 771 // reflection members computation, and (re-)close the world afterwards. |
| 778 closureToClassMapper.createClosureClasses(); | 772 closureToClassMapper.createClosureClasses(world); |
| 773 return world; |
| 779 } | 774 } |
| 780 | 775 |
| 781 /// Compute the [WorldImpact] for accessing all elements in [library]. | 776 /// Compute the [WorldImpact] for accessing all elements in [library]. |
| 782 WorldImpact computeImpactForLibrary(LibraryElement library) { | 777 WorldImpact computeImpactForLibrary(LibraryElement library) { |
| 783 WorldImpactBuilderImpl impactBuilder = new WorldImpactBuilderImpl(); | 778 WorldImpactBuilderImpl impactBuilder = new WorldImpactBuilderImpl(); |
| 784 | 779 |
| 785 void registerStaticUse(Element element) { | 780 void registerStaticUse(Element element) { |
| 786 impactBuilder.registerStaticUse(new StaticUse.directUse(element)); | 781 impactBuilder.registerStaticUse(new StaticUse.directUse(element)); |
| 787 } | 782 } |
| 788 | 783 |
| (...skipping 1451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2240 _ElementScanner(this.scanner); | 2235 _ElementScanner(this.scanner); |
| 2241 void scanLibrary(LibraryElement library) => scanner.scanLibrary(library); | 2236 void scanLibrary(LibraryElement library) => scanner.scanLibrary(library); |
| 2242 void scanUnit(CompilationUnitElement unit) => scanner.scan(unit); | 2237 void scanUnit(CompilationUnitElement unit) => scanner.scan(unit); |
| 2243 } | 2238 } |
| 2244 | 2239 |
| 2245 class _EmptyEnvironment implements Environment { | 2240 class _EmptyEnvironment implements Environment { |
| 2246 const _EmptyEnvironment(); | 2241 const _EmptyEnvironment(); |
| 2247 | 2242 |
| 2248 String valueOf(String key) => null; | 2243 String valueOf(String key) => null; |
| 2249 } | 2244 } |
| OLD | NEW |