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

Unified Diff: pkg/compiler/lib/src/universe/use.dart

Issue 1408383006: Rename UniverseSelector to DynamicUse and move it to use.dart (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Updated cf. comments. 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/universe/use.dart
diff --git a/pkg/compiler/lib/src/universe/use.dart b/pkg/compiler/lib/src/universe/use.dart
index a398ad99a04ea03d9c5b80c2afa3d0c2501fdd56..b393089b9088d99d0977a1de7c838be3ed8a6cd6 100644
--- a/pkg/compiler/lib/src/universe/use.dart
+++ b/pkg/compiler/lib/src/universe/use.dart
@@ -2,17 +2,68 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+/// This library defined `uses`. A `use` is a single impact of the world, for
+/// instance an invocation of a top level function or a call to the `foo()`
+/// method on an unknown class.
library dart2js.universe.use;
import '../closure.dart' show
BoxFieldElement;
import '../common.dart';
import '../elements/elements.dart';
+import '../world.dart' show
+ ClassWorld;
import '../util/util.dart' show
Hashing;
import 'call_structure.dart' show
CallStructure;
+import 'selector.dart' show
+ Selector;
+import 'universe.dart' show
+ ReceiverConstraint;
+
+
+enum DynamicUseKind {
+ INVOKE,
+ GET,
+ SET,
+}
+
+/// The use of a dynamic property. [selector] defined the name and kind of the
+/// property and [mask] defines the known constraint for the object on which
+/// the property is accessed.
+class DynamicUse {
+ final Selector selector;
+ final ReceiverConstraint mask;
+
+ DynamicUse(this.selector, this.mask);
+
+ bool appliesUnnamed(Element element, ClassWorld world) {
+ return selector.appliesUnnamed(element, world) &&
+ (mask == null || mask.canHit(element, selector, world));
+ }
+
+ DynamicUseKind get kind {
+ if (selector.isGetter) {
+ return DynamicUseKind.GET;
+ } else if (selector.isSetter) {
+ return DynamicUseKind.SET;
+ } else {
+ return DynamicUseKind.INVOKE;
+ }
+ }
+
+ int get hashCode => selector.hashCode * 13 + mask.hashCode * 17;
+
+ bool operator ==(other) {
+ if (identical(this, other)) return true;
+ if (other is! DynamicUse) return false;
+ return selector == other.selector && mask == other.mask;
+ }
+
+ String toString() => '$selector,$mask';
+}
enum StaticUseKind {
GENERAL,
« 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