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

Side by Side Diff: sdk/lib/_internal/compiler/js_lib/js_number.dart

Issue 988523002: Fix int.parse bug (dart2js version) (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 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 | « sdk/lib/_internal/compiler/js_lib/js_helper.dart ('k') | sdk/lib/core/int.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 part of _interceptors; 5 part of _interceptors;
6 6
7 /** 7 /**
8 * The super interceptor class for [JSInt] and [JSDouble]. The compiler 8 * The super interceptor class for [JSInt] and [JSDouble]. The compiler
9 * recognizes this class as an interceptor, and changes references to 9 * recognizes this class as an interceptor, and changes references to
10 * [:this:] to actually use the receiver of the method, which is 10 * [:this:] to actually use the receiver of the method, which is
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 throw new RangeError(precision); 160 throw new RangeError(precision);
161 } 161 }
162 String result = JS('String', r'#.toPrecision(#)', 162 String result = JS('String', r'#.toPrecision(#)',
163 this, precision); 163 this, precision);
164 if (this == 0 && isNegative) return "-$result"; 164 if (this == 0 && isNegative) return "-$result";
165 return result; 165 return result;
166 } 166 }
167 167
168 String toRadixString(int radix) { 168 String toRadixString(int radix) {
169 checkInt(radix); 169 checkInt(radix);
170 if (radix < 2 || radix > 36) throw new RangeError(radix); 170 if (radix < 2 || radix > 36) {
171 throw new RangeError.range(radix, 2, 36, "radix");
172 }
171 String result = JS('String', r'#.toString(#)', this, radix); 173 String result = JS('String', r'#.toString(#)', this, radix);
172 const int rightParenCode = 0x29; 174 const int rightParenCode = 0x29;
173 if (result.codeUnitAt(result.length - 1) != rightParenCode) { 175 if (result.codeUnitAt(result.length - 1) != rightParenCode) {
174 return result; 176 return result;
175 } 177 }
176 return _handleIEtoString(result); 178 return _handleIEtoString(result);
177 } 179 }
178 180
179 static String _handleIEtoString(String result) { 181 static String _handleIEtoString(String result) {
180 // Result is probably IE's untraditional format for large numbers, 182 // Result is probably IE's untraditional format for large numbers,
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 } 457 }
456 458
457 class JSDouble extends JSNumber implements double { 459 class JSDouble extends JSNumber implements double {
458 const JSDouble(); 460 const JSDouble();
459 Type get runtimeType => double; 461 Type get runtimeType => double;
460 } 462 }
461 463
462 class JSPositiveInt extends JSInt {} 464 class JSPositiveInt extends JSInt {}
463 class JSUInt32 extends JSPositiveInt {} 465 class JSUInt32 extends JSPositiveInt {}
464 class JSUInt31 extends JSUInt32 {} 466 class JSUInt31 extends JSUInt32 {}
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/js_lib/js_helper.dart ('k') | sdk/lib/core/int.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698