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

Side by Side Diff: third_party/WebKit/Source/platform/Decimal.cpp

Issue 2849903002: Replace ASSERT_NOT_REACHED with NOTREACHED in platform/ (Closed)
Patch Set: rebase Created 3 years, 7 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 return kEitherNaN; 100 return kEitherNaN;
101 } 101 }
102 102
103 if (lhs_class == Decimal::EncodedData::kClassInfinity) 103 if (lhs_class == Decimal::EncodedData::kClassInfinity)
104 return rhs_class == Decimal::EncodedData::kClassInfinity ? kBothInfinity 104 return rhs_class == Decimal::EncodedData::kClassInfinity ? kBothInfinity
105 : kLHSIsInfinity; 105 : kLHSIsInfinity;
106 106
107 if (rhs_class == Decimal::EncodedData::kClassInfinity) 107 if (rhs_class == Decimal::EncodedData::kClassInfinity)
108 return kRHSIsInfinity; 108 return kRHSIsInfinity;
109 109
110 ASSERT_NOT_REACHED(); 110 NOTREACHED();
111 return kBothFinite; 111 return kBothFinite;
112 } 112 }
113 113
114 Decimal SpecialValueHandler::Value() const { 114 Decimal SpecialValueHandler::Value() const {
115 switch (result_) { 115 switch (result_) {
116 case kResultIsLHS: 116 case kResultIsLHS:
117 return lhs_; 117 return lhs_;
118 case kResultIsRHS: 118 case kResultIsRHS:
119 return rhs_; 119 return rhs_;
120 case kResultIsUnknown: 120 case kResultIsUnknown:
121 default: 121 default:
122 ASSERT_NOT_REACHED(); 122 NOTREACHED();
123 return lhs_; 123 return lhs_;
124 } 124 }
125 } 125 }
126 126
127 // This class is used for 128 bit unsigned integer arithmetic. 127 // This class is used for 128 bit unsigned integer arithmetic.
128 class UInt128 { 128 class UInt128 {
129 public: 129 public:
130 UInt128(uint64_t low, uint64_t high) : high_(high), low_(low) {} 130 UInt128(uint64_t low, uint64_t high) : high_(high), low_(low) {}
131 131
132 UInt128& operator/=(uint32_t); 132 UInt128& operator/=(uint32_t);
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 case SpecialValueHandler::kEitherNaN: 419 case SpecialValueHandler::kEitherNaN:
420 return handler.Value(); 420 return handler.Value();
421 421
422 case SpecialValueHandler::kLHSIsInfinity: 422 case SpecialValueHandler::kLHSIsInfinity:
423 return rhs.IsZero() ? Nan() : Infinity(result_sign); 423 return rhs.IsZero() ? Nan() : Infinity(result_sign);
424 424
425 case SpecialValueHandler::kRHSIsInfinity: 425 case SpecialValueHandler::kRHSIsInfinity:
426 return lhs.IsZero() ? Nan() : Infinity(result_sign); 426 return lhs.IsZero() ? Nan() : Infinity(result_sign);
427 } 427 }
428 428
429 ASSERT_NOT_REACHED(); 429 NOTREACHED();
430 return Nan(); 430 return Nan();
431 } 431 }
432 432
433 Decimal Decimal::operator/(const Decimal& rhs) const { 433 Decimal Decimal::operator/(const Decimal& rhs) const {
434 const Decimal& lhs = *this; 434 const Decimal& lhs = *this;
435 const Sign lhs_sign = lhs.GetSign(); 435 const Sign lhs_sign = lhs.GetSign();
436 const Sign rhs_sign = rhs.GetSign(); 436 const Sign rhs_sign = rhs.GetSign();
437 const Sign result_sign = lhs_sign == rhs_sign ? kPositive : kNegative; 437 const Sign result_sign = lhs_sign == rhs_sign ? kPositive : kNegative;
438 438
439 SpecialValueHandler handler(lhs, rhs); 439 SpecialValueHandler handler(lhs, rhs);
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
621 return result.IsNegative() ? Decimal(-1) : Decimal(1); 621 return result.IsNegative() ? Decimal(-1) : Decimal(1);
622 622
623 case EncodedData::kClassNaN: 623 case EncodedData::kClassNaN:
624 case EncodedData::kClassNormal: 624 case EncodedData::kClassNormal:
625 return result; 625 return result;
626 626
627 case EncodedData::kClassZero: 627 case EncodedData::kClassZero:
628 return Zero(kPositive); 628 return Zero(kPositive);
629 629
630 default: 630 default:
631 ASSERT_NOT_REACHED(); 631 NOTREACHED();
632 return Nan(); 632 return Nan();
633 } 633 }
634 } 634 }
635 635
636 // Round toward negative infinity. 636 // Round toward negative infinity.
637 Decimal Decimal::Floor() const { 637 Decimal Decimal::Floor() const {
638 if (IsSpecial()) 638 if (IsSpecial())
639 return *this; 639 return *this;
640 640
641 if (Exponent() >= 0) 641 if (Exponent() >= 0)
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
822 number_of_digits = 1; 822 number_of_digits = 1;
823 state = kStateDigit; 823 state = kStateDigit;
824 break; 824 break;
825 } 825 }
826 826
827 HandleCharAndBreak('.', kStateDot); 827 HandleCharAndBreak('.', kStateDot);
828 HandleTwoCharsAndBreak('E', 'e', kStateE); 828 HandleTwoCharsAndBreak('E', 'e', kStateE);
829 return Nan(); 829 return Nan();
830 830
831 default: 831 default:
832 ASSERT_NOT_REACHED(); 832 NOTREACHED();
833 return Nan(); 833 return Nan();
834 } 834 }
835 } 835 }
836 836
837 if (state == kStateZero) 837 if (state == kStateZero)
838 return Zero(sign); 838 return Zero(sign);
839 839
840 if (state == kStateDigit || state == kStateEDigit || 840 if (state == kStateDigit || state == kStateEDigit ||
841 state == kStateDotDigit) { 841 state == kStateDotDigit) {
842 int result_exponent = exponent * (exponent_sign == kNegative ? -1 : 1) - 842 int result_exponent = exponent * (exponent_sign == kNegative ? -1 : 1) -
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
915 return GetSign() ? "-Infinity" : "Infinity"; 915 return GetSign() ? "-Infinity" : "Infinity";
916 916
917 case EncodedData::kClassNaN: 917 case EncodedData::kClassNaN:
918 return "NaN"; 918 return "NaN";
919 919
920 case EncodedData::kClassNormal: 920 case EncodedData::kClassNormal:
921 case EncodedData::kClassZero: 921 case EncodedData::kClassZero:
922 break; 922 break;
923 923
924 default: 924 default:
925 ASSERT_NOT_REACHED(); 925 NOTREACHED();
926 return ""; 926 return "";
927 } 927 }
928 928
929 StringBuilder builder; 929 StringBuilder builder;
930 if (GetSign()) 930 if (GetSign())
931 builder.Append('-'); 931 builder.Append('-');
932 932
933 int original_exponent = Exponent(); 933 int original_exponent = Exponent();
934 uint64_t coefficient = data_.Coefficient(); 934 uint64_t coefficient = data_.Coefficient();
935 935
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
1001 Decimal::EncodedData data = decimal.Value(); 1001 Decimal::EncodedData data = decimal.Value();
1002 return ostream << "encode(" 1002 return ostream << "encode("
1003 << String::Number(data.Coefficient()).Ascii().data() << ", " 1003 << String::Number(data.Coefficient()).Ascii().data() << ", "
1004 << String::Number(data.Exponent()).Ascii().data() << ", " 1004 << String::Number(data.Exponent()).Ascii().data() << ", "
1005 << (data.GetSign() == Decimal::kNegative ? "Negative" 1005 << (data.GetSign() == Decimal::kNegative ? "Negative"
1006 : "Positive") 1006 : "Positive")
1007 << ")=" << decimal.ToString().Ascii().data(); 1007 << ")=" << decimal.ToString().Ascii().data();
1008 } 1008 }
1009 1009
1010 } // namespace blink 1010 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/DateComponents.cpp ('k') | third_party/WebKit/Source/platform/Length.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698