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

Unified Diff: pkg/compiler/lib/src/tree_ir/optimization/pull_into_initializers.dart

Issue 1155463005: dart2js cps: Remove dart2dart from cps pipeline and clean up. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Skip tests specific to the dart backend Created 5 years, 7 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/optimization/pull_into_initializers.dart
diff --git a/pkg/compiler/lib/src/tree_ir/optimization/pull_into_initializers.dart b/pkg/compiler/lib/src/tree_ir/optimization/pull_into_initializers.dart
index e68c4886f93e76539efde5f24589ca176bd7790c..a19aeba06c03c33cc00e03756c3eb085d571587c 100644
--- a/pkg/compiler/lib/src/tree_ir/optimization/pull_into_initializers.dart
+++ b/pkg/compiler/lib/src/tree_ir/optimization/pull_into_initializers.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+library tree_ir.optimization.pull_into_initializers;
+
import 'optimization.dart' show Pass;
import '../tree_ir_nodes.dart';
@@ -46,17 +48,10 @@ import '../tree_ir_nodes.dart';
/// [PullIntoInitializers] cannot pull `y` into an initializer because
/// the impure expressions `foo()` and `bar()` would then be swapped.
///
-class PullIntoInitializers implements Pass {
+class PullIntoInitializers extends ExpressionVisitor<Expression>
+ implements Pass {
String get passName => 'Pull into initializers';
- void rewrite(RootNode node) {
- node.replaceEachBody((Statement body) {
- return new BodyRewriter().rewriteBody(node.parameters, body);
- });
- }
-}
-
-class BodyRewriter extends ExpressionVisitor<Expression> {
Set<Variable> assignedVariables = new Set<Variable>();
/// The fragment between [first] and [last] holds the statements
@@ -98,8 +93,9 @@ class BodyRewriter extends ExpressionVisitor<Expression> {
return visitExpression(node);
}
- Statement rewriteBody(List<Variable> parameters, Statement body) {
- assignedVariables.addAll(parameters);
+ void rewrite(FunctionDefinition node) {
+ Statement body = node.body;
+ assignedVariables.addAll(node.parameters);
// [body] represents the first statement after the initializer block.
// Repeatedly pull assignment statements into the initializer block.
@@ -134,7 +130,8 @@ class BodyRewriter extends ExpressionVisitor<Expression> {
append(body);
assert(first != null); // Because we just appended the body.
- return first;
+
+ node.body = first;
}
void destroyVariableUse(VariableUse node) {
@@ -255,7 +252,7 @@ class BodyRewriter extends ExpressionVisitor<Expression> {
}
void visitInnerFunction(FunctionDefinition node) {
- node.body = new BodyRewriter().rewriteBody(node.parameters, node.body);
+ new PullIntoInitializers().rewrite(node);
}
Expression visitFunctionExpression(FunctionExpression node) {
@@ -315,10 +312,6 @@ class BodyRewriter extends ExpressionVisitor<Expression> {
return node;
}
- Expression visitReifyTypeVar(ReifyTypeVar node) {
- return node;
- }
-
Expression visitNot(Not node) {
node.operand = visitExpression(node.operand);
return node;

Powered by Google App Engine
This is Rietveld 408576698