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

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

Issue 1196443002: Revert "cps-ir: Support foreign code." (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 6 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 '../constants/expressions.dart'; 6 import '../constants/expressions.dart';
7 import '../constants/values.dart' as values show ConstantValue; 7 import '../constants/values.dart' as values show ConstantValue;
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/universe.dart' show Selector, SelectorKind; 12 import '../universe/universe.dart' show Selector, SelectorKind;
13 13
14 import 'builtin_operator.dart'; 14 import 'builtin_operator.dart';
15 export 'builtin_operator.dart'; 15 export 'builtin_operator.dart';
16 16
17 // 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
19 // abstractions for native code and its type and effect system.
20 import '../js/js.dart' as js show Template;
21 import '../native/native.dart' as native show NativeBehavior;
22 import '../types/types.dart' as types show TypeMask;
23
24 abstract class Node { 17 abstract class Node {
25 /// A pointer to the parent node. Is null until set by optimization passes. 18 /// A pointer to the parent node. Is null until set by optimization passes.
26 Node parent; 19 Node parent;
27 20
28 accept(Visitor visitor); 21 accept(Visitor visitor);
29 } 22 }
30 23
31 /// Expressions can be evaluated, and may diverge, throw, and/or have 24 /// Expressions can be evaluated, and may diverge, throw, and/or have
32 /// side-effects. 25 /// side-effects.
33 /// 26 ///
(...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 class CreateInvocationMirror extends Primitive { 722 class CreateInvocationMirror extends Primitive {
730 final Selector selector; 723 final Selector selector;
731 final List<Reference<Primitive>> arguments; 724 final List<Reference<Primitive>> arguments;
732 725
733 CreateInvocationMirror(this.selector, List<Primitive> arguments) 726 CreateInvocationMirror(this.selector, List<Primitive> arguments)
734 : this.arguments = _referenceList(arguments); 727 : this.arguments = _referenceList(arguments);
735 728
736 accept(Visitor visitor) => visitor.visitCreateInvocationMirror(this); 729 accept(Visitor visitor) => visitor.visitCreateInvocationMirror(this);
737 } 730 }
738 731
739 class ForeignCode extends Expression {
740 final js.Template codeTemplate;
741 final types.TypeMask type;
742 final List<Reference<Primitive>> arguments;
743 final native.NativeBehavior nativeBehavior;
744 final FunctionElement dependency;
745
746 /// The continuation, if the foreign code is not a JavaScript 'throw',
747 /// otherwise null.
748 final Reference<Continuation> continuation;
749
750 ForeignCode(this.codeTemplate, this.type, List<Primitive> arguments,
751 this.nativeBehavior, {Continuation continuation, this.dependency})
752 : arguments = _referenceList(arguments),
753 continuation = continuation == null ? null
754 : new Reference<Continuation>(continuation);
755
756 accept(Visitor visitor) => visitor.visitForeignCode(this);
757 }
758
759 class Constant extends Primitive { 732 class Constant extends Primitive {
760 final ConstantExpression expression; 733 final ConstantExpression expression;
761 final values.ConstantValue value; 734 final values.ConstantValue value;
762 735
763 Constant(this.expression, this.value); 736 Constant(this.expression, this.value);
764 737
765 accept(Visitor visitor) => visitor.visitConstant(this); 738 accept(Visitor visitor) => visitor.visitConstant(this);
766 } 739 }
767 740
768 class LiteralList extends Primitive { 741 class LiteralList extends Primitive {
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
983 T visitCreateBox(CreateBox node); 956 T visitCreateBox(CreateBox node);
984 T visitReifyRuntimeType(ReifyRuntimeType node); 957 T visitReifyRuntimeType(ReifyRuntimeType node);
985 T visitReadTypeVariable(ReadTypeVariable node); 958 T visitReadTypeVariable(ReadTypeVariable node);
986 T visitTypeExpression(TypeExpression node); 959 T visitTypeExpression(TypeExpression node);
987 T visitCreateInvocationMirror(CreateInvocationMirror node); 960 T visitCreateInvocationMirror(CreateInvocationMirror node);
988 T visitTypeTest(TypeTest node); 961 T visitTypeTest(TypeTest node);
989 T visitApplyBuiltinOperator(ApplyBuiltinOperator node); 962 T visitApplyBuiltinOperator(ApplyBuiltinOperator node);
990 963
991 // Conditions. 964 // Conditions.
992 T visitIsTrue(IsTrue node); 965 T visitIsTrue(IsTrue node);
993
994 // Support for literal foreign code.
995 T visitForeignCode(ForeignCode node);
996 } 966 }
997 967
998 /// Recursively visits the entire CPS term, and calls abstract `process*` 968 /// Recursively visits the entire CPS term, and calls abstract `process*`
999 /// (i.e. `processLetPrim`) functions in pre-order. 969 /// (i.e. `processLetPrim`) functions in pre-order.
1000 class RecursiveVisitor implements Visitor { 970 class RecursiveVisitor implements Visitor {
1001 const RecursiveVisitor(); 971 const RecursiveVisitor();
1002 972
1003 visit(Node node) => node.accept(this); 973 visit(Node node) => node.accept(this);
1004 974
1005 processReference(Reference ref) {} 975 processReference(Reference ref) {}
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
1271 processCreateInvocationMirror(node); 1241 processCreateInvocationMirror(node);
1272 node.arguments.forEach(processReference); 1242 node.arguments.forEach(processReference);
1273 } 1243 }
1274 1244
1275 processApplyBuiltinOperator(ApplyBuiltinOperator node) {} 1245 processApplyBuiltinOperator(ApplyBuiltinOperator node) {}
1276 visitApplyBuiltinOperator(ApplyBuiltinOperator node) { 1246 visitApplyBuiltinOperator(ApplyBuiltinOperator node) {
1277 processApplyBuiltinOperator(node); 1247 processApplyBuiltinOperator(node);
1278 node.arguments.forEach(processReference); 1248 node.arguments.forEach(processReference);
1279 } 1249 }
1280 1250
1281 processForeignCode(ForeignCode node) {}
1282 visitForeignCode(ForeignCode node) {
1283 processForeignCode(node);
1284 processReference(node.continuation);
1285 node.arguments.forEach(processReference);
1286 }
1287
1288 processUnreachable(Unreachable node) {} 1251 processUnreachable(Unreachable node) {}
1289 visitUnreachable(Unreachable node) { 1252 visitUnreachable(Unreachable node) {
1290 processUnreachable(node); 1253 processUnreachable(node);
1291 } 1254 }
1292 } 1255 }
1293 1256
1294 /// Visit a just-deleted subterm and unlink all [Reference]s in it. 1257 /// Visit a just-deleted subterm and unlink all [Reference]s in it.
1295 class RemovalVisitor extends RecursiveVisitor { 1258 class RemovalVisitor extends RecursiveVisitor {
1296 const RemovalVisitor(); 1259 const RemovalVisitor();
1297 1260
1298 processReference(Reference reference) { 1261 processReference(Reference reference) {
1299 reference.unlink(); 1262 reference.unlink();
1300 } 1263 }
1301 1264
1302 static void remove(Node node) { 1265 static void remove(Node node) {
1303 (const RemovalVisitor()).visit(node); 1266 (const RemovalVisitor()).visit(node);
1304 } 1267 }
1305 } 1268 }
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