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

Unified Diff: pkg/compiler/lib/src/cps_ir/cps_ir_nodes.dart

Issue 1642493002: Add type info to JSArray. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: array changes Created 4 years, 11 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/cps_ir/cps_ir_nodes.dart
diff --git a/pkg/compiler/lib/src/cps_ir/cps_ir_nodes.dart b/pkg/compiler/lib/src/cps_ir/cps_ir_nodes.dart
index 44d822343cb9a2f47f10005b0471acf056483b20..c179799cef3bcc2722812e2e449955cb246aff4a 100644
--- a/pkg/compiler/lib/src/cps_ir/cps_ir_nodes.dart
+++ b/pkg/compiler/lib/src/cps_ir/cps_ir_nodes.dart
@@ -1483,15 +1483,17 @@ class CreateInstance extends Primitive {
/// May be `null` to indicate that no type information is needed because the
/// compiler determined that the type information for instances of this class
/// is not needed at runtime.
- final List<Reference<Primitive>> typeInformation;
+ final Reference<Primitive> typeInformation;
final SourceInformation sourceInformation;
CreateInstance(this.classElement, List<Primitive> arguments,
- List<Primitive> typeInformation,
+ Primitive typeInformation,
this.sourceInformation)
: this.arguments = _referenceList(arguments),
- this.typeInformation = _referenceList(typeInformation);
+ this.typeInformation = typeInformation == null
+ ? null
+ : new Reference<Primitive>(typeInformation);
accept(Visitor visitor) => visitor.visitCreateInstance(this);
@@ -1503,7 +1505,7 @@ class CreateInstance extends Primitive {
void setParentPointers() {
_setParentsOnList(arguments, this);
- if (typeInformation != null) _setParentsOnList(typeInformation, this);
+ if (typeInformation != null) typeInformation.parent = this;
}
}
@@ -1798,20 +1800,45 @@ class ReadTypeVariable extends Primitive {
}
}
-/// Representation of a closed type (that is, a type without type variables).
+enum TypeExpressionKind {
+ COMPLETE,
+ INSTANCE
+}
+
+/// Constructs a representation of a closed or ground-term type (that is, a type
+/// without type variables).
+///
+/// There are two forms:
///
-/// The resulting value is constructed from [dartType] by replacing the type
+/// - COMPLETE: A complete form that is self contained, used for the values of
+/// type parameters and non-raw is-checks.
+///
+/// - INSTANCE: A headless flat form for representing the sequence of values of
+/// the type parameters of an instance of a generic type.
+///
+/// The COMPLETE form value is constructed from [dartType] by replacing the type
/// variables with consecutive values from [arguments], in the order generated
/// by [DartType.forEachTypeVariable]. The type variables in [dartType] are
/// treated as 'holes' in the term, which means that it must be ensured at
/// construction, that duplicate occurences of a type variable in [dartType]
/// are assigned the same value.
+///
+/// The INSTANCE form is constructed as a list of [arguments]. This is the same
+/// as the COMPLETE form for the 'thisType', except the root term's type is
+/// missing; this is implicit as the raw type of instance.
+///
+/// TODO(sra): The INSTANCE form requires the instance for full
+/// interpretation. I want to move to a representation where the instance type
+/// parameter vector is also a complete form. This will allow the
class TypeExpression extends Primitive {
+ final TypeExpressionKind kind;
final DartType dartType;
final List<Reference<Primitive>> arguments;
+ final bool isForInstance; // Expression on instance has 'headless' form.
- TypeExpression(this.dartType,
- [List<Primitive> arguments = const <Primitive>[]])
+ TypeExpression(this.kind,
+ this.dartType,
+ List<Primitive> arguments)
: this.arguments = _referenceList(arguments);
@override
@@ -1826,6 +1853,13 @@ class TypeExpression extends Primitive {
void setParentPointers() {
_setParentsOnList(arguments, this);
}
+
+ String get kindAsString {
+ switch (kind) {
+ case TypeExpressionKind.COMPLETE: return 'COMPLETE';
+ case TypeExpressionKind.INSTANCE: return 'INSTANCE';
+ }
+ }
}
class Await extends UnsafePrimitive {
@@ -2201,7 +2235,7 @@ class DeepRecursiveVisitor implements Visitor {
visitCreateInstance(CreateInstance node) {
processCreateInstance(node);
node.arguments.forEach(processReference);
- node.typeInformation.forEach(processReference);
+ if (node.typeInformation != null) processReference(node.typeInformation);
}
processSetField(SetField node) {}
@@ -2613,8 +2647,10 @@ class DefinitionCopyingVisitor extends Visitor<Definition> {
}
Definition visitCreateInstance(CreateInstance node) {
- return new CreateInstance(node.classElement, getList(node.arguments),
- getList(node.typeInformation),
+ return new CreateInstance(
+ node.classElement,
+ getList(node.arguments),
+ node.typeInformation == null ? null : getCopy(node.typeInformation),
node.sourceInformation);
}
@@ -2636,7 +2672,8 @@ class DefinitionCopyingVisitor extends Visitor<Definition> {
}
Definition visitTypeExpression(TypeExpression node) {
- return new TypeExpression(node.dartType, getList(node.arguments));
+ return new TypeExpression(
+ node.kind, node.dartType, getList(node.arguments));
}
Definition visitCreateInvocationMirror(CreateInvocationMirror node) {

Powered by Google App Engine
This is Rietveld 408576698