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

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

Issue 762213002: Support top-level field declaration and assignment in analyzer2dart. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments. Created 6 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 | Annotate | Revision Log
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 part of dart2js.optimizers; 5 part of dart2js.optimizers;
6 6
7 /** 7 /**
8 * Propagates constants throughout the IR, and replaces branches with fixed 8 * Propagates constants throughout the IR, and replaces branches with fixed
9 * jumps as well as side-effect free expressions with known constant results. 9 * jumps as well as side-effect free expressions with known constant results.
10 * Should be followed by the [ShrinkingReducer] pass. 10 * Should be followed by the [ShrinkingReducer] pass.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 analyzer.reachableNodes, analyzer.node2value); 42 analyzer.reachableNodes, analyzer.node2value);
43 transformer.transform(root); 43 transformer.transform(root);
44 } 44 }
45 45
46 void rewriteFunctionDefinition(FunctionDefinition root) { 46 void rewriteFunctionDefinition(FunctionDefinition root) {
47 if (root.isAbstract) return; 47 if (root.isAbstract) return;
48 _rewriteExecutableDefinition(root); 48 _rewriteExecutableDefinition(root);
49 } 49 }
50 50
51 void rewriteFieldDefinition(FieldDefinition root) { 51 void rewriteFieldDefinition(FieldDefinition root) {
52 if (!root.hasInitializer) return;
52 _rewriteExecutableDefinition(root); 53 _rewriteExecutableDefinition(root);
53 } 54 }
54 55
55 } 56 }
56 57
57 /** 58 /**
58 * Uses the information from a preceding analysis pass in order to perform the 59 * Uses the information from a preceding analysis pass in order to perform the
59 * actual transformations on the CPS graph. 60 * actual transformations on the CPS graph.
60 */ 61 */
61 class _TransformingVisitor extends RecursiveVisitor { 62 class _TransformingVisitor extends RecursiveVisitor {
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 compiler.internalError(NO_LOCATION_SPANNABLE, 306 compiler.internalError(NO_LOCATION_SPANNABLE,
306 "_ConstPropagationVisitor is stale, add missing visit overrides"); 307 "_ConstPropagationVisitor is stale, add missing visit overrides");
307 } 308 }
308 309
309 void visitFunctionDefinition(FunctionDefinition node) { 310 void visitFunctionDefinition(FunctionDefinition node) {
310 node.parameters.forEach(visitParameter); 311 node.parameters.forEach(visitParameter);
311 setReachable(node.body); 312 setReachable(node.body);
312 } 313 }
313 314
314 void visitFieldDefinition(FieldDefinition node) { 315 void visitFieldDefinition(FieldDefinition node) {
315 setReachable(node.body); 316 if (node.hasInitializer) {
317 setReachable(node.body);
318 }
316 } 319 }
317 320
318 // Expressions. 321 // Expressions.
319 322
320 void visitLetPrim(LetPrim node) { 323 void visitLetPrim(LetPrim node) {
321 visit(node.primitive); // No reason to delay visits to primitives. 324 visit(node.primitive); // No reason to delay visits to primitives.
322 setReachable(node.body); 325 setReachable(node.body);
323 } 326 }
324 327
325 void visitLetCont(LetCont node) { 328 void visitLetCont(LetCont node) {
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 return that; 693 return that;
691 } 694 }
692 695
693 if (this.constant == that.constant) { 696 if (this.constant == that.constant) {
694 return this; 697 return this;
695 } 698 }
696 699
697 return NonConst; 700 return NonConst;
698 } 701 }
699 } 702 }
OLDNEW
« no previous file with comments | « pkg/analyzer2dart/test/test_helper.dart ('k') | pkg/compiler/lib/src/cps_ir/cps_ir_builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698