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

Side by Side Diff: pkg/compiler/lib/src/tree_ir/tree_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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 4
5 library tree_ir_nodes; 5 library tree_ir_nodes;
6 6
7 import '../constants/values.dart' as values; 7 import '../constants/values.dart' as values;
8 import '../dart_types.dart' show DartType, InterfaceType, TypeVariableType; 8 import '../dart_types.dart' show DartType, InterfaceType, TypeVariableType;
9 import '../elements/elements.dart'; 9 import '../elements/elements.dart';
10 import '../io/source_information.dart' show SourceInformation; 10 import '../io/source_information.dart' show SourceInformation;
11 import '../types/types.dart' show TypeMask; 11 import '../types/types.dart' show TypeMask;
12 import '../universe/selector.dart' show Selector; 12 import '../universe/selector.dart' show Selector;
13 13
14 import '../cps_ir/builtin_operator.dart'; 14 import '../cps_ir/builtin_operator.dart';
15 export '../cps_ir/builtin_operator.dart'; 15 export '../cps_ir/builtin_operator.dart';
16 import '../cps_ir/cps_ir_nodes.dart' show TypeExpressionKind;
17 export '../cps_ir/cps_ir_nodes.dart' show TypeExpressionKind;
16 18
17 // These imports are only used for the JavaScript specific nodes. If we want to 19 // These imports are only used for the JavaScript specific nodes. If we want to
18 // support more than one native backend, we should probably create better 20 // support more than one native backend, we should probably create better
19 // abstractions for native code and its type and effect system. 21 // abstractions for native code and its type and effect system.
20 import '../js/js.dart' as js show Template; 22 import '../js/js.dart' as js show Template;
21 import '../native/native.dart' as native show NativeBehavior; 23 import '../native/native.dart' as native show NativeBehavior;
22 import '../types/types.dart' as types show TypeMask; 24 import '../types/types.dart' as types show TypeMask;
23 25
24 // The Tree language is the target of translation out of the CPS-based IR. 26 // The Tree language is the target of translation out of the CPS-based IR.
25 // 27 //
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 int writeCount = 0; 109 int writeCount = 0;
108 110
109 /// True if an inner JS function might access this variable through a 111 /// True if an inner JS function might access this variable through a
110 /// [ForeignCode] node. 112 /// [ForeignCode] node.
111 bool isCaptured = false; 113 bool isCaptured = false;
112 114
113 Variable(this.host, this.element) { 115 Variable(this.host, this.element) {
114 assert(host != null); 116 assert(host != null);
115 } 117 }
116 118
117 String toString() => element == null ? 'Variable' : element.toString(); 119 String toString() =>
120 element == null ? 'Variable.${hashCode}' : element.toString();
118 } 121 }
119 122
120 /// Read the value of a variable. 123 /// Read the value of a variable.
121 class VariableUse extends Expression { 124 class VariableUse extends Expression {
122 Variable variable; 125 Variable variable;
123 126
124 /// Creates a use of [variable] and updates its `readCount`. 127 /// Creates a use of [variable] and updates its `readCount`.
125 VariableUse(this.variable) { 128 VariableUse(this.variable) {
126 variable.readCount++; 129 variable.readCount++;
127 } 130 }
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after
662 } 665 }
663 666
664 class CreateBox extends Expression { 667 class CreateBox extends Expression {
665 accept(ExpressionVisitor visitor) => visitor.visitCreateBox(this); 668 accept(ExpressionVisitor visitor) => visitor.visitCreateBox(this);
666 accept1(ExpressionVisitor1 visitor, arg) => visitor.visitCreateBox(this, arg); 669 accept1(ExpressionVisitor1 visitor, arg) => visitor.visitCreateBox(this, arg);
667 } 670 }
668 671
669 class CreateInstance extends Expression { 672 class CreateInstance extends Expression {
670 ClassElement classElement; 673 ClassElement classElement;
671 List<Expression> arguments; 674 List<Expression> arguments;
672 List<Expression> typeInformation; 675 Expression typeInformation;
673 SourceInformation sourceInformation; 676 SourceInformation sourceInformation;
674 677
675 CreateInstance(this.classElement, this.arguments, 678 CreateInstance(this.classElement, this.arguments,
676 this.typeInformation, this.sourceInformation); 679 this.typeInformation, this.sourceInformation);
677 680
678 accept(ExpressionVisitor visitor) => visitor.visitCreateInstance(this); 681 accept(ExpressionVisitor visitor) => visitor.visitCreateInstance(this);
679 accept1(ExpressionVisitor1 visitor, arg) { 682 accept1(ExpressionVisitor1 visitor, arg) {
680 return visitor.visitCreateInstance(this, arg); 683 return visitor.visitCreateInstance(this, arg);
681 } 684 }
682 } 685 }
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
895 Statement get next => null; 898 Statement get next => null;
896 899
897 @override 900 @override
898 void set next(Statement s) => throw 'UNREACHABLE'; 901 void set next(Statement s) => throw 'UNREACHABLE';
899 } 902 }
900 903
901 /// Denotes the internal representation of [dartType], where all type variables 904 /// Denotes the internal representation of [dartType], where all type variables
902 /// are replaced by the values in [arguments]. 905 /// are replaced by the values in [arguments].
903 /// (See documentation on the TypeExpression CPS node for more details.) 906 /// (See documentation on the TypeExpression CPS node for more details.)
904 class TypeExpression extends Expression { 907 class TypeExpression extends Expression {
908 final TypeExpressionKind kind;
905 final DartType dartType; 909 final DartType dartType;
906 final List<Expression> arguments; 910 final List<Expression> arguments;
907 911
908 TypeExpression(this.dartType, this.arguments); 912 TypeExpression(this.kind, this.dartType, this.arguments);
909 913
910 accept(ExpressionVisitor visitor) { 914 accept(ExpressionVisitor visitor) {
911 return visitor.visitTypeExpression(this); 915 return visitor.visitTypeExpression(this);
912 } 916 }
913 917
914 accept1(ExpressionVisitor1 visitor, arg) { 918 accept1(ExpressionVisitor1 visitor, arg) {
915 return visitor.visitTypeExpression(this, arg); 919 return visitor.visitTypeExpression(this, arg);
916 } 920 }
917 } 921 }
918 922
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
1209 1213
1210 visitGetTypeTestProperty(GetTypeTestProperty node) { 1214 visitGetTypeTestProperty(GetTypeTestProperty node) {
1211 visitExpression(node.object); 1215 visitExpression(node.object);
1212 } 1216 }
1213 1217
1214 visitCreateBox(CreateBox node) { 1218 visitCreateBox(CreateBox node) {
1215 } 1219 }
1216 1220
1217 visitCreateInstance(CreateInstance node) { 1221 visitCreateInstance(CreateInstance node) {
1218 node.arguments.forEach(visitExpression); 1222 node.arguments.forEach(visitExpression);
1219 node.typeInformation.forEach(visitExpression); 1223 if (node.typeInformation != null) visitExpression(node.typeInformation);
1220 } 1224 }
1221 1225
1222 visitReifyRuntimeType(ReifyRuntimeType node) { 1226 visitReifyRuntimeType(ReifyRuntimeType node) {
1223 visitExpression(node.value); 1227 visitExpression(node.value);
1224 } 1228 }
1225 1229
1226 visitReadTypeVariable(ReadTypeVariable node) { 1230 visitReadTypeVariable(ReadTypeVariable node) {
1227 visitExpression(node.target); 1231 visitExpression(node.target);
1228 } 1232 }
1229 1233
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
1450 1454
1451 visitGetTypeTestProperty(GetTypeTestProperty node) { 1455 visitGetTypeTestProperty(GetTypeTestProperty node) {
1452 node.object = visitExpression(node.object); 1456 node.object = visitExpression(node.object);
1453 return node; 1457 return node;
1454 } 1458 }
1455 1459
1456 visitCreateBox(CreateBox node) => node; 1460 visitCreateBox(CreateBox node) => node;
1457 1461
1458 visitCreateInstance(CreateInstance node) { 1462 visitCreateInstance(CreateInstance node) {
1459 _replaceExpressions(node.arguments); 1463 _replaceExpressions(node.arguments);
1460 _replaceExpressions(node.typeInformation); 1464 if (node.typeInformation != null) {
1465 node.typeInformation = visitExpression(node.typeInformation);
1466 }
1461 return node; 1467 return node;
1462 } 1468 }
1463 1469
1464 visitReifyRuntimeType(ReifyRuntimeType node) { 1470 visitReifyRuntimeType(ReifyRuntimeType node) {
1465 node.value = visitExpression(node.value); 1471 node.value = visitExpression(node.value);
1466 return node; 1472 return node;
1467 } 1473 }
1468 1474
1469 visitReadTypeVariable(ReadTypeVariable node) { 1475 visitReadTypeVariable(ReadTypeVariable node) {
1470 node.target = visitExpression(node.target); 1476 node.target = visitExpression(node.target);
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
1578 1584
1579 /// Number of uses of the current fallthrough target. 1585 /// Number of uses of the current fallthrough target.
1580 int get useCount => _stack.last.useCount; 1586 int get useCount => _stack.last.useCount;
1581 1587
1582 /// Indicate that a statement will fall through to the current fallthrough 1588 /// Indicate that a statement will fall through to the current fallthrough
1583 /// target. 1589 /// target.
1584 void use() { 1590 void use() {
1585 ++_stack.last.useCount; 1591 ++_stack.last.useCount;
1586 } 1592 }
1587 } 1593 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698