Chromium Code Reviews| 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 aaf7baf8e48ad7012daff9dc7b3365697c78826a..49ea5718c2daae1a7edaab70ea9d17a43a6e59b9 100644 |
| --- a/pkg/compiler/lib/src/cps_ir/cps_ir_nodes.dart |
| +++ b/pkg/compiler/lib/src/cps_ir/cps_ir_nodes.dart |
| @@ -1446,15 +1446,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); |
| @@ -1466,7 +1468,7 @@ class CreateInstance extends Primitive { |
| void setParentPointers() { |
| _setParentsOnList(arguments, this); |
| - if (typeInformation != null) _setParentsOnList(typeInformation, this); |
| + if (typeInformation != null) typeInformation.parent = this; |
| } |
| } |
| @@ -1744,20 +1746,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 |
|
asgerf
2016/01/27 14:53:27
Incomplete sentence at the end.
|
| 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 |
| @@ -1772,6 +1799,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 { |
| @@ -2147,7 +2181,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) {} |
| @@ -2559,8 +2593,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); |
| } |
| @@ -2582,7 +2618,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) { |