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

Side by Side Diff: pkg/compiler/lib/src/cps_ir/cps_ir_nodes.dart

Issue 1637843002: typeInformation in CreateInstance is a kind of TypeExpression (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 library dart2js.ir_nodes; 4 library dart2js.ir_nodes;
5 5
6 import 'dart:collection'; 6 import 'dart:collection';
7 import 'cps_fragment.dart' show CpsFragment; 7 import 'cps_fragment.dart' show CpsFragment;
8 import '../constants/values.dart' as values; 8 import '../constants/values.dart' as values;
9 import '../dart_types.dart' show DartType, InterfaceType, TypeVariableType; 9 import '../dart_types.dart' show DartType, InterfaceType, TypeVariableType;
10 import '../elements/elements.dart'; 10 import '../elements/elements.dart';
(...skipping 1428 matching lines...) Expand 10 before | Expand all | Expand 10 after
1439 1439
1440 /// Initial values for the fields on the class. 1440 /// Initial values for the fields on the class.
1441 /// The order corresponds to the order of fields on the class. 1441 /// The order corresponds to the order of fields on the class.
1442 final List<Reference<Primitive>> arguments; 1442 final List<Reference<Primitive>> arguments;
1443 1443
1444 /// The runtime type information structure which contains the type arguments. 1444 /// The runtime type information structure which contains the type arguments.
1445 /// 1445 ///
1446 /// May be `null` to indicate that no type information is needed because the 1446 /// May be `null` to indicate that no type information is needed because the
1447 /// compiler determined that the type information for instances of this class 1447 /// compiler determined that the type information for instances of this class
1448 /// is not needed at runtime. 1448 /// is not needed at runtime.
1449 final List<Reference<Primitive>> typeInformation; 1449 final Reference<Primitive> typeInformation;
1450 1450
1451 final SourceInformation sourceInformation; 1451 final SourceInformation sourceInformation;
1452 1452
1453 CreateInstance(this.classElement, List<Primitive> arguments, 1453 CreateInstance(this.classElement, List<Primitive> arguments,
1454 List<Primitive> typeInformation, 1454 Primitive typeInformation,
1455 this.sourceInformation) 1455 this.sourceInformation)
1456 : this.arguments = _referenceList(arguments), 1456 : this.arguments = _referenceList(arguments),
1457 this.typeInformation = _referenceList(typeInformation); 1457 this.typeInformation = typeInformation == null
1458 ? null
1459 : new Reference<Primitive>(typeInformation);
1458 1460
1459 accept(Visitor visitor) => visitor.visitCreateInstance(this); 1461 accept(Visitor visitor) => visitor.visitCreateInstance(this);
1460 1462
1461 bool get hasValue => true; 1463 bool get hasValue => true;
1462 bool get isSafeForElimination => true; 1464 bool get isSafeForElimination => true;
1463 bool get isSafeForReordering => true; 1465 bool get isSafeForReordering => true;
1464 1466
1465 toString() => 'CreateInstance($classElement)'; 1467 toString() => 'CreateInstance($classElement)';
1466 1468
1467 void setParentPointers() { 1469 void setParentPointers() {
1468 _setParentsOnList(arguments, this); 1470 _setParentsOnList(arguments, this);
1469 if (typeInformation != null) _setParentsOnList(typeInformation, this); 1471 if (typeInformation != null) typeInformation.parent = this;
1470 } 1472 }
1471 } 1473 }
1472 1474
1473 /// Obtains the interceptor for the given value. This is a method table 1475 /// Obtains the interceptor for the given value. This is a method table
1474 /// corresponding to the Dart class of the value. 1476 /// corresponding to the Dart class of the value.
1475 /// 1477 ///
1476 /// All values are either intercepted or self-intercepted. The interceptor for 1478 /// All values are either intercepted or self-intercepted. The interceptor for
1477 /// an "intercepted value" is one of the subclasses of Interceptor. 1479 /// an "intercepted value" is one of the subclasses of Interceptor.
1478 /// The interceptor for a "self-intercepted value" is the value itself. 1480 /// The interceptor for a "self-intercepted value" is the value itself.
1479 /// 1481 ///
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
1737 1739
1738 bool get hasValue => true; 1740 bool get hasValue => true;
1739 bool get isSafeForElimination => true; 1741 bool get isSafeForElimination => true;
1740 bool get isSafeForReordering => true; 1742 bool get isSafeForReordering => true;
1741 1743
1742 void setParentPointers() { 1744 void setParentPointers() {
1743 target.parent = this; 1745 target.parent = this;
1744 } 1746 }
1745 } 1747 }
1746 1748
1747 /// Representation of a closed type (that is, a type without type variables). 1749 enum TypeExpressionKind {
1750 COMPLETE,
1751 INSTANCE
1752 }
1753
1754 /// Constructs a representation of a closed or ground-term type (that is, a type
1755 /// without type variables).
1748 /// 1756 ///
1749 /// The resulting value is constructed from [dartType] by replacing the type 1757 /// There are two forms:
1758 ///
1759 /// - COMPLETE: A complete form that is self contained, used for the values of
1760 /// type parameters and non-raw is-checks.
1761 ///
1762 /// - INSTANCE: A headless flat form for representing the sequence of values of
1763 /// the type parameters of an instance of a generic type.
1764 ///
1765 /// The COMPLETE form value is constructed from [dartType] by replacing the type
1750 /// variables with consecutive values from [arguments], in the order generated 1766 /// variables with consecutive values from [arguments], in the order generated
1751 /// by [DartType.forEachTypeVariable]. The type variables in [dartType] are 1767 /// by [DartType.forEachTypeVariable]. The type variables in [dartType] are
1752 /// treated as 'holes' in the term, which means that it must be ensured at 1768 /// treated as 'holes' in the term, which means that it must be ensured at
1753 /// construction, that duplicate occurences of a type variable in [dartType] 1769 /// construction, that duplicate occurences of a type variable in [dartType]
1754 /// are assigned the same value. 1770 /// are assigned the same value.
1771 ///
1772 /// The INSTANCE form is constructed as a list of [arguments]. This is the same
1773 /// as the COMPLETE form for the 'thisType', except the root term's type is
1774 /// missing; this is implicit as the raw type of instance.
1775 ///
1776 /// TODO(sra): The INSTANCE form requires the instance for full
1777 /// interpretation. I want to move to a representation where the instance type
1778 /// parameter vector is also a complete form. This will allow the
asgerf 2016/01/27 14:53:27 Incomplete sentence at the end.
1755 class TypeExpression extends Primitive { 1779 class TypeExpression extends Primitive {
1780 final TypeExpressionKind kind;
1756 final DartType dartType; 1781 final DartType dartType;
1757 final List<Reference<Primitive>> arguments; 1782 final List<Reference<Primitive>> arguments;
1783 final bool isForInstance; // Expression on instance has 'headless' form.
1758 1784
1759 TypeExpression(this.dartType, 1785 TypeExpression(this.kind,
1760 [List<Primitive> arguments = const <Primitive>[]]) 1786 this.dartType,
1787 List<Primitive> arguments)
1761 : this.arguments = _referenceList(arguments); 1788 : this.arguments = _referenceList(arguments);
1762 1789
1763 @override 1790 @override
1764 accept(Visitor visitor) { 1791 accept(Visitor visitor) {
1765 return visitor.visitTypeExpression(this); 1792 return visitor.visitTypeExpression(this);
1766 } 1793 }
1767 1794
1768 bool get hasValue => true; 1795 bool get hasValue => true;
1769 bool get isSafeForElimination => true; 1796 bool get isSafeForElimination => true;
1770 bool get isSafeForReordering => true; 1797 bool get isSafeForReordering => true;
1771 1798
1772 void setParentPointers() { 1799 void setParentPointers() {
1773 _setParentsOnList(arguments, this); 1800 _setParentsOnList(arguments, this);
1774 } 1801 }
1802
1803 String get kindAsString {
1804 switch (kind) {
1805 case TypeExpressionKind.COMPLETE: return 'COMPLETE';
1806 case TypeExpressionKind.INSTANCE: return 'INSTANCE';
1807 }
1808 }
1775 } 1809 }
1776 1810
1777 class Await extends UnsafePrimitive { 1811 class Await extends UnsafePrimitive {
1778 final Reference<Primitive> input; 1812 final Reference<Primitive> input;
1779 1813
1780 Await(Primitive input) 1814 Await(Primitive input)
1781 : this.input = new Reference<Primitive>(input); 1815 : this.input = new Reference<Primitive>(input);
1782 1816
1783 @override 1817 @override
1784 accept(Visitor visitor) { 1818 accept(Visitor visitor) {
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
2140 processInterceptor(Interceptor node) {} 2174 processInterceptor(Interceptor node) {}
2141 visitInterceptor(Interceptor node) { 2175 visitInterceptor(Interceptor node) {
2142 processInterceptor(node); 2176 processInterceptor(node);
2143 processReference(node.input); 2177 processReference(node.input);
2144 } 2178 }
2145 2179
2146 processCreateInstance(CreateInstance node) {} 2180 processCreateInstance(CreateInstance node) {}
2147 visitCreateInstance(CreateInstance node) { 2181 visitCreateInstance(CreateInstance node) {
2148 processCreateInstance(node); 2182 processCreateInstance(node);
2149 node.arguments.forEach(processReference); 2183 node.arguments.forEach(processReference);
2150 node.typeInformation.forEach(processReference); 2184 if (node.typeInformation != null) processReference(node.typeInformation);
2151 } 2185 }
2152 2186
2153 processSetField(SetField node) {} 2187 processSetField(SetField node) {}
2154 visitSetField(SetField node) { 2188 visitSetField(SetField node) {
2155 processSetField(node); 2189 processSetField(node);
2156 processReference(node.object); 2190 processReference(node.object);
2157 processReference(node.value); 2191 processReference(node.value);
2158 } 2192 }
2159 2193
2160 processGetField(GetField node) {} 2194 processGetField(GetField node) {}
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
2552 Definition visitGetStatic(GetStatic node) { 2586 Definition visitGetStatic(GetStatic node) {
2553 return new GetStatic(node.element, node.sourceInformation); 2587 return new GetStatic(node.element, node.sourceInformation);
2554 } 2588 }
2555 2589
2556 Definition visitInterceptor(Interceptor node) { 2590 Definition visitInterceptor(Interceptor node) {
2557 return new Interceptor(getCopy(node.input), node.sourceInformation) 2591 return new Interceptor(getCopy(node.input), node.sourceInformation)
2558 ..interceptedClasses.addAll(node.interceptedClasses); 2592 ..interceptedClasses.addAll(node.interceptedClasses);
2559 } 2593 }
2560 2594
2561 Definition visitCreateInstance(CreateInstance node) { 2595 Definition visitCreateInstance(CreateInstance node) {
2562 return new CreateInstance(node.classElement, getList(node.arguments), 2596 return new CreateInstance(
2563 getList(node.typeInformation), 2597 node.classElement,
2598 getList(node.arguments),
2599 node.typeInformation == null ? null : getCopy(node.typeInformation),
2564 node.sourceInformation); 2600 node.sourceInformation);
2565 } 2601 }
2566 2602
2567 Definition visitGetField(GetField node) { 2603 Definition visitGetField(GetField node) {
2568 return new GetField(getCopy(node.object), node.field); 2604 return new GetField(getCopy(node.object), node.field);
2569 } 2605 }
2570 2606
2571 Definition visitCreateBox(CreateBox node) { 2607 Definition visitCreateBox(CreateBox node) {
2572 return new CreateBox(); 2608 return new CreateBox();
2573 } 2609 }
2574 2610
2575 Definition visitReifyRuntimeType(ReifyRuntimeType node) { 2611 Definition visitReifyRuntimeType(ReifyRuntimeType node) {
2576 return new ReifyRuntimeType(getCopy(node.value), node.sourceInformation); 2612 return new ReifyRuntimeType(getCopy(node.value), node.sourceInformation);
2577 } 2613 }
2578 2614
2579 Definition visitReadTypeVariable(ReadTypeVariable node) { 2615 Definition visitReadTypeVariable(ReadTypeVariable node) {
2580 return new ReadTypeVariable(node.variable, getCopy(node.target), 2616 return new ReadTypeVariable(node.variable, getCopy(node.target),
2581 node.sourceInformation); 2617 node.sourceInformation);
2582 } 2618 }
2583 2619
2584 Definition visitTypeExpression(TypeExpression node) { 2620 Definition visitTypeExpression(TypeExpression node) {
2585 return new TypeExpression(node.dartType, getList(node.arguments)); 2621 return new TypeExpression(
2622 node.kind, node.dartType, getList(node.arguments));
2586 } 2623 }
2587 2624
2588 Definition visitCreateInvocationMirror(CreateInvocationMirror node) { 2625 Definition visitCreateInvocationMirror(CreateInvocationMirror node) {
2589 return new CreateInvocationMirror(node.selector, getList(node.arguments)); 2626 return new CreateInvocationMirror(node.selector, getList(node.arguments));
2590 } 2627 }
2591 2628
2592 Definition visitTypeTest(TypeTest node) { 2629 Definition visitTypeTest(TypeTest node) {
2593 return new TypeTest(getCopy(node.value), node.dartType, 2630 return new TypeTest(getCopy(node.value), node.dartType,
2594 getList(node.typeArguments)); 2631 getList(node.typeArguments));
2595 } 2632 }
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
2787 plug(new Branch.loose(_definitions.getCopy(node.condition), 2824 plug(new Branch.loose(_definitions.getCopy(node.condition),
2788 _copies[node.trueContinuation.definition], 2825 _copies[node.trueContinuation.definition],
2789 _copies[node.falseContinuation.definition]) 2826 _copies[node.falseContinuation.definition])
2790 ..isStrictCheck = node.isStrictCheck); 2827 ..isStrictCheck = node.isStrictCheck);
2791 } 2828 }
2792 2829
2793 visitUnreachable(Unreachable node) { 2830 visitUnreachable(Unreachable node) {
2794 plug(new Unreachable()); 2831 plug(new Unreachable());
2795 } 2832 }
2796 } 2833 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/cps_ir/cps_ir_builder_task.dart ('k') | pkg/compiler/lib/src/cps_ir/cps_ir_nodes_sexpr.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698