| OLD | NEW |
| 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 /// Rewrites logical expressions to be more compact in the Tree IR. | 7 /// Rewrites logical expressions to be more compact in the Tree IR. |
| 8 /// | 8 /// |
| 9 /// In this class an expression is said to occur in "boolean context" if | 9 /// In this class an expression is said to occur in "boolean context" if |
| 10 /// its result is immediately applied to boolean conversion. | 10 /// its result is immediately applied to boolean conversion. |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 | 325 |
| 326 Expression visitGetField(GetField node) { | 326 Expression visitGetField(GetField node) { |
| 327 node.object = visitExpression(node.object); | 327 node.object = visitExpression(node.object); |
| 328 return node; | 328 return node; |
| 329 } | 329 } |
| 330 | 330 |
| 331 Expression visitCreateBox(CreateBox node) { | 331 Expression visitCreateBox(CreateBox node) { |
| 332 return node; | 332 return node; |
| 333 } | 333 } |
| 334 | 334 |
| 335 Expression visitCreateClosureClass(CreateClosureClass node) { | 335 Expression visitCreateInstance(CreateInstance node) { |
| 336 _rewriteList(node.arguments); | 336 _rewriteList(node.arguments); |
| 337 return node; | 337 return node; |
| 338 } | 338 } |
| 339 | 339 |
| 340 /// True if the given expression is known to evaluate to a boolean. | 340 /// True if the given expression is known to evaluate to a boolean. |
| 341 /// This will not recursively traverse [Conditional] expressions, but if | 341 /// This will not recursively traverse [Conditional] expressions, but if |
| 342 /// applied to the result of [visitExpression] conditionals will have been | 342 /// applied to the result of [visitExpression] conditionals will have been |
| 343 /// rewritten anyway. | 343 /// rewritten anyway. |
| 344 bool isBooleanValued(Expression e) { | 344 bool isBooleanValued(Expression e) { |
| 345 return isTrue(e) || isFalse(e) || e is Not || e is LogicalOperator; | 345 return isTrue(e) || isFalse(e) || e is Not || e is LogicalOperator; |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 483 } | 483 } |
| 484 | 484 |
| 485 /// Destructively updates each entry of [l] with the result of visiting it. | 485 /// Destructively updates each entry of [l] with the result of visiting it. |
| 486 void _rewriteList(List<Expression> l) { | 486 void _rewriteList(List<Expression> l) { |
| 487 for (int i = 0; i < l.length; i++) { | 487 for (int i = 0; i < l.length; i++) { |
| 488 l[i] = visitExpression(l[i]); | 488 l[i] = visitExpression(l[i]); |
| 489 } | 489 } |
| 490 } | 490 } |
| 491 } | 491 } |
| 492 | 492 |
| OLD | NEW |