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

Side by Side Diff: pkg/compiler/lib/src/deferred_load.dart

Issue 2908153003: It's alive! (Closed)
Patch Set: Updated cf. comments Created 3 years, 6 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
« no previous file with comments | « pkg/compiler/lib/src/common_elements.dart ('k') | pkg/compiler/lib/src/elements/elements.dart » ('j') | 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 library deferred_load; 5 library deferred_load;
6 6
7 import 'common/tasks.dart' show CompilerTask; 7 import 'common/tasks.dart' show CompilerTask;
8 import 'common.dart'; 8 import 'common.dart';
9 import 'compiler.dart' show Compiler; 9 import 'compiler.dart' show Compiler;
10 import 'constants/expressions.dart' show ConstantExpression; 10 import 'constants/expressions.dart' show ConstantExpression;
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 DeferredLoadTask(Compiler compiler) 157 DeferredLoadTask(Compiler compiler)
158 : compiler = compiler, 158 : compiler = compiler,
159 super(compiler.measurer) { 159 super(compiler.measurer) {
160 mainOutputUnit.imports.add(_fakeMainImport); 160 mainOutputUnit.imports.add(_fakeMainImport);
161 } 161 }
162 162
163 JavaScriptBackend get backend => compiler.backend; 163 JavaScriptBackend get backend => compiler.backend;
164 DiagnosticReporter get reporter => compiler.reporter; 164 DiagnosticReporter get reporter => compiler.reporter;
165 165
166 /// Returns the [OutputUnit] where [element] belongs. 166 /// Returns the [OutputUnit] where [element] belongs.
167 OutputUnit outputUnitForElement(Element element) { 167 OutputUnit outputUnitForElement(Entity entity) {
168 // TODO(johnniwinther): Support use of entities by splitting maps by
169 // entity kind.
168 if (!isProgramSplit) return mainOutputUnit; 170 if (!isProgramSplit) return mainOutputUnit;
169 171 Element element = entity;
170 element = element.implementation; 172 element = element.implementation;
171 while (!_elementToOutputUnit.containsKey(element)) { 173 while (!_elementToOutputUnit.containsKey(element)) {
172 // TODO(21051): workaround: it looks like we output annotation constants 174 // TODO(21051): workaround: it looks like we output annotation constants
173 // for classes that we don't include in the output. This seems to happen 175 // for classes that we don't include in the output. This seems to happen
174 // when we have reflection but can see that some classes are not needed. 176 // when we have reflection but can see that some classes are not needed.
175 // We still add the annotation but don't run through it below (where we 177 // We still add the annotation but don't run through it below (where we
176 // assign every element to its output unit). 178 // assign every element to its output unit).
177 if (element.enclosingElement == null) { 179 if (element.enclosingElement == null) {
178 _elementToOutputUnit[element] = mainOutputUnit; 180 _elementToOutputUnit[element] = mainOutputUnit;
179 break; 181 break;
180 } 182 }
181 element = element.enclosingElement.implementation; 183 element = element.enclosingElement.implementation;
182 } 184 }
183 return _elementToOutputUnit[element]; 185 return _elementToOutputUnit[element];
184 } 186 }
185 187
186 /// Returns the [OutputUnit] where [element] belongs. 188 /// Returns the [OutputUnit] where [element] belongs.
187 OutputUnit outputUnitForClass(ClassElement element) { 189 OutputUnit outputUnitForClass(ClassEntity element) {
188 return outputUnitForElement(element); 190 return outputUnitForElement(element);
189 } 191 }
190 192
191 /// Returns the [OutputUnit] where [element] belongs. 193 /// Returns the [OutputUnit] where [element] belongs.
192 OutputUnit outputUnitForMember(MemberElement element) { 194 OutputUnit outputUnitForMember(MemberEntity element) {
193 return outputUnitForElement(element); 195 return outputUnitForElement(element);
194 } 196 }
195 197
196 /// Direct access to the output-unit to element relation used for testing. 198 /// Direct access to the output-unit to element relation used for testing.
197 OutputUnit getOutputUnitForElementForTesting(Element element) { 199 OutputUnit getOutputUnitForElementForTesting(Element element) {
198 return _elementToOutputUnit[element]; 200 return _elementToOutputUnit[element];
199 } 201 }
200 202
201 /// Returns the [OutputUnit] where [constant] belongs. 203 /// Returns the [OutputUnit] where [constant] belongs.
202 OutputUnit outputUnitForConstant(ConstantValue constant) { 204 OutputUnit outputUnitForConstant(ConstantValue constant) {
(...skipping 887 matching lines...) Expand 10 before | Expand all | Expand 10 after
1090 1092
1091 bool operator ==(other) { 1093 bool operator ==(other) {
1092 if (other is! _DeclaredDeferredImport) return false; 1094 if (other is! _DeclaredDeferredImport) return false;
1093 return declaration == other.declaration; 1095 return declaration == other.declaration;
1094 } 1096 }
1095 1097
1096 int get hashCode => declaration.hashCode * 17; 1098 int get hashCode => declaration.hashCode * 17;
1097 1099
1098 String toString() => '$declaration'; 1100 String toString() => '$declaration';
1099 } 1101 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/common_elements.dart ('k') | pkg/compiler/lib/src/elements/elements.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698