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

Unified Diff: pkg/compiler/lib/src/tree_ir/tree_ir_builder.dart

Issue 1204733002: dart2js cps: Make Identical a built-in and add Interceptor to Tree IR. (Closed) Base URL: git@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 side-by-side diff with in-line comments
Download patch
Index: pkg/compiler/lib/src/tree_ir/tree_ir_builder.dart
diff --git a/pkg/compiler/lib/src/tree_ir/tree_ir_builder.dart b/pkg/compiler/lib/src/tree_ir/tree_ir_builder.dart
index f9f35de3fe4f87437e11cf7c01a9fc89e7e3d409..b482a319aea579a128e1f58d5c0179f4a86c5854 100644
--- a/pkg/compiler/lib/src/tree_ir/tree_ir_builder.dart
+++ b/pkg/compiler/lib/src/tree_ir/tree_ir_builder.dart
@@ -267,15 +267,37 @@ class Builder implements cps_ir.Visitor<Node> {
internalError(CURRENT_ELEMENT_SPANNABLE, 'Unexpected IR node: $node');
}
- // JS-specific nodes are handled by a subclass.
- visitSetField(cps_ir.SetField node) => unexpectedNode(node);
- visitIdentical(cps_ir.Identical node) => unexpectedNode(node);
- visitInterceptor(cps_ir.Interceptor node) => unexpectedNode(node);
- visitCreateInstance(cps_ir.CreateInstance node) => unexpectedNode(node);
- visitGetField(cps_ir.GetField node) => unexpectedNode(node);
- visitCreateBox(cps_ir.CreateBox node) => unexpectedNode(node);
+ Statement visitSetField(cps_ir.SetField node) {
+ return new ExpressionStatement(
+ new SetField(getVariableUse(node.object),
+ node.field,
+ getVariableUse(node.value)),
+ visit(node.body));
+ }
+
+ Expression visitInterceptor(cps_ir.Interceptor node) {
+ return new Interceptor(getVariableUse(node.input), node.interceptedClasses);
+ }
+
+ Expression visitCreateInstance(cps_ir.CreateInstance node) {
+ return new CreateInstance(
+ node.classElement,
+ translateArguments(node.arguments),
+ translateArguments(node.typeInformation));
+ }
+
+ Expression visitGetField(cps_ir.GetField node) {
+ return new GetField(getVariableUse(node.object), node.field);
+ }
+
+ Expression visitCreateBox(cps_ir.CreateBox node) {
+ return new CreateBox();
+ }
+
visitCreateInvocationMirror(cps_ir.CreateInvocationMirror node) {
- return unexpectedNode(node);
+ return new CreateInvocationMirror(
+ node.selector,
+ translateArguments(node.arguments));
}
// Executable definitions are not visited directly. They have 'build'
@@ -586,9 +608,24 @@ class Builder implements cps_ir.Visitor<Node> {
translateArguments(node.arguments));
}
- @override
- visitForeignCode(cps_ir.ForeignCode node) {
- unexpectedNode(node);
+ Statement visitForeignCode(cps_ir.ForeignCode node) {
+ if (node.codeTemplate.isExpression) {
+ Expression foreignCode = new ForeignExpression(
+ node.codeTemplate,
+ node.type,
+ node.arguments.map(getVariableUse).toList(growable: false),
+ node.nativeBehavior,
+ node.dependency);
+ return continueWithExpression(node.continuation, foreignCode);
+ } else {
+ assert(node.continuation == null);
+ return new ForeignStatement(
+ node.codeTemplate,
+ node.type,
+ node.arguments.map(getVariableUse).toList(growable: false),
+ node.nativeBehavior,
+ node.dependency);
+ }
}
}

Powered by Google App Engine
This is Rietveld 408576698