Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(581)

Side by Side Diff: frog/leg/lib/js_helper.dart

Issue 9595013: parseInt fixes. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Update status file. Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | frog/lib/math.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1112 matching lines...) Expand 10 before | Expand all | Expand 10 after
1123 checkNull(receiver); 1123 checkNull(receiver);
1124 if (receiver is !String) return UNINTERCEPTED(receiver.trim()); 1124 if (receiver is !String) return UNINTERCEPTED(receiver.trim());
1125 1125
1126 return JS('String', @'$0.trim()', receiver); 1126 return JS('String', @'$0.trim()', receiver);
1127 } 1127 }
1128 1128
1129 class MathNatives { 1129 class MathNatives {
1130 static int parseInt(str) { 1130 static int parseInt(str) {
1131 checkNull(str); 1131 checkNull(str);
1132 if (str is !String) throw new IllegalArgumentException(str); 1132 if (str is !String) throw new IllegalArgumentException(str);
1133 if (!JS('bool', @'/^\s*[+-]?(0[xX])?\d+\s*$/.test($0)', str)) { 1133 if (!JS('bool',
1134 @'/^\s*[+-]?(?:0[xX][abcdefABCDEF0-9]+|\d+)\s*$/.test($0)',
1135 str)) {
1134 throw new BadNumberFormatException(str); 1136 throw new BadNumberFormatException(str);
1135 } 1137 }
1136 var trimmed = str.trim(); 1138 var trimmed = str.trim();
1137 var base = 10;; 1139 var base = 10;;
1138 if ((trimmed.length > 2 && (trimmed[1] == 'x' || trimmed[1] == 'X')) || 1140 if ((trimmed.length > 2 && (trimmed[1] == 'x' || trimmed[1] == 'X')) ||
1139 (trimmed.length > 3 && (trimmed[2] == 'x' || trimmed[2] == 'X'))) { 1141 (trimmed.length > 3 && (trimmed[2] == 'x' || trimmed[2] == 'X'))) {
1140 base = 16; 1142 base = 16;
1141 } 1143 }
1142 var ret = JS('num', @'parseInt($0, $1)', trimmed, base); 1144 var ret = JS('num', @'parseInt($0, $1)', trimmed, base);
1143 if (ret.isNaN()) throw new BadNumberFormatException(str); 1145 if (ret.isNaN()) throw new BadNumberFormatException(str);
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
1294 } 1296 }
1295 } 1297 }
1296 } else if (JS('bool', @'$0 instanceof RangeError', ex)) { 1298 } else if (JS('bool', @'$0 instanceof RangeError', ex)) {
1297 var message = JS('String', @'$0.message', ex); 1299 var message = JS('String', @'$0.message', ex);
1298 if (message.contains('call stack')) { 1300 if (message.contains('call stack')) {
1299 return new StackOverflowException(); 1301 return new StackOverflowException();
1300 } 1302 }
1301 } 1303 }
1302 return ex; 1304 return ex;
1303 } 1305 }
OLDNEW
« no previous file with comments | « no previous file | frog/lib/math.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698