| Index: pkg/compiler/lib/src/cps_ir/remove_refinements.dart
|
| diff --git a/pkg/compiler/lib/src/cps_ir/remove_refinements.dart b/pkg/compiler/lib/src/cps_ir/remove_refinements.dart
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..f5088ae214008351cbb595d737c6578bd1ba4478
|
| --- /dev/null
|
| +++ b/pkg/compiler/lib/src/cps_ir/remove_refinements.dart
|
| @@ -0,0 +1,35 @@
|
| +// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
|
| +// 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 cps_ir.optimization.remove_refinements;
|
| +
|
| +import 'optimizers.dart' show Pass;
|
| +import 'shrinking_reductions.dart' show ParentVisitor;
|
| +import 'cps_ir_nodes.dart';
|
| +
|
| +/// Removes all [Refinement] nodes from the IR.
|
| +///
|
| +/// This simplifies subsequent passes that don't rely on path-sensitive
|
| +/// type information but depend on equality between primitives.
|
| +class RemoveRefinements extends RecursiveVisitor implements Pass {
|
| + String get passName => 'Remove refinement nodes';
|
| +
|
| + void rewrite(FunctionDefinition node) {
|
| + new ParentVisitor().visit(node);
|
| + visit(node);
|
| + }
|
| +
|
| + @override
|
| + Expression traverseLetPrim(LetPrim node) {
|
| + if (node.primitive is Refinement) {
|
| + Refinement refinement = node.primitive;
|
| + refinement.value.definition.substituteFor(refinement);
|
| + refinement.value.unlink();
|
| + InteriorNode parent = node.parent;
|
| + parent.body = node.body;
|
| + node.body.parent = parent;
|
| + }
|
| + return node.body;
|
| + }
|
| +}
|
|
|