| 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 library dart_tree; | 5 library dart_tree; |
| 6 | 6 |
| 7 import '../dart2jslib.dart' as dart2js; | 7 import '../dart2jslib.dart' as dart2js; |
| 8 import '../elements/elements.dart' | 8 import '../elements/elements.dart' |
| 9 show Element, FunctionElement, FunctionSignature, ParameterElement, | 9 show Element, FunctionElement, FunctionSignature, ParameterElement, |
| 10 ClassElement; | 10 ClassElement; |
| (...skipping 1384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1395 makeCondition(node.condition, false, liftNots: false), | 1395 makeCondition(node.condition, false, liftNots: false), |
| 1396 putInBooleanContext(node.thenExpression)); | 1396 putInBooleanContext(node.thenExpression)); |
| 1397 } | 1397 } |
| 1398 // x ? true : y ==> x || y (if y if known to be boolean) | 1398 // x ? true : y ==> x || y (if y if known to be boolean) |
| 1399 if (isBooleanValued(node.elseExpression) && isTrue(node.thenExpression)) { | 1399 if (isBooleanValued(node.elseExpression) && isTrue(node.thenExpression)) { |
| 1400 return new LogicalOperator.or( | 1400 return new LogicalOperator.or( |
| 1401 makeCondition(node.condition, true, liftNots: false), | 1401 makeCondition(node.condition, true, liftNots: false), |
| 1402 putInBooleanContext(node.elseExpression)); | 1402 putInBooleanContext(node.elseExpression)); |
| 1403 } | 1403 } |
| 1404 // x ? false : y ==> !x && y (if y is known to be a boolean) | 1404 // x ? false : y ==> !x && y (if y is known to be a boolean) |
| 1405 if (isBooleanValued(node.elseExpression) && isTrue(node.thenExpression)) { | 1405 if (isBooleanValued(node.elseExpression) && isFalse(node.thenExpression)) { |
| 1406 return new LogicalOperator.and( | 1406 return new LogicalOperator.and( |
| 1407 makeCondition(node.condition, false, liftNots: false), | 1407 makeCondition(node.condition, false, liftNots: false), |
| 1408 putInBooleanContext(node.elseExpression)); | 1408 putInBooleanContext(node.elseExpression)); |
| 1409 } | 1409 } |
| 1410 | 1410 |
| 1411 node.condition = makeCondition(node.condition, true); | 1411 node.condition = makeCondition(node.condition, true); |
| 1412 | 1412 |
| 1413 // !x ? y : z ==> x ? z : y | 1413 // !x ? y : z ==> x ? z : y |
| 1414 if (node.condition is Not) { | 1414 if (node.condition is Not) { |
| 1415 node.condition = (node.condition as Not).operand; | 1415 node.condition = (node.condition as Not).operand; |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1571 } | 1571 } |
| 1572 } | 1572 } |
| 1573 | 1573 |
| 1574 /// Destructively updates each entry of [l] with the result of visiting it. | 1574 /// Destructively updates each entry of [l] with the result of visiting it. |
| 1575 void _rewriteList(List<Expression> l) { | 1575 void _rewriteList(List<Expression> l) { |
| 1576 for (int i = 0; i < l.length; i++) { | 1576 for (int i = 0; i < l.length; i++) { |
| 1577 l[i] = visitExpression(l[i]); | 1577 l[i] = visitExpression(l[i]); |
| 1578 } | 1578 } |
| 1579 } | 1579 } |
| 1580 } | 1580 } |
| OLD | NEW |