| 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 1335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1346 makeCondition(node.condition, false, liftNots: false), | 1346 makeCondition(node.condition, false, liftNots: false), |
| 1347 putInBooleanContext(node.thenExpression)); | 1347 putInBooleanContext(node.thenExpression)); |
| 1348 } | 1348 } |
| 1349 // x ? true : y ==> x || y (if y if known to be boolean) | 1349 // x ? true : y ==> x || y (if y if known to be boolean) |
| 1350 if (isBooleanValued(node.elseExpression) && isTrue(node.thenExpression)) { | 1350 if (isBooleanValued(node.elseExpression) && isTrue(node.thenExpression)) { |
| 1351 return new LogicalOperator.or( | 1351 return new LogicalOperator.or( |
| 1352 makeCondition(node.condition, true, liftNots: false), | 1352 makeCondition(node.condition, true, liftNots: false), |
| 1353 putInBooleanContext(node.elseExpression)); | 1353 putInBooleanContext(node.elseExpression)); |
| 1354 } | 1354 } |
| 1355 // x ? false : y ==> !x && y (if y is known to be a boolean) | 1355 // x ? false : y ==> !x && y (if y is known to be a boolean) |
| 1356 if (isBooleanValued(node.elseExpression) && isTrue(node.thenExpression)) { | 1356 if (isBooleanValued(node.elseExpression) && isFalse(node.thenExpression)) { |
| 1357 return new LogicalOperator.and( | 1357 return new LogicalOperator.and( |
| 1358 makeCondition(node.condition, false, liftNots: false), | 1358 makeCondition(node.condition, false, liftNots: false), |
| 1359 putInBooleanContext(node.elseExpression)); | 1359 putInBooleanContext(node.elseExpression)); |
| 1360 } | 1360 } |
| 1361 | 1361 |
| 1362 node.condition = makeCondition(node.condition, true); | 1362 node.condition = makeCondition(node.condition, true); |
| 1363 | 1363 |
| 1364 // !x ? y : z ==> x ? z : y | 1364 // !x ? y : z ==> x ? z : y |
| 1365 if (node.condition is Not) { | 1365 if (node.condition is Not) { |
| 1366 node.condition = (node.condition as Not).operand; | 1366 node.condition = (node.condition as Not).operand; |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1516 | 1516 |
| 1517 Expression makeOr(Expression e1, Expression e2, {bool liftNots: true}) { | 1517 Expression makeOr(Expression e1, Expression e2, {bool liftNots: true}) { |
| 1518 if (e1 is Not && e2 is Not && liftNots) { | 1518 if (e1 is Not && e2 is Not && liftNots) { |
| 1519 return new Not(new LogicalOperator.and(e1.operand, e2.operand)); | 1519 return new Not(new LogicalOperator.and(e1.operand, e2.operand)); |
| 1520 } else { | 1520 } else { |
| 1521 return new LogicalOperator.or(e1, e2); | 1521 return new LogicalOperator.or(e1, e2); |
| 1522 } | 1522 } |
| 1523 } | 1523 } |
| 1524 | 1524 |
| 1525 } | 1525 } |
| OLD | NEW |