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

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

Issue 806103003: cps-ir: Add support for intercepted calls. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Disable debug print. Created 6 years 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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 arguments = _referenceList(args) { 201 arguments = _referenceList(args) {
202 assert(selector != null); 202 assert(selector != null);
203 assert(selector.kind == SelectorKind.CALL || 203 assert(selector.kind == SelectorKind.CALL ||
204 selector.kind == SelectorKind.OPERATOR || 204 selector.kind == SelectorKind.OPERATOR ||
205 (selector.kind == SelectorKind.GETTER && arguments.isEmpty) || 205 (selector.kind == SelectorKind.GETTER && arguments.isEmpty) ||
206 (selector.kind == SelectorKind.SETTER && arguments.length == 1) || 206 (selector.kind == SelectorKind.SETTER && arguments.length == 1) ||
207 (selector.kind == SelectorKind.INDEX && arguments.length == 1) || 207 (selector.kind == SelectorKind.INDEX && arguments.length == 1) ||
208 (selector.kind == SelectorKind.INDEX && arguments.length == 2)); 208 (selector.kind == SelectorKind.INDEX && arguments.length == 2));
209 } 209 }
210 210
211 bool get isIntercepted => receiver.definition is Interceptor;
212
211 accept(Visitor visitor) => visitor.visitInvokeMethod(this); 213 accept(Visitor visitor) => visitor.visitInvokeMethod(this);
212 } 214 }
213 215
214 /// Invoke a method, operator, getter, setter, or index getter/setter from the 216 /// Invoke a method, operator, getter, setter, or index getter/setter from the
215 /// super class in tail position. 217 /// super class in tail position.
216 class InvokeSuperMethod extends Expression implements Invoke { 218 class InvokeSuperMethod extends Expression implements Invoke {
217 final Selector selector; 219 final Selector selector;
218 final Reference<Continuation> continuation; 220 final Reference<Continuation> continuation;
219 final List<Reference<Primitive>> arguments; 221 final List<Reference<Primitive>> arguments;
220 222
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 450
449 class Identical extends Primitive { 451 class Identical extends Primitive {
450 final Reference<Primitive> left; 452 final Reference<Primitive> left;
451 final Reference<Primitive> right; 453 final Reference<Primitive> right;
452 Identical(Primitive left, Primitive right) 454 Identical(Primitive left, Primitive right)
453 : left = new Reference<Primitive>(left), 455 : left = new Reference<Primitive>(left),
454 right = new Reference<Primitive>(right); 456 right = new Reference<Primitive>(right);
455 accept(Visitor visitor) => visitor.visitIdentical(this); 457 accept(Visitor visitor) => visitor.visitIdentical(this);
456 } 458 }
457 459
460 class Interceptor extends Primitive {
461 final Reference<Primitive> input;
462 final Set<ClassElement> interceptedClasses;
463 Interceptor(Primitive input, this.interceptedClasses)
464 : this.input = new Reference<Primitive>(input);
465 accept(Visitor visitor) => visitor.visitInterceptor(this);
466 }
467
458 class Constant extends Primitive { 468 class Constant extends Primitive {
459 final ConstantExpression expression; 469 final ConstantExpression expression;
460 470
461 Constant(this.expression); 471 Constant(this.expression);
462 472
463 values.ConstantValue get value => expression.value; 473 values.ConstantValue get value => expression.value;
464 474
465 accept(Visitor visitor) => visitor.visitConstant(this); 475 accept(Visitor visitor) => visitor.visitConstant(this);
466 } 476 }
467 477
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 T visitGetClosureVariable(GetClosureVariable node) => visitPrimitive(node); 693 T visitGetClosureVariable(GetClosureVariable node) => visitPrimitive(node);
684 T visitParameter(Parameter node) => visitPrimitive(node); 694 T visitParameter(Parameter node) => visitPrimitive(node);
685 T visitContinuation(Continuation node) => visitDefinition(node); 695 T visitContinuation(Continuation node) => visitDefinition(node);
686 T visitClosureVariable(ClosureVariable node) => visitDefinition(node); 696 T visitClosureVariable(ClosureVariable node) => visitDefinition(node);
687 697
688 // Conditions. 698 // Conditions.
689 T visitIsTrue(IsTrue node) => visitCondition(node); 699 T visitIsTrue(IsTrue node) => visitCondition(node);
690 700
691 // JavaScript specific nodes. 701 // JavaScript specific nodes.
692 T visitIdentical(Identical node) => visitPrimitive(node); 702 T visitIdentical(Identical node) => visitPrimitive(node);
703 T visitInterceptor(Interceptor node) => visitPrimitive(node);
693 } 704 }
694 705
695 /// Recursively visits the entire CPS term, and calls abstract `process*` 706 /// Recursively visits the entire CPS term, and calls abstract `process*`
696 /// (i.e. `processLetPrim`) functions in pre-order. 707 /// (i.e. `processLetPrim`) functions in pre-order.
697 abstract class RecursiveVisitor extends Visitor { 708 abstract class RecursiveVisitor extends Visitor {
698 const RecursiveVisitor(); 709 const RecursiveVisitor();
699 710
700 // Ensures that RecursiveVisitor contains overrides for all relevant nodes. 711 // Ensures that RecursiveVisitor contains overrides for all relevant nodes.
701 // As a rule of thumb, nodes with structure to traverse should be overridden 712 // As a rule of thumb, nodes with structure to traverse should be overridden
702 // with the appropriate visits in this class (for example, visitLetCont), 713 // with the appropriate visits in this class (for example, visitLetCont),
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
872 processReference(node.value); 883 processReference(node.value);
873 } 884 }
874 885
875 // JavaScript specific nodes. 886 // JavaScript specific nodes.
876 processIdentical(Identical node) {} 887 processIdentical(Identical node) {}
877 visitIdentical(Identical node) { 888 visitIdentical(Identical node) {
878 processIdentical(node); 889 processIdentical(node);
879 processReference(node.left); 890 processReference(node.left);
880 processReference(node.right); 891 processReference(node.right);
881 } 892 }
893
894 processInterceptor(Interceptor node) {}
895 visitInterceptor(Interceptor node) {
896 processInterceptor(node);
897 processReference(node.input);
898 }
882 } 899 }
883 900
884 /// Keeps track of currently unused register indices. 901 /// Keeps track of currently unused register indices.
885 class RegisterArray { 902 class RegisterArray {
886 int nextIndex = 0; 903 int nextIndex = 0;
887 final List<int> freeStack = <int>[]; 904 final List<int> freeStack = <int>[];
888 905
889 /// Returns an index that is currently unused. 906 /// Returns an index that is currently unused.
890 int makeIndex() { 907 int makeIndex() {
891 if (freeStack.isEmpty) { 908 if (freeStack.isEmpty) {
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
1056 void visitIsTrue(IsTrue node) { 1073 void visitIsTrue(IsTrue node) {
1057 visitReference(node.value); 1074 visitReference(node.value);
1058 } 1075 }
1059 1076
1060 // JavaScript specific nodes. 1077 // JavaScript specific nodes.
1061 1078
1062 void visitIdentical(Identical node) { 1079 void visitIdentical(Identical node) {
1063 visitReference(node.left); 1080 visitReference(node.left);
1064 visitReference(node.right); 1081 visitReference(node.right);
1065 } 1082 }
1083
1084 void visitInterceptor(Interceptor node) {
1085 visitReference(node.input);
1086 }
1066 } 1087 }
1067
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698