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

Side by Side Diff: runtime/lib/integers.dart

Issue 59933004: In preparation of inlining remainder and modulo binary Smi operations: (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 1 month 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 | « runtime/include/dart_native_api.h ('k') | runtime/vm/dart_api_impl.cc » ('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 // TODO(srdjan): fix limitations. 5 // TODO(srdjan): fix limitations.
6 // - shift amount must be a Smi. 6 // - shift amount must be a Smi.
7 class _IntegerImplementation { 7 class _IntegerImplementation {
8 factory _IntegerImplementation._uninstantiable() { 8 factory _IntegerImplementation._uninstantiable() {
9 throw new UnsupportedError( 9 throw new UnsupportedError(
10 "_IntegerImplementation can only be allocated by the VM"); 10 "_IntegerImplementation can only be allocated by the VM");
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 negative = true; 268 negative = true;
269 // Handle the first digit as negative to avoid negating the minimum 269 // Handle the first digit as negative to avoid negating the minimum
270 // smi, for which the negation is not a smi. 270 // smi, for which the negation is not a smi.
271 int digit = -(val.remainder(10)); 271 int digit = -(val.remainder(10));
272 reversed[index++] = digit + 0x30; 272 reversed[index++] = digit + 0x30;
273 val = -(val ~/ 10); 273 val = -(val ~/ 10);
274 } 274 }
275 275
276 while (val > 0) { 276 while (val > 0) {
277 int digit = val % 10; 277 int digit = val % 10;
278 val = val ~/ 10;
278 reversed[index++] = (digit + 0x30); 279 reversed[index++] = (digit + 0x30);
279 val = val ~/ 10;
280 } 280 }
281 if (negative) reversed[index++] = 0x2D; // '-'. 281 if (negative) reversed[index++] = 0x2D; // '-'.
282 282
283 _OneByteString string = _OneByteString._allocate(index); 283 _OneByteString string = _OneByteString._allocate(index);
284 for (int i = 0, j = index; i < index; i++) { 284 for (int i = 0, j = index; i < index; i++) {
285 string._setAt(i, reversed[--j]); 285 string._setAt(i, reversed[--j]);
286 } 286 }
287 return string; 287 return string;
288 } 288 }
289 } 289 }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 } else { 334 } else {
335 return 0; 335 return 0;
336 } 336 }
337 } 337 }
338 int _shlFromInt(int other) native "Bigint_shlFromInt"; 338 int _shlFromInt(int other) native "Bigint_shlFromInt";
339 339
340 int pow(int exponent) { 340 int pow(int exponent) {
341 throw "Bigint.pow not implemented"; 341 throw "Bigint.pow not implemented";
342 } 342 }
343 } 343 }
OLDNEW
« no previous file with comments | « runtime/include/dart_native_api.h ('k') | runtime/vm/dart_api_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698