| 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 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 | 336 |
| 337 Expression visitCreateBox(CreateBox node) { | 337 Expression visitCreateBox(CreateBox node) { |
| 338 return node; | 338 return node; |
| 339 } | 339 } |
| 340 | 340 |
| 341 Expression visitCreateInstance(CreateInstance node) { | 341 Expression visitCreateInstance(CreateInstance node) { |
| 342 _rewriteList(node.arguments); | 342 _rewriteList(node.arguments); |
| 343 return node; | 343 return node; |
| 344 } | 344 } |
| 345 | 345 |
| 346 Expression visitReifyRuntimeType(ReifyRuntimeType node) { |
| 347 node.value = visitExpression(node.value); |
| 348 return node; |
| 349 } |
| 350 |
| 351 Expression visitReadTypeVariable(ReadTypeVariable node) { |
| 352 node.target = visitExpression(node.target); |
| 353 return node; |
| 354 } |
| 355 |
| 346 /// True if the given expression is known to evaluate to a boolean. | 356 /// True if the given expression is known to evaluate to a boolean. |
| 347 /// This will not recursively traverse [Conditional] expressions, but if | 357 /// This will not recursively traverse [Conditional] expressions, but if |
| 348 /// applied to the result of [visitExpression] conditionals will have been | 358 /// applied to the result of [visitExpression] conditionals will have been |
| 349 /// rewritten anyway. | 359 /// rewritten anyway. |
| 350 bool isBooleanValued(Expression e) { | 360 bool isBooleanValued(Expression e) { |
| 351 return isTrue(e) || isFalse(e) || e is Not || e is LogicalOperator; | 361 return isTrue(e) || isFalse(e) || e is Not || e is LogicalOperator; |
| 352 } | 362 } |
| 353 | 363 |
| 354 /// Rewrite an expression that was originally processed in a non-boolean | 364 /// Rewrite an expression that was originally processed in a non-boolean |
| 355 /// context. | 365 /// context. |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 489 } | 499 } |
| 490 | 500 |
| 491 /// Destructively updates each entry of [l] with the result of visiting it. | 501 /// Destructively updates each entry of [l] with the result of visiting it. |
| 492 void _rewriteList(List<Expression> l) { | 502 void _rewriteList(List<Expression> l) { |
| 493 for (int i = 0; i < l.length; i++) { | 503 for (int i = 0; i < l.length; i++) { |
| 494 l[i] = visitExpression(l[i]); | 504 l[i] = visitExpression(l[i]); |
| 495 } | 505 } |
| 496 } | 506 } |
| 497 } | 507 } |
| 498 | 508 |
| OLD | NEW |