Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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('js_helper'); | 5 #library('js_helper'); |
| 6 | 6 |
| 7 #import('coreimpl.dart'); | 7 #import('coreimpl.dart'); |
| 8 | 8 |
| 9 #source('date_helper.dart'); | 9 #source('date_helper.dart'); |
| 10 #source('regexp_helper.dart'); | 10 #source('regexp_helper.dart'); |
| (...skipping 1123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1134 } | 1134 } |
| 1135 var ret = JS('num', @'parseInt($0, 10)', str); | 1135 var ret = JS('num', @'parseInt($0, 10)', str); |
| 1136 if (ret.isNaN()) throw new BadNumberFormatException(str); | 1136 if (ret.isNaN()) throw new BadNumberFormatException(str); |
| 1137 return ret; | 1137 return ret; |
| 1138 } | 1138 } |
| 1139 | 1139 |
| 1140 static double parseDouble(String str) { | 1140 static double parseDouble(String str) { |
| 1141 checkNull(str); | 1141 checkNull(str); |
| 1142 if (str is !String) throw new IllegalArgumentException(); | 1142 if (str is !String) throw new IllegalArgumentException(); |
| 1143 var ret = JS('num', @'parseFloat($0)', str); | 1143 var ret = JS('num', @'parseFloat($0)', str); |
| 1144 if (ret.isNaN() && str != 'NaN') throw new BadNumberFormatException(str); | 1144 if (ret == 0 && (str.startsWith("0x") || str.startsWith("0X"))) { |
| 1145 // TODO(ahe): This is unspecified, but tested by co19. | |
|
floitsch
2012/02/29 15:33:46
please file a bug that this should not be allowed.
ahe
2012/02/29 18:42:55
I have filed a co19 bug.
| |
| 1146 ret = JS('num', @'parseInt($0)', str); | |
| 1147 } | |
| 1148 if (ret.isNaN() && str != 'NaN' && str != '-NaN') { | |
| 1149 throw new BadNumberFormatException(str); | |
| 1150 } | |
| 1145 return ret; | 1151 return ret; |
| 1146 } | 1152 } |
| 1147 | 1153 |
| 1148 static double sqrt(num value) | 1154 static double sqrt(num value) |
| 1149 => JS('double', @'Math.sqrt($0)', checkNum(value)); | 1155 => JS('double', @'Math.sqrt($0)', checkNum(value)); |
| 1150 | 1156 |
| 1151 static double sin(num value) | 1157 static double sin(num value) |
| 1152 => JS('double', @'Math.sin($0)', checkNum(value)); | 1158 => JS('double', @'Math.sin($0)', checkNum(value)); |
| 1153 | 1159 |
| 1154 static double cos(num value) | 1160 static double cos(num value) |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1281 } | 1287 } |
| 1282 } | 1288 } |
| 1283 } else if (JS('bool', @'$0 instanceof RangeError', ex)) { | 1289 } else if (JS('bool', @'$0 instanceof RangeError', ex)) { |
| 1284 var message = JS('String', @'$0.message', ex); | 1290 var message = JS('String', @'$0.message', ex); |
| 1285 if (message.contains('call stack')) { | 1291 if (message.contains('call stack')) { |
| 1286 return new StackOverflowException(); | 1292 return new StackOverflowException(); |
| 1287 } | 1293 } |
| 1288 } | 1294 } |
| 1289 return ex; | 1295 return ex; |
| 1290 } | 1296 } |
| OLD | NEW |