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

Side by Side 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 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_builder; 5 library tree_ir_builder;
6 6
7 import '../dart2jslib.dart' as dart2js; 7 import '../dart2jslib.dart' as dart2js;
8 import '../elements/elements.dart'; 8 import '../elements/elements.dart';
9 import '../cps_ir/cps_ir_nodes.dart' as cps_ir; 9 import '../cps_ir/cps_ir_nodes.dart' as cps_ir;
10 import '../util/util.dart' show CURRENT_ELEMENT_SPANNABLE; 10 import '../util/util.dart' show CURRENT_ELEMENT_SPANNABLE;
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 } 260 }
261 return first; 261 return first;
262 } 262 }
263 263
264 visit(cps_ir.Node node) => node.accept(this); 264 visit(cps_ir.Node node) => node.accept(this);
265 265
266 unexpectedNode(cps_ir.Node node) { 266 unexpectedNode(cps_ir.Node node) {
267 internalError(CURRENT_ELEMENT_SPANNABLE, 'Unexpected IR node: $node'); 267 internalError(CURRENT_ELEMENT_SPANNABLE, 'Unexpected IR node: $node');
268 } 268 }
269 269
270 // JS-specific nodes are handled by a subclass. 270 Statement visitSetField(cps_ir.SetField node) {
271 visitSetField(cps_ir.SetField node) => unexpectedNode(node); 271 return new ExpressionStatement(
272 visitIdentical(cps_ir.Identical node) => unexpectedNode(node); 272 new SetField(getVariableUse(node.object),
273 visitInterceptor(cps_ir.Interceptor node) => unexpectedNode(node); 273 node.field,
274 visitCreateInstance(cps_ir.CreateInstance node) => unexpectedNode(node); 274 getVariableUse(node.value)),
275 visitGetField(cps_ir.GetField node) => unexpectedNode(node); 275 visit(node.body));
276 visitCreateBox(cps_ir.CreateBox node) => unexpectedNode(node); 276 }
277
278 Expression visitInterceptor(cps_ir.Interceptor node) {
279 return new Interceptor(getVariableUse(node.input), node.interceptedClasses);
280 }
281
282 Expression visitCreateInstance(cps_ir.CreateInstance node) {
283 return new CreateInstance(
284 node.classElement,
285 translateArguments(node.arguments),
286 translateArguments(node.typeInformation));
287 }
288
289 Expression visitGetField(cps_ir.GetField node) {
290 return new GetField(getVariableUse(node.object), node.field);
291 }
292
293 Expression visitCreateBox(cps_ir.CreateBox node) {
294 return new CreateBox();
295 }
296
277 visitCreateInvocationMirror(cps_ir.CreateInvocationMirror node) { 297 visitCreateInvocationMirror(cps_ir.CreateInvocationMirror node) {
278 return unexpectedNode(node); 298 return new CreateInvocationMirror(
299 node.selector,
300 translateArguments(node.arguments));
279 } 301 }
280 302
281 // Executable definitions are not visited directly. They have 'build' 303 // Executable definitions are not visited directly. They have 'build'
282 // functions as entry points. 304 // functions as entry points.
283 visitFunctionDefinition(cps_ir.FunctionDefinition node) { 305 visitFunctionDefinition(cps_ir.FunctionDefinition node) {
284 return unexpectedNode(node); 306 return unexpectedNode(node);
285 } 307 }
286 308
287 Statement visitLetPrim(cps_ir.LetPrim node) { 309 Statement visitLetPrim(cps_ir.LetPrim node) {
288 Variable variable = getVariable(node.primitive); 310 Variable variable = getVariable(node.primitive);
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
579 } 601 }
580 602
581 Expression visitApplyBuiltinOperator(cps_ir.ApplyBuiltinOperator node) { 603 Expression visitApplyBuiltinOperator(cps_ir.ApplyBuiltinOperator node) {
582 if (node.operator == BuiltinOperator.IsFalsy) { 604 if (node.operator == BuiltinOperator.IsFalsy) {
583 return new Not(getVariableUse(node.arguments.single)); 605 return new Not(getVariableUse(node.arguments.single));
584 } 606 }
585 return new ApplyBuiltinOperator(node.operator, 607 return new ApplyBuiltinOperator(node.operator,
586 translateArguments(node.arguments)); 608 translateArguments(node.arguments));
587 } 609 }
588 610
589 @override 611 Statement visitForeignCode(cps_ir.ForeignCode node) {
590 visitForeignCode(cps_ir.ForeignCode node) { 612 if (node.codeTemplate.isExpression) {
591 unexpectedNode(node); 613 Expression foreignCode = new ForeignExpression(
614 node.codeTemplate,
615 node.type,
616 node.arguments.map(getVariableUse).toList(growable: false),
617 node.nativeBehavior,
618 node.dependency);
619 return continueWithExpression(node.continuation, foreignCode);
620 } else {
621 assert(node.continuation == null);
622 return new ForeignStatement(
623 node.codeTemplate,
624 node.type,
625 node.arguments.map(getVariableUse).toList(growable: false),
626 node.nativeBehavior,
627 node.dependency);
628 }
592 } 629 }
593 } 630 }
594 631
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698