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

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

Issue 2843283004: Use more entities in program_builder, collector and registry (Closed)
Patch Set: Updated cf. comments. Created 3 years, 7 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 | « no previous file | 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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 // assign every element to its output unit). 176 // assign every element to its output unit).
177 if (element.enclosingElement == null) { 177 if (element.enclosingElement == null) {
178 _elementToOutputUnit[element] = mainOutputUnit; 178 _elementToOutputUnit[element] = mainOutputUnit;
179 break; 179 break;
180 } 180 }
181 element = element.enclosingElement.implementation; 181 element = element.enclosingElement.implementation;
182 } 182 }
183 return _elementToOutputUnit[element]; 183 return _elementToOutputUnit[element];
184 } 184 }
185 185
186 /// Returns the [OutputUnit] where [element] belongs.
187 OutputUnit outputUnitForClass(ClassElement element) {
188 return outputUnitForElement(element);
189 }
190
191 /// Returns the [OutputUnit] where [element] belongs.
192 OutputUnit outputUnitForMember(MemberElement element) {
193 return outputUnitForElement(element);
194 }
195
186 /// Direct access to the output-unit to element relation used for testing. 196 /// Direct access to the output-unit to element relation used for testing.
187 OutputUnit getOutputUnitForElementForTesting(Element element) { 197 OutputUnit getOutputUnitForElementForTesting(Element element) {
188 return _elementToOutputUnit[element]; 198 return _elementToOutputUnit[element];
189 } 199 }
190 200
191 /// Returns the [OutputUnit] where [constant] belongs. 201 /// Returns the [OutputUnit] where [constant] belongs.
192 OutputUnit outputUnitForConstant(ConstantValue constant) { 202 OutputUnit outputUnitForConstant(ConstantValue constant) {
193 if (!isProgramSplit) return mainOutputUnit; 203 if (!isProgramSplit) return mainOutputUnit;
194 return _constantToOutputUnit[constant]; 204 return _constantToOutputUnit[constant];
195 } 205 }
196 206
197 /// Direct access to the output-unit to constants map used for testing. 207 /// Direct access to the output-unit to constants map used for testing.
198 Map<ConstantValue, OutputUnit> get outputUnitForConstantsForTesting { 208 Map<ConstantValue, OutputUnit> get outputUnitForConstantsForTesting {
199 return _constantToOutputUnit; 209 return _constantToOutputUnit;
200 } 210 }
201 211
202 bool isDeferred(Element element) { 212 bool isDeferred(Element element) {
203 return outputUnitForElement(element) != mainOutputUnit; 213 return outputUnitForElement(element) != mainOutputUnit;
204 } 214 }
205 215
216 bool isDeferredClass(ClassElement element) {
217 return outputUnitForElement(element) != mainOutputUnit;
218 }
219
206 /// Returns the unique name for the deferred import of [prefix]. 220 /// Returns the unique name for the deferred import of [prefix].
207 String getImportDeferName(Spannable node, PrefixElement prefix) { 221 String getImportDeferName(Spannable node, PrefixElement prefix) {
208 String name = 222 String name =
209 importDeferName[new _DeclaredDeferredImport(prefix.deferredImport)]; 223 importDeferName[new _DeclaredDeferredImport(prefix.deferredImport)];
210 if (name == null) { 224 if (name == null) {
211 reporter.internalError(node, "No deferred name for $prefix."); 225 reporter.internalError(node, "No deferred name for $prefix.");
212 } 226 }
213 return name; 227 return name;
214 } 228 }
215 229
(...skipping 858 matching lines...) Expand 10 before | Expand all | Expand 10 after
1074 1088
1075 bool operator ==(other) { 1089 bool operator ==(other) {
1076 if (other is! _DeclaredDeferredImport) return false; 1090 if (other is! _DeclaredDeferredImport) return false;
1077 return declaration == other.declaration; 1091 return declaration == other.declaration;
1078 } 1092 }
1079 1093
1080 int get hashCode => declaration.hashCode * 17; 1094 int get hashCode => declaration.hashCode * 17;
1081 1095
1082 String toString() => '$declaration'; 1096 String toString() => '$declaration';
1083 } 1097 }
OLDNEW
« no previous file with comments | « no previous file | pkg/compiler/lib/src/elements/elements.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698