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

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

Issue 2908153003: It's alive! (Closed)
Patch Set: 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
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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(Element element) {
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
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 if (!isProgramSplit) return mainOutputUnit;
Siggi Cherem (dart-lang) 2017/05/30 22:10:20 how about removing the check here and the cast bel
Johnni Winther 2017/05/31 08:19:31 Done.
191 return outputUnitForElement(element as ClassElement);
189 } 192 }
190 193
191 /// Returns the [OutputUnit] where [element] belongs. 194 /// Returns the [OutputUnit] where [element] belongs.
192 OutputUnit outputUnitForMember(MemberElement element) { 195 OutputUnit outputUnitForMember(MemberEntity element) {
193 return outputUnitForElement(element); 196 if (!isProgramSplit) return mainOutputUnit;
197 return outputUnitForElement(element as MemberElement);
194 } 198 }
195 199
196 /// Direct access to the output-unit to element relation used for testing. 200 /// Direct access to the output-unit to element relation used for testing.
197 OutputUnit getOutputUnitForElementForTesting(Element element) { 201 OutputUnit getOutputUnitForElementForTesting(Element element) {
198 return _elementToOutputUnit[element]; 202 return _elementToOutputUnit[element];
199 } 203 }
200 204
201 /// Returns the [OutputUnit] where [constant] belongs. 205 /// Returns the [OutputUnit] where [constant] belongs.
202 OutputUnit outputUnitForConstant(ConstantValue constant) { 206 OutputUnit outputUnitForConstant(ConstantValue constant) {
203 if (!isProgramSplit) return mainOutputUnit; 207 if (!isProgramSplit) return mainOutputUnit;
(...skipping 886 matching lines...) Expand 10 before | Expand all | Expand 10 after
1090 1094
1091 bool operator ==(other) { 1095 bool operator ==(other) {
1092 if (other is! _DeclaredDeferredImport) return false; 1096 if (other is! _DeclaredDeferredImport) return false;
1093 return declaration == other.declaration; 1097 return declaration == other.declaration;
1094 } 1098 }
1095 1099
1096 int get hashCode => declaration.hashCode * 17; 1100 int get hashCode => declaration.hashCode * 17;
1097 1101
1098 String toString() => '$declaration'; 1102 String toString() => '$declaration';
1099 } 1103 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698