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

Side by Side Diff: pkg/compiler/lib/src/tree_ir/optimization/statement_rewriter.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: Update 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 tree_ir.optimization; 5 part of tree_ir.optimization;
6 6
7 /** 7 /**
8 * Performs the following transformations on the tree: 8 * Performs the following transformations on the tree:
9 * - Assignment propagation 9 * - Assignment propagation
10 * - If-to-conditional conversion 10 * - If-to-conditional conversion
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 /// Returns the redirect target of [label] or [label] itself if it should not 103 /// Returns the redirect target of [label] or [label] itself if it should not
104 /// be redirected. 104 /// be redirected.
105 Jump redirect(Jump jump) { 105 Jump redirect(Jump jump) {
106 Jump newJump = labelRedirects[jump.target]; 106 Jump newJump = labelRedirects[jump.target];
107 return newJump != null ? newJump : jump; 107 return newJump != null ? newJump : jump;
108 } 108 }
109 109
110 void rewrite(ExecutableDefinition definition) => definition.applyPass(this); 110 void rewrite(ExecutableDefinition definition) => definition.applyPass(this);
111 111
112 void rewriteFieldDefinition(FieldDefinition definition) { 112 void rewriteFieldDefinition(FieldDefinition definition) {
113 if (!definition.hasInitializer) return;
114
113 environment = <Assign>[]; 115 environment = <Assign>[];
114 definition.body = visitStatement(definition.body); 116 definition.body = visitStatement(definition.body);
115 117
116 // TODO(kmillikin): Allow definitions that are not propagated. Here, 118 // TODO(kmillikin): Allow definitions that are not propagated. Here,
117 // this means rebuilding the binding with a recursively unnamed definition, 119 // this means rebuilding the binding with a recursively unnamed definition,
118 // or else introducing a variable definition and an assignment. 120 // or else introducing a variable definition and an assignment.
119 assert(environment.isEmpty); 121 assert(environment.isEmpty);
120 } 122 }
121 123
122 void rewriteFunctionDefinition(FunctionDefinition definition) { 124 void rewriteFunctionDefinition(FunctionDefinition definition) {
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 } 557 }
556 558
557 Expression makeCondition(Expression e, bool polarity) { 559 Expression makeCondition(Expression e, bool polarity) {
558 return polarity ? e : new Not(e); 560 return polarity ? e : new Not(e);
559 } 561 }
560 562
561 Statement getBranch(If node, bool polarity) { 563 Statement getBranch(If node, bool polarity) {
562 return polarity ? node.thenStatement : node.elseStatement; 564 return polarity ? node.thenStatement : node.elseStatement;
563 } 565 }
564 } 566 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698