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

Side by Side Diff: pkg/compiler/lib/src/universe/use.dart

Issue 2392943003: Handle const constructor invocation in kernel_impact. (Closed)
Patch Set: Created 4 years, 2 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) 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 /// This library defines individual world impacts. 5 /// This library defines individual world impacts.
6 /// 6 ///
7 /// We call these building blocks `uses`. Each `use` is a single impact of the 7 /// We call these building blocks `uses`. Each `use` is a single impact of the
8 /// world. Some example uses are: 8 /// world. Some example uses are:
9 /// 9 ///
10 /// * an invocation of a top level function 10 /// * an invocation of a top level function
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 } 64 }
65 65
66 enum StaticUseKind { 66 enum StaticUseKind {
67 GENERAL, 67 GENERAL,
68 STATIC_TEAR_OFF, 68 STATIC_TEAR_OFF,
69 SUPER_TEAR_OFF, 69 SUPER_TEAR_OFF,
70 SUPER_FIELD_SET, 70 SUPER_FIELD_SET,
71 FIELD_GET, 71 FIELD_GET,
72 FIELD_SET, 72 FIELD_SET,
73 CLOSURE, 73 CLOSURE,
74 CONSTRUCTOR_INVOKE,
75 CONST_CONSTRUCTOR_INVOKE,
74 } 76 }
75 77
76 /// Statically known use of an [Element]. 78 /// Statically known use of an [Element].
77 // TODO(johnniwinther): Create backend-specific implementations with better 79 // TODO(johnniwinther): Create backend-specific implementations with better
78 // invariants. 80 // invariants.
79 class StaticUse { 81 class StaticUse {
80 final Element element; 82 final Element element;
81 final StaticUseKind kind; 83 final StaticUseKind kind;
82 final int hashCode; 84 final int hashCode;
85 final DartType type;
83 86
84 StaticUse.internal(Element element, StaticUseKind kind) 87 StaticUse.internal(Element element, StaticUseKind kind, [DartType type = null] )
Harry Terkelsen 2016/10/07 15:53:21 long line
Johnni Winther 2016/10/10 09:58:12 Done.
85 : this.element = element, 88 : this.element = element,
86 this.kind = kind, 89 this.kind = kind,
87 this.hashCode = Hashing.objectHash(element, Hashing.objectHash(kind)) { 90 this.type = type,
91 this.hashCode = Hashing.objectsHash(element, kind, type) {
88 assert(invariant(element, element.isDeclaration, 92 assert(invariant(element, element.isDeclaration,
89 message: "Static use element $element must be " 93 message: "Static use element $element must be "
90 "the declaration element.")); 94 "the declaration element."));
91 } 95 }
92 96
93 /// Invocation of a static or top-level [element] with the given 97 /// Invocation of a static or top-level [element] with the given
94 /// [callStructure]. 98 /// [callStructure].
95 factory StaticUse.staticInvoke( 99 factory StaticUse.staticInvoke(
96 MethodElement element, CallStructure callStructure) { 100 MethodElement element, CallStructure callStructure) {
97 // TODO(johnniwinther): Use the [callStructure]. 101 // TODO(johnniwinther): Use the [callStructure].
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 return new StaticUse.internal(element, StaticUseKind.GENERAL); 206 return new StaticUse.internal(element, StaticUseKind.GENERAL);
203 } 207 }
204 208
205 /// Constructor invocation of [element] with the given [callStructure]. 209 /// Constructor invocation of [element] with the given [callStructure].
206 factory StaticUse.constructorInvoke( 210 factory StaticUse.constructorInvoke(
207 ConstructorElement element, CallStructure callStructure) { 211 ConstructorElement element, CallStructure callStructure) {
208 // TODO(johnniwinther): Use the [callStructure]. 212 // TODO(johnniwinther): Use the [callStructure].
209 return new StaticUse.internal(element, StaticUseKind.GENERAL); 213 return new StaticUse.internal(element, StaticUseKind.GENERAL);
210 } 214 }
211 215
216 /// Constructor invocation of [element] with the given [callStructure] on
217 /// [type].
218 factory StaticUse.typedConstructorInvoke(
219 ConstructorElement element, CallStructure callStructure, DartType type) {
220 assert(invariant(element, type != null,
221 message: "No type provided for constructor invocation."));
222 // TODO(johnniwinther): Use the [callStructure].
223 return new StaticUse.internal(element, StaticUseKind.CONSTRUCTOR_INVOKE, typ e);
Harry Terkelsen 2016/10/07 15:53:21 long line
Johnni Winther 2016/10/10 09:58:12 Done.
224 }
225
226 /// Constant constructor invocation of [element] with the given
227 /// [callStructure] on [type].
228 factory StaticUse.constConstructorInvoke(
229 ConstructorElement element, CallStructure callStructure, DartType type) {
230 assert(invariant(element, type != null,
231 message: "No type provided for constructor invocation."));
232 // TODO(johnniwinther): Use the [callStructure].
233 return new StaticUse.internal(
234 element, StaticUseKind.CONST_CONSTRUCTOR_INVOKE, type);
235 }
236
212 /// Constructor redirection to [element]. 237 /// Constructor redirection to [element].
213 factory StaticUse.constructorRedirect(ConstructorElement element) { 238 factory StaticUse.constructorRedirect(ConstructorElement element) {
214 return new StaticUse.internal(element, StaticUseKind.GENERAL); 239 return new StaticUse.internal(element, StaticUseKind.GENERAL);
215 } 240 }
216 241
217 /// Initialization of an instance field [element]. 242 /// Initialization of an instance field [element].
218 factory StaticUse.fieldInit(FieldElement element) { 243 factory StaticUse.fieldInit(FieldElement element) {
219 assert(invariant(element, element.isInstanceMember, 244 assert(invariant(element, element.isInstanceMember,
220 message: "Field init element $element must be an instance field.")); 245 message: "Field init element $element must be an instance field."));
221 return new StaticUse.internal(element, StaticUseKind.GENERAL); 246 return new StaticUse.internal(element, StaticUseKind.GENERAL);
(...skipping 24 matching lines...) Expand all
246 271
247 /// Unknown use of [element]. 272 /// Unknown use of [element].
248 @deprecated 273 @deprecated
249 factory StaticUse.foreignUse(Element element) { 274 factory StaticUse.foreignUse(Element element) {
250 return new StaticUse.internal(element, StaticUseKind.GENERAL); 275 return new StaticUse.internal(element, StaticUseKind.GENERAL);
251 } 276 }
252 277
253 bool operator ==(other) { 278 bool operator ==(other) {
254 if (identical(this, other)) return true; 279 if (identical(this, other)) return true;
255 if (other is! StaticUse) return false; 280 if (other is! StaticUse) return false;
256 return element == other.element && kind == other.kind; 281 return element == other.element && kind == other.kind && type == other.type;
257 } 282 }
258 283
259 String toString() => 'StaticUse($element,$kind)'; 284 String toString() => 'StaticUse($element,$kind,$type)';
260 } 285 }
261 286
262 enum TypeUseKind { 287 enum TypeUseKind {
263 IS_CHECK, 288 IS_CHECK,
264 AS_CAST, 289 AS_CAST,
265 CHECKED_MODE_CHECK, 290 CHECKED_MODE_CHECK,
266 CATCH_TYPE, 291 CATCH_TYPE,
267 TYPE_LITERAL, 292 TYPE_LITERAL,
268 INSTANTIATION, 293 INSTANTIATION,
269 } 294 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 } 335 }
311 336
312 bool operator ==(other) { 337 bool operator ==(other) {
313 if (identical(this, other)) return true; 338 if (identical(this, other)) return true;
314 if (other is! TypeUse) return false; 339 if (other is! TypeUse) return false;
315 return type == other.type && kind == other.kind; 340 return type == other.type && kind == other.kind;
316 } 341 }
317 342
318 String toString() => 'TypeUse($type,$kind)'; 343 String toString() => 'TypeUse($type,$kind)';
319 } 344 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698