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 analyzer.src.generated.utilities_general; | 5 library analyzer.src.generated.utilities_general; |
6 | 6 |
7 import 'dart:collection'; | 7 import 'dart:collection'; |
8 import 'dart:developer' show UserTag; | 8 import 'dart:developer' show UserTag; |
9 | 9 |
10 export 'package:front_end/src/base/jenkins_smi_hash.dart' show JenkinsSmiHash; | 10 export 'package:front_end/src/base/jenkins_smi_hash.dart' show JenkinsSmiHash; |
11 | 11 |
12 /** | 12 /** |
13 * Test if the given [value] is `false` or the string "false" (case-insensitive)
. | 13 * Test if the given [value] is `false` or the string "false" (case-insensitive)
. |
14 */ | 14 */ |
15 bool isFalse(Object value) => | 15 bool isFalse(Object value) => |
16 value is bool ? !value : toLowerCase(value) == 'false'; | 16 value is bool ? !value : toLowerCase(value) == 'false'; |
17 | 17 |
18 /** | 18 /** |
19 * Test if the given [value] is `true` or the string "true" (case-insensitive). | 19 * Test if the given [value] is `true` or the string "true" (case-insensitive). |
20 */ | 20 */ |
21 bool isTrue(Object value) => | 21 bool isTrue(Object value) => |
22 value is bool ? value : toLowerCase(value) == 'true'; | 22 value is bool ? value : toLowerCase(value) == 'true'; |
23 | 23 |
24 /** | 24 /** |
25 * Safely convert the given [value] to a bool value, or return `null` if the | 25 * Safely convert the given [value] to a bool value, or return `null` if the |
26 * value coult not be converted. | 26 * value could not be converted. |
27 */ | 27 */ |
28 bool toBool(Object value) { | 28 bool toBool(Object value) { |
29 if (value is bool) { | 29 if (value is bool) { |
30 return value; | 30 return value; |
31 } | 31 } |
32 String string = toLowerCase(value); | 32 String string = toLowerCase(value); |
33 if (string == 'true') { | 33 if (string == 'true') { |
34 return true; | 34 return true; |
35 } | 35 } |
36 if (string == 'false') { | 36 if (string == 'false') { |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 | 185 |
186 dynamic/*=E*/ makeCurrentWhile/*<E>*/(dynamic/*=E*/ f()) { | 186 dynamic/*=E*/ makeCurrentWhile/*<E>*/(dynamic/*=E*/ f()) { |
187 PerformanceTag prevTag = makeCurrent(); | 187 PerformanceTag prevTag = makeCurrent(); |
188 try { | 188 try { |
189 return f(); | 189 return f(); |
190 } finally { | 190 } finally { |
191 prevTag.makeCurrent(); | 191 prevTag.makeCurrent(); |
192 } | 192 } |
193 } | 193 } |
194 } | 194 } |
OLD | NEW |