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

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

Issue 968843003: Implement type argument access and reification of runtime types. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 9 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 | Annotate | Revision Log
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 4
5 // IrNodes are kept in a separate library to have precise control over their 5 // IrNodes are kept in a separate library to have precise control over their
6 // dependencies on other parts of the system. 6 // dependencies on other parts of the system.
7 library dart2js.ir_nodes; 7 library dart2js.ir_nodes;
8 8
9 import '../constants/expressions.dart'; 9 import '../constants/expressions.dart';
10 import '../constants/values.dart' as values show ConstantValue; 10 import '../constants/values.dart' as values show ConstantValue;
(...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after
631 } 631 }
632 632
633 class This extends Primitive { 633 class This extends Primitive {
634 This(); 634 This();
635 635
636 accept(Visitor visitor) => visitor.visitThis(this); 636 accept(Visitor visitor) => visitor.visitThis(this);
637 } 637 }
638 638
639 /// Reify the given type variable as a [Type]. 639 /// Reify the given type variable as a [Type].
640 /// This depends on the current binding of 'this'. 640 /// This depends on the current binding of 'this'.
641 class ReifyTypeVar extends Primitive { 641 class ReifyTypeVar extends Primitive implements DartSpecificNode {
642 final TypeVariableElement typeVariable; 642 final TypeVariableElement typeVariable;
643 643
644 ReifyTypeVar(this.typeVariable); 644 ReifyTypeVar(this.typeVariable);
645 645
646 values.ConstantValue get constant => null; 646 values.ConstantValue get constant => null;
647 647
648 accept(Visitor visitor) => visitor.visitReifyTypeVar(this); 648 accept(Visitor visitor) => visitor.visitReifyTypeVar(this);
649 } 649 }
650 650
651 class LiteralList extends Primitive { 651 class LiteralList extends Primitive {
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
853 ConstructorElement element, 853 ConstructorElement element,
854 List<Definition> parameters, 854 List<Definition> parameters,
855 List<ConstantExpression> defaultParameterValues) 855 List<ConstantExpression> defaultParameterValues)
856 : initializers = null, 856 : initializers = null,
857 super.abstract(element, parameters, defaultParameterValues); 857 super.abstract(element, parameters, defaultParameterValues);
858 858
859 accept(Visitor visitor) => visitor.visitConstructorDefinition(this); 859 accept(Visitor visitor) => visitor.visitConstructorDefinition(this);
860 applyPass(Pass pass) => pass.rewriteConstructorDefinition(this); 860 applyPass(Pass pass) => pass.rewriteConstructorDefinition(this);
861 } 861 }
862 862
863 class ReifyRuntimeType extends Primitive implements JsSpecificNode {
asgerf 2015/03/02 13:52:36 Please clarify that [value] should be a "JS type"
karlklose 2015/03/05 09:54:58 Done.
asgerf 2015/03/05 10:58:07 Great!
864 final Reference<Primitive> value;
865 ReifyRuntimeType(Primitive value)
866 : this.value = new Reference<Primitive>(value);
867
868 @override
869 accept(Visitor visitor) => visitor.visitReifyRuntimeType(this);
870 }
871
872 class ReadTypeVariable extends Primitive implements JsSpecificNode {
873 final TypeVariableType variable;
874 final ClassElement context;
asgerf 2015/03/02 13:52:36 Please provide a doc comment for 'context' and for
karlklose 2015/03/05 09:54:58 Acknowledged.
875 final Reference<Primitive> target;
876
877 ReadTypeVariable(this.variable, this.context, Primitive target)
878 : this.target = new Reference<Primitive>(target);
879
880 @override
881 accept(Visitor visitor) => visitor.visitReadTypeVariable(this);
882 }
883
863 List<Reference<Primitive>> _referenceList(Iterable<Primitive> definitions) { 884 List<Reference<Primitive>> _referenceList(Iterable<Primitive> definitions) {
864 return definitions.map((e) => new Reference<Primitive>(e)).toList(); 885 return definitions.map((e) => new Reference<Primitive>(e)).toList();
865 } 886 }
866 887
867 abstract class Visitor<T> { 888 abstract class Visitor<T> {
868 const Visitor(); 889 const Visitor();
869 890
870 T visit(Node node) => node.accept(this); 891 T visit(Node node) => node.accept(this);
871 // Abstract classes. 892 // Abstract classes.
872 T visitNode(Node node) => null; 893 T visitNode(Node node) => null;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
919 T visitGetField(GetField node) => visitDefinition(node); 940 T visitGetField(GetField node) => visitDefinition(node);
920 T visitCreateBox(CreateBox node) => visitDefinition(node); 941 T visitCreateBox(CreateBox node) => visitDefinition(node);
921 T visitCreateInstance(CreateInstance node) => visitDefinition(node); 942 T visitCreateInstance(CreateInstance node) => visitDefinition(node);
922 943
923 // Conditions. 944 // Conditions.
924 T visitIsTrue(IsTrue node) => visitCondition(node); 945 T visitIsTrue(IsTrue node) => visitCondition(node);
925 946
926 // JavaScript specific nodes. 947 // JavaScript specific nodes.
927 T visitIdentical(Identical node) => visitPrimitive(node); 948 T visitIdentical(Identical node) => visitPrimitive(node);
928 T visitInterceptor(Interceptor node) => visitPrimitive(node); 949 T visitInterceptor(Interceptor node) => visitPrimitive(node);
950 T visitReifyRuntimeType(ReifyRuntimeType node) => visitPrimitive(node);
951 T visitReadTypeVariable(ReadTypeVariable node) => visitPrimitive(node);
929 } 952 }
930 953
931 /// Recursively visits the entire CPS term, and calls abstract `process*` 954 /// Recursively visits the entire CPS term, and calls abstract `process*`
932 /// (i.e. `processLetPrim`) functions in pre-order. 955 /// (i.e. `processLetPrim`) functions in pre-order.
933 abstract class RecursiveVisitor extends Visitor { 956 abstract class RecursiveVisitor extends Visitor {
934 const RecursiveVisitor(); 957 const RecursiveVisitor();
935 958
936 // Ensures that RecursiveVisitor contains overrides for all relevant nodes. 959 // Ensures that RecursiveVisitor contains overrides for all relevant nodes.
937 // As a rule of thumb, nodes with structure to traverse should be overridden 960 // As a rule of thumb, nodes with structure to traverse should be overridden
938 // with the appropriate visits in this class (for example, visitLetCont), 961 // with the appropriate visits in this class (for example, visitLetCont),
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
1185 processGetField(GetField node) {} 1208 processGetField(GetField node) {}
1186 visitGetField(GetField node) { 1209 visitGetField(GetField node) {
1187 processGetField(node); 1210 processGetField(node);
1188 processReference(node.object); 1211 processReference(node.object);
1189 } 1212 }
1190 1213
1191 processCreateBox(CreateBox node) {} 1214 processCreateBox(CreateBox node) {}
1192 visitCreateBox(CreateBox node) { 1215 visitCreateBox(CreateBox node) {
1193 processCreateBox(node); 1216 processCreateBox(node);
1194 } 1217 }
1218
1219 processReifyRuntimeType(ReifyRuntimeType node) {}
1220 visitReifyRuntimeType(ReifyRuntimeType node) {
1221 processReifyRuntimeType(node);
1222 processReference(node.value);
1223 }
1224
1225 processReadTypeVariable(ReadTypeVariable node) {}
1226 visitReadTypeVariable(ReadTypeVariable node) {
1227 processReadTypeVariable(node);
1228 processReference(node.target);
1229 }
1195 } 1230 }
1196 1231
1197 /// Keeps track of currently unused register indices. 1232 /// Keeps track of currently unused register indices.
1198 class RegisterArray { 1233 class RegisterArray {
1199 int nextIndex = 0; 1234 int nextIndex = 0;
1200 final List<int> freeStack = <int>[]; 1235 final List<int> freeStack = <int>[];
1201 1236
1202 /// Returns an index that is currently unused. 1237 /// Returns an index that is currently unused.
1203 int makeIndex() { 1238 int makeIndex() {
1204 if (freeStack.isEmpty) { 1239 if (freeStack.isEmpty) {
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
1436 } 1471 }
1437 1472
1438 void visitIdentical(Identical node) { 1473 void visitIdentical(Identical node) {
1439 visitReference(node.left); 1474 visitReference(node.left);
1440 visitReference(node.right); 1475 visitReference(node.right);
1441 } 1476 }
1442 1477
1443 void visitInterceptor(Interceptor node) { 1478 void visitInterceptor(Interceptor node) {
1444 visitReference(node.input); 1479 visitReference(node.input);
1445 } 1480 }
1481
1482 void visitReifyRuntimeType(ReifyRuntimeType node) {
1483 visitReference(node.value);
1484 }
1485
1486 void visitReadTypeVariable(ReadTypeVariable node) {
1487 visitReference(node.target);
1488 }
1446 } 1489 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698