Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(248)

Side by Side Diff: pkg/compiler/lib/src/js_emitter/registry.dart

Issue 851683004: dart2js: register output units explicitly in the program builder. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebase Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/compiler/lib/src/js_emitter/program_builder.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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.js_emitter.program_builder; 5 part of dart2js.js_emitter.program_builder;
6 6
7 /// Maps [LibraryElement]s to their [Element]s. 7 /// Maps [LibraryElement]s to their [Element]s.
8 /// 8 ///
9 /// Fundamentally, this class nicely encapsulates a 9 /// Fundamentally, this class nicely encapsulates a
10 /// `Map<LibraryElement, List<Element>>`. 10 /// `Map<LibraryElement, List<Element>>`.
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 LibrariesMap mainLibrariesMap; 71 LibrariesMap mainLibrariesMap;
72 72
73 Registry(this._compiler); 73 Registry(this._compiler);
74 74
75 bool get _isProgramSplit => _deferredLoadTask.isProgramSplit; 75 bool get _isProgramSplit => _deferredLoadTask.isProgramSplit;
76 OutputUnit get _mainOutputUnit => _deferredLoadTask.mainOutputUnit; 76 OutputUnit get _mainOutputUnit => _deferredLoadTask.mainOutputUnit;
77 77
78 LibrariesMap _mapUnitToLibrariesMap(OutputUnit targetUnit) { 78 LibrariesMap _mapUnitToLibrariesMap(OutputUnit targetUnit) {
79 if (targetUnit == _lastOutputUnit) return _lastLibrariesMap; 79 if (targetUnit == _lastOutputUnit) return _lastLibrariesMap;
80 80
81 if (mainLibrariesMap == null) { 81 LibrariesMap result = (targetUnit == _mainOutputUnit)
82 mainLibrariesMap = 82 ? mainLibrariesMap
83 new LibrariesMap.main(_deferredLoadTask.mainOutputUnit); 83 : _deferredLibrariesMap[targetUnit];
84 }
85 84
86 LibrariesMap result; 85 assert(result != null);
87 if (targetUnit == _mainOutputUnit) {
88 result = mainLibrariesMap;
89 } else {
90 String name = targetUnit.name;
91 result = _deferredLibrariesMap.putIfAbsent(
92 targetUnit, () => new LibrariesMap.deferred(targetUnit, name));
93 }
94 _lastOutputUnit = targetUnit; 86 _lastOutputUnit = targetUnit;
95 _lastLibrariesMap = result; 87 _lastLibrariesMap = result;
96 return result; 88 return result;
97 } 89 }
98 90
91 void registerOutputUnit(OutputUnit outputUnit) {
92 if (outputUnit == _mainOutputUnit) {
93 assert(mainLibrariesMap == null);
94 mainLibrariesMap =
95 new LibrariesMap.main(_deferredLoadTask.mainOutputUnit);
96 } else {
97 assert(!_deferredLibrariesMap.containsKey(outputUnit));
98 String name = outputUnit.name;
99 _deferredLibrariesMap[outputUnit] =
100 new LibrariesMap.deferred(outputUnit, name);
101 }
102 }
103
99 /// Adds all elements to their respective libraries in the correct 104 /// Adds all elements to their respective libraries in the correct
100 /// libraries map. 105 /// libraries map.
101 void registerElements(OutputUnit outputUnit, List<Element> elements) { 106 void registerElements(OutputUnit outputUnit, List<Element> elements) {
102 LibrariesMap targetLibrariesMap = _mapUnitToLibrariesMap(outputUnit); 107 LibrariesMap targetLibrariesMap = _mapUnitToLibrariesMap(outputUnit);
103 for (Element element in Elements.sortedByPosition(elements)) { 108 for (Element element in Elements.sortedByPosition(elements)) {
104 targetLibrariesMap.add(element.library, element); 109 targetLibrariesMap.add(element.library, element);
105 } 110 }
106 } 111 }
107 112
108 void registerConstant(OutputUnit outputUnit, ConstantValue constantValue) { 113 void registerConstant(OutputUnit outputUnit, ConstantValue constantValue) {
109 // We just need to make sure that the target library map is registered. 114 // Ignore for now.
110 // Otherwise a library map that contains only constants is not built.
111 _mapUnitToLibrariesMap(outputUnit);
112 } 115 }
113 116
114 Holder registerHolder(String name) { 117 Holder registerHolder(String name) {
115 return _holdersMap.putIfAbsent( 118 return _holdersMap.putIfAbsent(
116 name, 119 name,
117 () => new Holder(name, _holdersMap.length)); 120 () => new Holder(name, _holdersMap.length));
118 } 121 }
119 } 122 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_emitter/program_builder.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698