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 dart2js.cps_ir.optimizers; | 5 library dart2js.cps_ir.optimizers; |
6 | 6 |
7 import 'cps_ir_nodes.dart'; | 7 import 'cps_ir_nodes.dart'; |
8 import '../constants/values.dart'; | 8 import '../constants/values.dart'; |
9 | 9 |
10 export 'type_propagation.dart' show TypePropagator; | 10 export 'type_propagation.dart' show TypePropagator; |
(...skipping 19 matching lines...) Expand all Loading... |
30 | 30 |
31 /// Returns true if [value] is false, null, 0, -0, NaN, or the empty string. | 31 /// Returns true if [value] is false, null, 0, -0, NaN, or the empty string. |
32 bool isFalsyConstant(ConstantValue value) { | 32 bool isFalsyConstant(ConstantValue value) { |
33 return value.isFalse || | 33 return value.isFalse || |
34 value.isNull || | 34 value.isNull || |
35 value.isZero || | 35 value.isZero || |
36 value.isMinusZero || | 36 value.isMinusZero || |
37 value.isNaN || | 37 value.isNaN || |
38 value is StringConstantValue && value.primitiveValue.isEmpty; | 38 value is StringConstantValue && value.primitiveValue.isEmpty; |
39 } | 39 } |
| 40 |
| 41 /// Returns true if [value] satisfies a branching condition with the |
| 42 /// given strictness. |
| 43 /// |
| 44 /// For non-strict, this is the opposite of [isFalsyConstant]. |
| 45 bool isTruthyConstant(ConstantValue value, {bool strict: false}) { |
| 46 return strict ? value.isTrue : !isFalsyConstant(value); |
| 47 } |
OLD | NEW |