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

Side by Side 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, 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 'cps_ir_nodes_sexpr.dart'; 8 import 'cps_ir_nodes_sexpr.dart';
9 import '../constants/values.dart' as values; 9 import '../constants/values.dart' as values;
10 import '../dart_types.dart' show DartType, InterfaceType, TypeVariableType; 10 import '../dart_types.dart' show DartType, InterfaceType, TypeVariableType;
(...skipping 1465 matching lines...) Expand 10 before | Expand all | Expand 10 after
1476 1476
1477 /// Initial values for the fields on the class. 1477 /// Initial values for the fields on the class.
1478 /// The order corresponds to the order of fields on the class. 1478 /// The order corresponds to the order of fields on the class.
1479 final List<Reference<Primitive>> arguments; 1479 final List<Reference<Primitive>> arguments;
1480 1480
1481 /// The runtime type information structure which contains the type arguments. 1481 /// The runtime type information structure which contains the type arguments.
1482 /// 1482 ///
1483 /// May be `null` to indicate that no type information is needed because the 1483 /// May be `null` to indicate that no type information is needed because the
1484 /// compiler determined that the type information for instances of this class 1484 /// compiler determined that the type information for instances of this class
1485 /// is not needed at runtime. 1485 /// is not needed at runtime.
1486 final List<Reference<Primitive>> typeInformation; 1486 final Reference<Primitive> typeInformation;
1487 1487
1488 final SourceInformation sourceInformation; 1488 final SourceInformation sourceInformation;
1489 1489
1490 CreateInstance(this.classElement, List<Primitive> arguments, 1490 CreateInstance(this.classElement, List<Primitive> arguments,
1491 List<Primitive> typeInformation, 1491 Primitive typeInformation,
1492 this.sourceInformation) 1492 this.sourceInformation)
1493 : this.arguments = _referenceList(arguments), 1493 : this.arguments = _referenceList(arguments),
1494 this.typeInformation = _referenceList(typeInformation); 1494 this.typeInformation = typeInformation == null
1495 ? null
1496 : new Reference<Primitive>(typeInformation);
1495 1497
1496 accept(Visitor visitor) => visitor.visitCreateInstance(this); 1498 accept(Visitor visitor) => visitor.visitCreateInstance(this);
1497 1499
1498 bool get hasValue => true; 1500 bool get hasValue => true;
1499 bool get isSafeForElimination => true; 1501 bool get isSafeForElimination => true;
1500 bool get isSafeForReordering => true; 1502 bool get isSafeForReordering => true;
1501 1503
1502 toString() => 'CreateInstance($classElement)'; 1504 toString() => 'CreateInstance($classElement)';
1503 1505
1504 void setParentPointers() { 1506 void setParentPointers() {
1505 _setParentsOnList(arguments, this); 1507 _setParentsOnList(arguments, this);
1506 if (typeInformation != null) _setParentsOnList(typeInformation, this); 1508 if (typeInformation != null) typeInformation.parent = this;
1507 } 1509 }
1508 } 1510 }
1509 1511
1510 /// Obtains the interceptor for the given value. This is a method table 1512 /// Obtains the interceptor for the given value. This is a method table
1511 /// corresponding to the Dart class of the value. 1513 /// corresponding to the Dart class of the value.
1512 /// 1514 ///
1513 /// All values are either intercepted or self-intercepted. The interceptor for 1515 /// All values are either intercepted or self-intercepted. The interceptor for
1514 /// an "intercepted value" is one of the subclasses of Interceptor. 1516 /// an "intercepted value" is one of the subclasses of Interceptor.
1515 /// The interceptor for a "self-intercepted value" is the value itself. 1517 /// The interceptor for a "self-intercepted value" is the value itself.
1516 /// 1518 ///
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
1791 1793
1792 bool get hasValue => true; 1794 bool get hasValue => true;
1793 bool get isSafeForElimination => true; 1795 bool get isSafeForElimination => true;
1794 bool get isSafeForReordering => true; 1796 bool get isSafeForReordering => true;
1795 1797
1796 void setParentPointers() { 1798 void setParentPointers() {
1797 target.parent = this; 1799 target.parent = this;
1798 } 1800 }
1799 } 1801 }
1800 1802
1801 /// Representation of a closed type (that is, a type without type variables). 1803 enum TypeExpressionKind {
1804 COMPLETE,
1805 INSTANCE
1806 }
1807
1808 /// Constructs a representation of a closed or ground-term type (that is, a type
1809 /// without type variables).
1802 /// 1810 ///
1803 /// The resulting value is constructed from [dartType] by replacing the type 1811 /// There are two forms:
1812 ///
1813 /// - COMPLETE: A complete form that is self contained, used for the values of
1814 /// type parameters and non-raw is-checks.
1815 ///
1816 /// - INSTANCE: A headless flat form for representing the sequence of values of
1817 /// the type parameters of an instance of a generic type.
1818 ///
1819 /// The COMPLETE form value is constructed from [dartType] by replacing the type
1804 /// variables with consecutive values from [arguments], in the order generated 1820 /// variables with consecutive values from [arguments], in the order generated
1805 /// by [DartType.forEachTypeVariable]. The type variables in [dartType] are 1821 /// by [DartType.forEachTypeVariable]. The type variables in [dartType] are
1806 /// treated as 'holes' in the term, which means that it must be ensured at 1822 /// treated as 'holes' in the term, which means that it must be ensured at
1807 /// construction, that duplicate occurences of a type variable in [dartType] 1823 /// construction, that duplicate occurences of a type variable in [dartType]
1808 /// are assigned the same value. 1824 /// are assigned the same value.
1825 ///
1826 /// The INSTANCE form is constructed as a list of [arguments]. This is the same
1827 /// as the COMPLETE form for the 'thisType', except the root term's type is
1828 /// missing; this is implicit as the raw type of instance.
1829 ///
1830 /// TODO(sra): The INSTANCE form requires the instance for full
1831 /// interpretation. I want to move to a representation where the instance type
1832 /// parameter vector is also a complete form. This will allow the
1809 class TypeExpression extends Primitive { 1833 class TypeExpression extends Primitive {
1834 final TypeExpressionKind kind;
1810 final DartType dartType; 1835 final DartType dartType;
1811 final List<Reference<Primitive>> arguments; 1836 final List<Reference<Primitive>> arguments;
1837 final bool isForInstance; // Expression on instance has 'headless' form.
1812 1838
1813 TypeExpression(this.dartType, 1839 TypeExpression(this.kind,
1814 [List<Primitive> arguments = const <Primitive>[]]) 1840 this.dartType,
1841 List<Primitive> arguments)
1815 : this.arguments = _referenceList(arguments); 1842 : this.arguments = _referenceList(arguments);
1816 1843
1817 @override 1844 @override
1818 accept(Visitor visitor) { 1845 accept(Visitor visitor) {
1819 return visitor.visitTypeExpression(this); 1846 return visitor.visitTypeExpression(this);
1820 } 1847 }
1821 1848
1822 bool get hasValue => true; 1849 bool get hasValue => true;
1823 bool get isSafeForElimination => true; 1850 bool get isSafeForElimination => true;
1824 bool get isSafeForReordering => true; 1851 bool get isSafeForReordering => true;
1825 1852
1826 void setParentPointers() { 1853 void setParentPointers() {
1827 _setParentsOnList(arguments, this); 1854 _setParentsOnList(arguments, this);
1828 } 1855 }
1856
1857 String get kindAsString {
1858 switch (kind) {
1859 case TypeExpressionKind.COMPLETE: return 'COMPLETE';
1860 case TypeExpressionKind.INSTANCE: return 'INSTANCE';
1861 }
1862 }
1829 } 1863 }
1830 1864
1831 class Await extends UnsafePrimitive { 1865 class Await extends UnsafePrimitive {
1832 final Reference<Primitive> input; 1866 final Reference<Primitive> input;
1833 1867
1834 Await(Primitive input) 1868 Await(Primitive input)
1835 : this.input = new Reference<Primitive>(input); 1869 : this.input = new Reference<Primitive>(input);
1836 1870
1837 @override 1871 @override
1838 accept(Visitor visitor) { 1872 accept(Visitor visitor) {
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
2194 processInterceptor(Interceptor node) {} 2228 processInterceptor(Interceptor node) {}
2195 visitInterceptor(Interceptor node) { 2229 visitInterceptor(Interceptor node) {
2196 processInterceptor(node); 2230 processInterceptor(node);
2197 processReference(node.input); 2231 processReference(node.input);
2198 } 2232 }
2199 2233
2200 processCreateInstance(CreateInstance node) {} 2234 processCreateInstance(CreateInstance node) {}
2201 visitCreateInstance(CreateInstance node) { 2235 visitCreateInstance(CreateInstance node) {
2202 processCreateInstance(node); 2236 processCreateInstance(node);
2203 node.arguments.forEach(processReference); 2237 node.arguments.forEach(processReference);
2204 node.typeInformation.forEach(processReference); 2238 if (node.typeInformation != null) processReference(node.typeInformation);
2205 } 2239 }
2206 2240
2207 processSetField(SetField node) {} 2241 processSetField(SetField node) {}
2208 visitSetField(SetField node) { 2242 visitSetField(SetField node) {
2209 processSetField(node); 2243 processSetField(node);
2210 processReference(node.object); 2244 processReference(node.object);
2211 processReference(node.value); 2245 processReference(node.value);
2212 } 2246 }
2213 2247
2214 processGetField(GetField node) {} 2248 processGetField(GetField node) {}
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
2606 Definition visitGetStatic(GetStatic node) { 2640 Definition visitGetStatic(GetStatic node) {
2607 return new GetStatic(node.element, node.sourceInformation); 2641 return new GetStatic(node.element, node.sourceInformation);
2608 } 2642 }
2609 2643
2610 Definition visitInterceptor(Interceptor node) { 2644 Definition visitInterceptor(Interceptor node) {
2611 return new Interceptor(getCopy(node.input), node.sourceInformation) 2645 return new Interceptor(getCopy(node.input), node.sourceInformation)
2612 ..interceptedClasses.addAll(node.interceptedClasses); 2646 ..interceptedClasses.addAll(node.interceptedClasses);
2613 } 2647 }
2614 2648
2615 Definition visitCreateInstance(CreateInstance node) { 2649 Definition visitCreateInstance(CreateInstance node) {
2616 return new CreateInstance(node.classElement, getList(node.arguments), 2650 return new CreateInstance(
2617 getList(node.typeInformation), 2651 node.classElement,
2652 getList(node.arguments),
2653 node.typeInformation == null ? null : getCopy(node.typeInformation),
2618 node.sourceInformation); 2654 node.sourceInformation);
2619 } 2655 }
2620 2656
2621 Definition visitGetField(GetField node) { 2657 Definition visitGetField(GetField node) {
2622 return new GetField(getCopy(node.object), node.field); 2658 return new GetField(getCopy(node.object), node.field);
2623 } 2659 }
2624 2660
2625 Definition visitCreateBox(CreateBox node) { 2661 Definition visitCreateBox(CreateBox node) {
2626 return new CreateBox(); 2662 return new CreateBox();
2627 } 2663 }
2628 2664
2629 Definition visitReifyRuntimeType(ReifyRuntimeType node) { 2665 Definition visitReifyRuntimeType(ReifyRuntimeType node) {
2630 return new ReifyRuntimeType(getCopy(node.value), node.sourceInformation); 2666 return new ReifyRuntimeType(getCopy(node.value), node.sourceInformation);
2631 } 2667 }
2632 2668
2633 Definition visitReadTypeVariable(ReadTypeVariable node) { 2669 Definition visitReadTypeVariable(ReadTypeVariable node) {
2634 return new ReadTypeVariable(node.variable, getCopy(node.target), 2670 return new ReadTypeVariable(node.variable, getCopy(node.target),
2635 node.sourceInformation); 2671 node.sourceInformation);
2636 } 2672 }
2637 2673
2638 Definition visitTypeExpression(TypeExpression node) { 2674 Definition visitTypeExpression(TypeExpression node) {
2639 return new TypeExpression(node.dartType, getList(node.arguments)); 2675 return new TypeExpression(
2676 node.kind, node.dartType, getList(node.arguments));
2640 } 2677 }
2641 2678
2642 Definition visitCreateInvocationMirror(CreateInvocationMirror node) { 2679 Definition visitCreateInvocationMirror(CreateInvocationMirror node) {
2643 return new CreateInvocationMirror(node.selector, getList(node.arguments)); 2680 return new CreateInvocationMirror(node.selector, getList(node.arguments));
2644 } 2681 }
2645 2682
2646 Definition visitTypeTest(TypeTest node) { 2683 Definition visitTypeTest(TypeTest node) {
2647 return new TypeTest(getCopy(node.value), node.dartType, 2684 return new TypeTest(getCopy(node.value), node.dartType,
2648 getList(node.typeArguments)); 2685 getList(node.typeArguments));
2649 } 2686 }
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
2841 plug(new Branch.loose(_definitions.getCopy(node.condition), 2878 plug(new Branch.loose(_definitions.getCopy(node.condition),
2842 _copies[node.trueContinuation.definition], 2879 _copies[node.trueContinuation.definition],
2843 _copies[node.falseContinuation.definition]) 2880 _copies[node.falseContinuation.definition])
2844 ..isStrictCheck = node.isStrictCheck); 2881 ..isStrictCheck = node.isStrictCheck);
2845 } 2882 }
2846 2883
2847 visitUnreachable(Unreachable node) { 2884 visitUnreachable(Unreachable node) {
2848 plug(new Unreachable()); 2885 plug(new Unreachable());
2849 } 2886 }
2850 } 2887 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698