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

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

Issue 2392943003: Handle const constructor invocation in kernel_impact. (Closed)
Patch Set: Updated cf. comments. 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
« no previous file with comments | « pkg/compiler/lib/src/ssa/kernel_impact.dart ('k') | pkg/compiler/lib/src/universe/world_builder.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 edd8cd7a13163bc68d32806cbb150ba0171e1b9b..fad9d905e8c6fec7a4bb8f80693538449f597fc5 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,14 @@ 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])
: 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 +214,28 @@ 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);
+ }
+
+ /// 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 +280,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 {
« no previous file with comments | « pkg/compiler/lib/src/ssa/kernel_impact.dart ('k') | pkg/compiler/lib/src/universe/world_builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698