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

Side by Side Diff: pkg/compiler/lib/src/tree_ir/optimization/statement_rewriter.dart

Issue 1474713002: dart2js cps: Clean up and avoid processing unreachable code. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Merge Created 5 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
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.optimization.statement_rewriter; 5 library tree_ir.optimization.statement_rewriter;
6 6
7 import 'optimization.dart' show Pass; 7 import 'optimization.dart' show Pass;
8 import '../tree_ir_nodes.dart'; 8 import '../tree_ir_nodes.dart';
9 import '../../io/source_information.dart'; 9 import '../../io/source_information.dart';
10 import '../../elements/elements.dart'; 10 import '../../elements/elements.dart';
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 }); 572 });
573 573
574 return node; 574 return node;
575 } 575 }
576 576
577 Expression visitNot(Not node) { 577 Expression visitNot(Not node) {
578 node.operand = visitExpression(node.operand); 578 node.operand = visitExpression(node.operand);
579 return node; 579 return node;
580 } 580 }
581 581
582 Expression visitFunctionExpression(FunctionExpression node) {
583 new StatementRewriter.nested(this).rewrite(node.definition);
584 return node;
585 }
586
587 Statement visitReturn(Return node) { 582 Statement visitReturn(Return node) {
588 node.value = visitExpression(node.value); 583 node.value = visitExpression(node.value);
589 return node; 584 return node;
590 } 585 }
591 586
592 Statement visitThrow(Throw node) { 587 Statement visitThrow(Throw node) {
593 node.value = visitExpression(node.value); 588 node.value = visitExpression(node.value);
594 return node; 589 return node;
595 } 590 }
596 591
(...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after
1249 Variable variable; 1244 Variable variable;
1250 bool wasFound = false; 1245 bool wasFound = false;
1251 1246
1252 IsVariableUsedVisitor(this.variable); 1247 IsVariableUsedVisitor(this.variable);
1253 1248
1254 visitVariableUse(VariableUse node) { 1249 visitVariableUse(VariableUse node) {
1255 if (node.variable == variable) { 1250 if (node.variable == variable) {
1256 wasFound = true; 1251 wasFound = true;
1257 } 1252 }
1258 } 1253 }
1259
1260 visitInnerFunction(FunctionDefinition node) {}
1261 } 1254 }
1262 1255
1263 typedef VariableUseCallback(VariableUse use); 1256 typedef VariableUseCallback(VariableUse use);
1264 1257
1265 class VariableUseVisitor extends RecursiveVisitor { 1258 class VariableUseVisitor extends RecursiveVisitor {
1266 VariableUseCallback callback; 1259 VariableUseCallback callback;
1267 1260
1268 VariableUseVisitor(this.callback); 1261 VariableUseVisitor(this.callback);
1269 1262
1270 visitVariableUse(VariableUse use) => callback(use); 1263 visitVariableUse(VariableUse use) => callback(use);
1271 1264
1272 visitInnerFunction(FunctionDefinition node) {}
1273
1274 static void visit(Expression node, VariableUseCallback callback) { 1265 static void visit(Expression node, VariableUseCallback callback) {
1275 new VariableUseVisitor(callback).visitExpression(node); 1266 new VariableUseVisitor(callback).visitExpression(node);
1276 } 1267 }
1277 } 1268 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698