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

Side by Side Diff: pkg/compiler/lib/src/cps_ir/remove_refinements.dart

Issue 1408783004: dart2js cps: Support --trust-primitives and --trust-type-annotations. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Merge Created 5 years, 2 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) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 cps_ir.optimization.remove_refinements; 5 library cps_ir.optimization.remove_refinements;
6 6
7 import 'optimizers.dart' show Pass; 7 import 'optimizers.dart' show Pass;
8 import 'cps_ir_nodes.dart'; 8 import 'cps_ir_nodes.dart';
9 9
10 /// Removes all [Refinement] nodes from the IR. 10 /// Removes all [Refinement] nodes from the IR.
11 /// 11 ///
12 /// This simplifies subsequent passes that don't rely on path-sensitive 12 /// This simplifies subsequent passes that don't rely on path-sensitive
13 /// type information but depend on equality between primitives. 13 /// type information but depend on equality between primitives.
14 class RemoveRefinements extends TrampolineRecursiveVisitor implements Pass { 14 class RemoveRefinements extends TrampolineRecursiveVisitor implements Pass {
15 String get passName => 'Remove refinement nodes'; 15 String get passName => 'Remove refinement nodes';
16 16
17 void rewrite(FunctionDefinition node) { 17 void rewrite(FunctionDefinition node) {
18 visit(node); 18 visit(node);
19 } 19 }
20 20
21 @override 21 @override
22 Expression traverseLetPrim(LetPrim node) { 22 Expression traverseLetPrim(LetPrim node) {
23 Expression next = node.body; 23 Expression next = node.body;
24 if (node.primitive is Refinement) { 24 if (node.primitive is Refinement) {
25 Refinement refinement = node.primitive; 25 Refinement refinement = node.primitive;
26 refinement.value.definition.substituteFor(refinement); 26 Primitive value = refinement.value.definition;
27 if (refinement.hint != null && value.hint == null) {
28 value.hint = refinement.hint;
29 }
30 value.substituteFor(refinement);
27 refinement.destroy(); 31 refinement.destroy();
28 node.remove(); 32 node.remove();
29 } 33 }
30 return next; 34 return next;
31 } 35 }
32 } 36 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/cps_ir/insert_refinements.dart ('k') | pkg/compiler/lib/src/cps_ir/type_propagation.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698