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

Side by Side Diff: pkg/fixnum/int64.dart

Issue 10989013: Change IllegalArgumentException to ArgumentError. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated co19 test expectations. Created 8 years, 2 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
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 /** 5 /**
6 * An immutable 64-bit signed integer, in the range [-2^63, 2^63 - 1]. 6 * An immutable 64-bit signed integer, in the range [-2^63, 2^63 - 1].
7 * Arithmetic operations may overflow in order to maintain this range. 7 * Arithmetic operations may overflow in order to maintain this range.
8 */ 8 */
9 class int64 implements intx { 9 class int64 implements intx {
10 10
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 return new int64._bits(a0, a1, a2); 413 return new int64._bits(a0, a1, a2);
414 } 414 }
415 415
416 int64 operator ~() { 416 int64 operator ~() {
417 var result = new int64._bits((~_l) & _MASK, (~_m) & _MASK, (~_h) & _MASK_2); 417 var result = new int64._bits((~_l) & _MASK, (~_m) & _MASK, (~_h) & _MASK_2);
418 return result; 418 return result;
419 } 419 }
420 420
421 int64 operator <<(int n) { 421 int64 operator <<(int n) {
422 if (n < 0) { 422 if (n < 0) {
423 throw new IllegalArgumentException("$n"); 423 throw new ArgumentError("$n");
424 } 424 }
425 n &= 63; 425 n &= 63;
426 426
427 int res0, res1, res2; 427 int res0, res1, res2;
428 if (n < _BITS) { 428 if (n < _BITS) {
429 res0 = _l << n; 429 res0 = _l << n;
430 res1 = (_m << n) | (_l >> (_BITS - n)); 430 res1 = (_m << n) | (_l >> (_BITS - n));
431 res2 = (_h << n) | (_m >> (_BITS - n)); 431 res2 = (_h << n) | (_m >> (_BITS - n));
432 } else if (n < _BITS01) { 432 } else if (n < _BITS01) {
433 res0 = 0; 433 res0 = 0;
434 res1 = _l << (n - _BITS); 434 res1 = _l << (n - _BITS);
435 res2 = (_m << (n - _BITS)) | (_l >> (_BITS01 - n)); 435 res2 = (_m << (n - _BITS)) | (_l >> (_BITS01 - n));
436 } else { 436 } else {
437 res0 = 0; 437 res0 = 0;
438 res1 = 0; 438 res1 = 0;
439 res2 = _l << (n - _BITS01); 439 res2 = _l << (n - _BITS01);
440 } 440 }
441 441
442 return new int64._bits(res0 & _MASK, res1 & _MASK, res2 & _MASK_2); 442 return new int64._bits(res0 & _MASK, res1 & _MASK, res2 & _MASK_2);
443 } 443 }
444 444
445 int64 operator >>(int n) { 445 int64 operator >>(int n) {
446 if (n < 0) { 446 if (n < 0) {
447 throw new IllegalArgumentException("$n"); 447 throw new ArgumentError("$n");
448 } 448 }
449 n &= 63; 449 n &= 63;
450 450
451 int res0, res1, res2; 451 int res0, res1, res2;
452 452
453 // Sign extend h(a). 453 // Sign extend h(a).
454 int a2 = _h; 454 int a2 = _h;
455 bool negative = (a2 & _SIGN_BIT_VALUE) != 0; 455 bool negative = (a2 & _SIGN_BIT_VALUE) != 0;
456 if (negative) { 456 if (negative) {
457 a2 += 0x3 << _BITS2; // add extra one bits on the left 457 a2 += 0x3 << _BITS2; // add extra one bits on the left
(...skipping 20 matching lines...) Expand all
478 if (negative) { 478 if (negative) {
479 res0 |= _MASK & ~(_MASK >> (n - _BITS01)); 479 res0 |= _MASK & ~(_MASK >> (n - _BITS01));
480 } 480 }
481 } 481 }
482 482
483 return new int64._bits(res0 & _MASK, res1 & _MASK, res2 & _MASK_2); 483 return new int64._bits(res0 & _MASK, res1 & _MASK, res2 & _MASK_2);
484 } 484 }
485 485
486 int64 shiftRightUnsigned(int n) { 486 int64 shiftRightUnsigned(int n) {
487 if (n < 0) { 487 if (n < 0) {
488 throw new IllegalArgumentException("$n"); 488 throw new ArgumentError("$n");
489 } 489 }
490 n &= 63; 490 n &= 63;
491 491
492 int res0, res1, res2; 492 int res0, res1, res2;
493 int a2 = _h & _MASK_2; // Ensure a2 is positive. 493 int a2 = _h & _MASK_2; // Ensure a2 is positive.
494 if (n < _BITS) { 494 if (n < _BITS) {
495 res2 = a2 >> n; 495 res2 = a2 >> n;
496 res1 = (_m >> n) | (a2 << (_BITS - n)); 496 res1 = (_m >> n) | (a2 << (_BITS - n));
497 res0 = (_l >> n) | (_m << (_BITS - n)); 497 res0 = (_l >> n) | (_m << (_BITS - n));
498 } else if (n < _BITS01) { 498 } else if (n < _BITS01) {
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after
1086 } 1086 }
1087 } 1087 }
1088 return ZERO; 1088 return ZERO;
1089 } 1089 }
1090 1090
1091 // Generate the quotient using bit-at-a-time long division. 1091 // Generate the quotient using bit-at-a-time long division.
1092 return _divModHelper(aIsCopy ? a : new int64._copy(a), b, negative, 1092 return _divModHelper(aIsCopy ? a : new int64._copy(a), b, negative,
1093 aIsNegative, aIsMinValue, computeRemainder); 1093 aIsNegative, aIsMinValue, computeRemainder);
1094 } 1094 }
1095 } 1095 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698