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

Unified 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 side-by-side diff with in-line comments
Download patch
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 edd8cd7a13163bc68d32806cbb150ba0171e1b9b..8dbe490b1be97ddacfe85011d8cd2c6db2195c27 100644
--- a/pkg/compiler/lib/src/universe/use.dart
+++ b/pkg/compiler/lib/src/universe/use.dart
@@ -71,6 +71,8 @@ enum StaticUseKind {
FIELD_GET,
FIELD_SET,
CLOSURE,
+ CONSTRUCTOR_INVOKE,
+ CONST_CONSTRUCTOR_INVOKE,
}
/// Statically known use of an [Element].
@@ -80,11 +82,13 @@ class StaticUse {
final Element element;
final StaticUseKind kind;
final int hashCode;
+ final DartType type;
- StaticUse.internal(Element element, StaticUseKind kind)
+ 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.
: this.element = element,
this.kind = kind,
- this.hashCode = Hashing.objectHash(element, Hashing.objectHash(kind)) {
+ this.type = type,
+ this.hashCode = Hashing.objectsHash(element, kind, type) {
assert(invariant(element, element.isDeclaration,
message: "Static use element $element must be "
"the declaration element."));
@@ -209,6 +213,27 @@ class StaticUse {
return new StaticUse.internal(element, StaticUseKind.GENERAL);
}
+ /// Constructor invocation of [element] with the given [callStructure] on
+ /// [type].
+ factory StaticUse.typedConstructorInvoke(
+ ConstructorElement element, CallStructure callStructure, DartType type) {
+ assert(invariant(element, type != null,
+ message: "No type provided for constructor invocation."));
+ // TODO(johnniwinther): Use the [callStructure].
+ return new StaticUse.internal(element, StaticUseKind.CONSTRUCTOR_INVOKE, type);
Harry Terkelsen 2016/10/07 15:53:21 long line
Johnni Winther 2016/10/10 09:58:12 Done.
+ }
+
+ /// Constant constructor invocation of [element] with the given
+ /// [callStructure] on [type].
+ factory StaticUse.constConstructorInvoke(
+ ConstructorElement element, CallStructure callStructure, DartType type) {
+ assert(invariant(element, type != null,
+ message: "No type provided for constructor invocation."));
+ // TODO(johnniwinther): Use the [callStructure].
+ return new StaticUse.internal(
+ element, StaticUseKind.CONST_CONSTRUCTOR_INVOKE, type);
+ }
+
/// Constructor redirection to [element].
factory StaticUse.constructorRedirect(ConstructorElement element) {
return new StaticUse.internal(element, StaticUseKind.GENERAL);
@@ -253,10 +278,10 @@ class StaticUse {
bool operator ==(other) {
if (identical(this, other)) return true;
if (other is! StaticUse) return false;
- return element == other.element && kind == other.kind;
+ return element == other.element && kind == other.kind && type == other.type;
}
- String toString() => 'StaticUse($element,$kind)';
+ String toString() => 'StaticUse($element,$kind,$type)';
}
enum TypeUseKind {

Powered by Google App Engine
This is Rietveld 408576698