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

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

Issue 1435853002: Register closures using StaticUse. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Updated cf. comment Created 5 years, 1 month 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 defined `uses`. A `use` is a single impact of the world, for 5 /// This library defined `uses`. A `use` is a single impact of the world, for
6 /// instance an invocation of a top level function or a call to the `foo()` 6 /// instance an invocation of a top level function or a call to the `foo()`
7 /// method on an unknown class. 7 /// method on an unknown class.
8 library dart2js.universe.use; 8 library dart2js.universe.use;
9 9
10 import '../closure.dart' show 10 import '../closure.dart' show
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 65
66 String toString() => '$selector,$mask'; 66 String toString() => '$selector,$mask';
67 } 67 }
68 68
69 enum StaticUseKind { 69 enum StaticUseKind {
70 GENERAL, 70 GENERAL,
71 STATIC_TEAR_OFF, 71 STATIC_TEAR_OFF,
72 SUPER_TEAR_OFF, 72 SUPER_TEAR_OFF,
73 FIELD_GET, 73 FIELD_GET,
74 FIELD_SET, 74 FIELD_SET,
75 CLOSURE,
75 } 76 }
76 77
77 /// Statically known use of an [Element]. 78 /// Statically known use of an [Element].
78 // TODO(johnniwinther): Create backend-specific implementations with better 79 // TODO(johnniwinther): Create backend-specific implementations with better
79 // invariants. 80 // invariants.
80 class StaticUse { 81 class StaticUse {
81 final Element element; 82 final Element element;
82 final StaticUseKind kind; 83 final StaticUseKind kind;
83 final int hashCode; 84 final int hashCode;
84 85
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 226
226 /// Write access of an instance field or boxed field [element]. 227 /// Write access of an instance field or boxed field [element].
227 factory StaticUse.fieldSet(Element element) { 228 factory StaticUse.fieldSet(Element element) {
228 assert(invariant(element, 229 assert(invariant(element,
229 element.isInstanceMember || element is BoxFieldElement, 230 element.isInstanceMember || element is BoxFieldElement,
230 message: "Field init element $element must be an instance " 231 message: "Field init element $element must be an instance "
231 "or boxed field.")); 232 "or boxed field."));
232 return new StaticUse._(element, StaticUseKind.FIELD_SET); 233 return new StaticUse._(element, StaticUseKind.FIELD_SET);
233 } 234 }
234 235
236 /// Read of a local function [element].
237 factory StaticUse.closure(LocalFunctionElement element) {
238 return new StaticUse._(element, StaticUseKind.CLOSURE);
239 }
240
235 /// Unknown use of [element]. 241 /// Unknown use of [element].
236 @deprecated 242 @deprecated
237 factory StaticUse.foreignUse(Element element) { 243 factory StaticUse.foreignUse(Element element) {
238 return new StaticUse._(element, StaticUseKind.GENERAL); 244 return new StaticUse._(element, StaticUseKind.GENERAL);
239 } 245 }
240 246
241 bool operator ==(other) { 247 bool operator ==(other) {
242 if (identical(this, other)) return true; 248 if (identical(this, other)) return true;
243 if (other is! StaticUse) return false; 249 if (other is! StaticUse) return false;
244 return element == other.element && 250 return element == other.element &&
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 306
301 bool operator ==(other) { 307 bool operator ==(other) {
302 if (identical(this, other)) return true; 308 if (identical(this, other)) return true;
303 if (other is! TypeUse) return false; 309 if (other is! TypeUse) return false;
304 return type == other.type && 310 return type == other.type &&
305 kind == other.kind; 311 kind == other.kind;
306 } 312 }
307 313
308 String toString() => 'TypeUse($type,$kind)'; 314 String toString() => 'TypeUse($type,$kind)';
309 } 315 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/universe/universe.dart ('k') | pkg/compiler/lib/src/universe/world_impact.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698