Parcourir la source

rename existing BigInt to BigUInt

Duong Nguyen-Huu il y a 7 ans
Parent
commit
dbeedc3f1d

+ 12 - 12
bin/NativeTests/BigIntTest.cpp → bin/NativeTests/BigUIntTest.cpp

@@ -9,19 +9,19 @@
 #pragma warning(disable:26451) // Arithmetic overflow
 #pragma warning(disable:26495) // Uninitialized member variable
 #include "catch.hpp"
-#include "BigIntTest.h"
+#include "BigUIntTest.h"
 
 #pragma warning(disable:4100) // unreferenced formal parameter
 #pragma warning(disable:6387) // suppressing preFAST which raises warning for passing null to the JsRT APIs
 #pragma warning(disable:6262) // CATCH is using stack variables to report errors, suppressing the preFAST warning.
 
-namespace BigIntTest
+namespace BigUIntTest
 {
-    TEST_CASE("Init_Compare", "[BigIntTest]")
+    TEST_CASE("Init_Compare", "[BigUIntTest]")
     {
         uint32 digits[1];
         int32 length = 1;
-        Js::BigInt bi1, bi2;
+        Js::BigUInt bi1, bi2;
         BOOL f;
         int result;
 
@@ -64,11 +64,11 @@ namespace BigIntTest
         }
     }
 
-    TEST_CASE("Addition", "[BigIntTest]")
+    TEST_CASE("Addition", "[BigUIntTest]")
     {
         uint32 digits[1], digit1s[2];
         int32 length = 1;
-        Js::BigInt bi1, bi2, bi3;
+        Js::BigUInt bi1, bi2, bi3;
         BOOL f;
         int result;
 
@@ -126,11 +126,11 @@ namespace BigIntTest
         }
     }
 
-    TEST_CASE("Addition_Subtraction_Large_Number", "[BigIntTest]")
+    TEST_CASE("Addition_Subtraction_Large_Number", "[BigUIntTest]")
     {
         const int l1 = 50, l2 = 1;
         uint32 digit1s[l1], digit2s[l2];
-        Js::BigInt bi1, bi2;
+        Js::BigUInt bi1, bi2;
         BOOL f;
 
         SECTION("Check 0xf...0xf + 0x1 = 0x1_0x0...0x0")
@@ -158,11 +158,11 @@ namespace BigIntTest
         }
     }
 
-    TEST_CASE("Subtraction", "[BigIntTest]")
+    TEST_CASE("Subtraction", "[BigUIntTest]")
     {
         uint32 digits[1], digit1s[2];
         int32 length = 1;
-        Js::BigInt bi1, bi2, bi3;
+        Js::BigUInt bi1, bi2, bi3;
         BOOL f;
         int result;
 
@@ -223,9 +223,9 @@ namespace BigIntTest
         }
     }
 
-    TEST_CASE("Init_From_Char_Of_Digits", "[BigIntTest]")
+    TEST_CASE("Init_From_Char_Of_Digits", "[BigUIntTest]")
     {
-        BigInt biDec;
+        BigUInt biDec;
         char *charDigit;
         bool result;
         int charDigitLength;

+ 2 - 2
bin/NativeTests/BigIntTest.h → bin/NativeTests/BigUIntTest.h

@@ -45,5 +45,5 @@ AutoSystemInfo AutoSystemInfo::Data;
 void AutoSystemInfo::Initialize(void){}
 #endif
 
-#include "..\..\lib\Common\DataStructures\BigInt.h"
-#include "..\..\lib\Common\DataStructures\BigInt.cpp"
+#include "..\..\lib\Common\DataStructures\BigUInt.h"
+#include "..\..\lib\Common\DataStructures\BigUInt.cpp"

+ 1 - 1
bin/NativeTests/NativeTests.vcxproj

@@ -48,7 +48,7 @@
     <ClInclude Include="stdafx.h" />
   </ItemGroup>
   <ItemGroup>
-    <ClCompile Include="BigIntTest.cpp" />
+    <ClCompile Include="BigUIntTest.cpp" />
     <ClCompile Include="CodexAssert.cpp" />
     <ClCompile Include="CodexTests.cpp" />
     <ClCompile Include="FileLoadHelpers.cpp" />

+ 5 - 5
lib/Common/Common/NumberUtilities_strtod.cpp

@@ -3,7 +3,7 @@
 // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
 //-------------------------------------------------------------------------------------------------------
 #include "CommonCommonPch.h"
-#include "DataStructures/BigInt.h"
+#include "DataStructures/BigUInt.h"
 
 namespace Js
 {
@@ -719,7 +719,7 @@ and re-compare.
 template <typename EncodedChar>
 static double AdjustDbl(double dbl, const EncodedChar *prgch, int32 cch, int32 lwExp)
 {
-    Js::BigInt biDec, biDbl;
+    Js::BigUInt biDec, biDbl;
     int32 c2Dec, c2Dbl;
     int32 c5Dec, c5Dbl;
     int wAddHi, wT;
@@ -1272,9 +1272,9 @@ static BOOL FDblToRgbPrecise(double dbl, __out_ecount(kcbMaxRgb) byte *prgb, int
     int wExp10, wExp2, w1, w2;
     int c2Num, c2Den, c5Num, c5Den;
     double dblT;
-    Js::BigInt biNum, biDen, biHi, biLo;
-    Js::BigInt *pbiLo;
-    Js::BigInt biT;
+    Js::BigUInt biNum, biDen, biHi, biLo;
+    Js::BigUInt *pbiLo;
+    Js::BigUInt biT;
     uint32 rglu[2];
 
     // Caller should take care of 0, negative and non-finite values.

+ 23 - 23
lib/Common/DataStructures/BigInt.cpp → lib/Common/DataStructures/BigUInt.cpp

@@ -3,20 +3,20 @@
 // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
 //-------------------------------------------------------------------------------------------------------
 #include "CommonDataStructuresPch.h"
-#include "DataStructures/BigInt.h"
+#include "DataStructures/BigUInt.h"
 #include "Common/NumberUtilitiesBase.h"
 #include "Common/NumberUtilities.h"
 
 namespace Js
 {
-    BigInt & BigInt::operator= (BigInt &bi)
+    BigUInt & BigUInt::operator= (BigUInt &bi)
     {
         AssertMsg(false, "can't assign BigInts");
         return *this;
     }
 
 #if DBG
-    void BigInt::AssertValid(bool fCheckVal)
+    void BigUInt::AssertValid(bool fCheckVal)
     {
         Assert(m_cluMax >= kcluMaxInit);
         Assert(m_prglu != 0);
@@ -26,7 +26,7 @@ namespace Js
     }
 #endif
 
-    BigInt::BigInt(void)
+    BigUInt::BigUInt(void)
     {
         m_cluMax = kcluMaxInit;
         m_clu = 0;
@@ -34,25 +34,25 @@ namespace Js
         AssertBi(this);
     }
 
-    BigInt::~BigInt(void)
+    BigUInt::~BigUInt(void)
     {
         if (m_prglu != m_rgluInit)
             free(m_prglu);
     }
 
-    int32 BigInt::Clu(void)
+    int32 BigUInt::Clu(void)
     {
         return m_clu;
     }
 
-    uint32 BigInt::Lu(int32 ilu)
+    uint32 BigUInt::Lu(int32 ilu)
     {
         AssertBi(this);
         Assert(ilu < m_clu);
         return m_prglu[ilu];
     }
 
-    bool BigInt::FResize(int32 clu)
+    bool BigUInt::FResize(int32 clu)
     {
         AssertBiNoVal(this);
 
@@ -79,7 +79,7 @@ namespace Js
         return true;
     }
 
-    bool BigInt::FInitFromRglu(uint32 *prglu, int32 clu)
+    bool BigUInt::FInitFromRglu(uint32 *prglu, int32 clu)
     {
         AssertBi(this);
         Assert(clu >= 0);
@@ -95,7 +95,7 @@ namespace Js
         return true;
     }
 
-    bool BigInt::FInitFromBigint(BigInt *pbiSrc)
+    bool BigUInt::FInitFromBigint(BigUInt *pbiSrc)
     {
         AssertBi(this);
         AssertBi(pbiSrc);
@@ -105,7 +105,7 @@ namespace Js
     }
 
     template <typename EncodedChar>
-    bool BigInt::FInitFromDigits(const EncodedChar *prgch, int32 cch, int32 *pcchDig)
+    bool BigUInt::FInitFromDigits(const EncodedChar *prgch, int32 cch, int32 *pcchDig)
     {
         AssertBi(this);
         Assert(cch >= 0);
@@ -147,7 +147,7 @@ namespace Js
         return true;
     }
 
-    bool BigInt::FMulAdd(uint32 luMul, uint32 luAdd)
+    bool BigUInt::FMulAdd(uint32 luMul, uint32 luAdd)
     {
         AssertBi(this);
         Assert(luMul != 0);
@@ -174,7 +174,7 @@ LDone:
         return true;
     }
 
-    bool BigInt::FMulPow5(int32 c5)
+    bool BigUInt::FMulPow5(int32 c5)
     {
         AssertBi(this);
         Assert(c5 >= 0);
@@ -203,7 +203,7 @@ LDone:
         return true;
     }
 
-    bool BigInt::FShiftLeft(int32 cbit)
+    bool BigUInt::FShiftLeft(int32 cbit)
     {
         AssertBi(this);
         Assert(cbit >= 0);
@@ -258,7 +258,7 @@ LDone:
         return true;
     }
 
-    void BigInt::ShiftLusRight(int32 clu)
+    void BigUInt::ShiftLusRight(int32 clu)
     {
         AssertBi(this);
         Assert(clu >= 0);
@@ -278,7 +278,7 @@ LDone:
         AssertBi(this);
     }
 
-    void BigInt::ShiftRight(int32 cbit)
+    void BigUInt::ShiftRight(int32 cbit)
     {
         AssertBi(this);
         Assert(cbit >= 0);
@@ -312,7 +312,7 @@ LDone:
         AssertBi(this);
     }
 
-    int BigInt::Compare(BigInt *pbi)
+    int BigUInt::Compare(BigUInt *pbi)
     {
         AssertBi(this);
         AssertBi(pbi);
@@ -338,7 +338,7 @@ LDone:
         return (m_prglu[ilu] > pbi->m_prglu[ilu]) ? 1 : -1;
     }
 
-    bool BigInt::FAdd(BigInt *pbi)
+    bool BigUInt::FAdd(BigUInt *pbi)
     {
         AssertBi(this);
         AssertBi(pbi);
@@ -391,7 +391,7 @@ LDone:
         return true;
     }
 
-    void BigInt::Subtract(BigInt *pbi)
+    void BigUInt::Subtract(BigUInt *pbi)
     {
         AssertBi(this);
         AssertBi(pbi);
@@ -443,7 +443,7 @@ LNegative:
         AssertBi(this);
     }
 
-    int BigInt::DivRem(BigInt *pbi)
+    int BigUInt::DivRem(BigUInt *pbi)
     {
         AssertBi(this);
         AssertBi(pbi);
@@ -510,7 +510,7 @@ LNegative:
         return wQuo;
     }
 
-    double BigInt::GetDbl(void)
+    double BigUInt::GetDbl(void)
     {
         double dbl;
         uint32 luHi, luLo;
@@ -591,6 +591,6 @@ LNegative:
         return dbl;
     }
 
-    template bool BigInt::FInitFromDigits<char16>(const char16 *prgch, int32 cch, int32 *pcchDig);
-    template bool BigInt::FInitFromDigits<utf8char_t>(const utf8char_t *prgch, int32 cch, int32 *pcchDig);
+    template bool BigUInt::FInitFromDigits<char16>(const char16 *prgch, int32 cch, int32 *pcchDig);
+    template bool BigUInt::FInitFromDigits<utf8char_t>(const utf8char_t *prgch, int32 cch, int32 *pcchDig);
 }

+ 9 - 9
lib/Common/DataStructures/BigInt.h → lib/Common/DataStructures/BigUInt.h

@@ -9,7 +9,7 @@ namespace Js
     /***************************************************************************
         Big non-negative integer class.
     ***************************************************************************/
-    class BigInt
+    class BigUInt
     {
         // Non-negative BigInt is stored as an array of 'digit' where each digit is unit32
     private:
@@ -21,7 +21,7 @@ namespace Js
         uint32 *m_prglu; // pointer to array of digits
         uint32 m_rgluInit[kcluMaxInit]; // pre-defined space to store array
 
-        inline BigInt & operator= (BigInt &bi);
+        inline BigUInt & operator= (BigUInt &bi);
         bool FResize(int32 clu);// allocate more space if length go over maximum
 
 #if DBG
@@ -34,11 +34,11 @@ namespace Js
 #endif //!DBG
 
     public:
-        BigInt(void);
-        ~BigInt(void);
+        BigUInt(void);
+        ~BigUInt(void);
 
         bool FInitFromRglu(uint32 *prglu, int32 clu); // init from array and length
-        bool FInitFromBigint(BigInt *pbiSrc); 
+        bool FInitFromBigint(BigUInt *pbiSrc); 
         template <typename EncodedChar>
         bool FInitFromDigits(const EncodedChar *prgch, int32 cch, int32 *pcchDec); // init from char of digits
         bool FMulAdd(uint32 luMul, uint32 luAdd);
@@ -46,10 +46,10 @@ namespace Js
         bool FShiftLeft(int32 cbit);
         void ShiftLusRight(int32 clu);
         void ShiftRight(int32 cbit);
-        int Compare(BigInt *pbi);
-        bool FAdd(BigInt *pbi);
-        void Subtract(BigInt *pbi);
-        int DivRem(BigInt *pbi);
+        int Compare(BigUInt *pbi);
+        bool FAdd(BigUInt *pbi);
+        void Subtract(BigUInt *pbi);
+        int DivRem(BigUInt *pbi);
 
         int32 Clu(void); // return current length
         uint32 Lu(int32 ilu); // return digit at position ilu start from 0

+ 1 - 1
lib/Common/DataStructures/CMakeLists.txt

@@ -1,5 +1,5 @@
 add_library (Chakra.Common.DataStructures OBJECT
-    BigInt.cpp
+    BigUInt.cpp
     BufferBuilder.cpp
     CommonDataStructuresPch.cpp
     DictionaryStats.cpp

+ 2 - 2
lib/Common/DataStructures/Chakra.Common.DataStructures.vcxproj

@@ -29,7 +29,7 @@
     </ClCompile>
   </ItemDefinitionGroup>
   <ItemGroup>
-    <ClCompile Include="$(MSBuildThisFileDirectory)BigInt.cpp" />
+    <ClCompile Include="$(MSBuildThisFileDirectory)BigUInt.cpp" />
     <ClCompile Include="$(MSBuildThisFileDirectory)BufferBuilder.cpp" />
     <ClCompile Include="$(MSBuildThisFileDirectory)DictionaryStats.cpp" />
     <ClCompile Include="$(MSBuildThisFileDirectory)GrowingArray.cpp" />
@@ -45,7 +45,7 @@
     </ClCompile>
   </ItemGroup>
   <ItemGroup>
-    <ClInclude Include="BigInt.h" />
+    <ClInclude Include="BigUInt.h" />
     <ClInclude Include="BaseDictionary.h" />
     <ClInclude Include="BufferBuilder.h" />
     <ClInclude Include="Cache.h" />

+ 2 - 2
lib/Runtime/Library/JavascriptString.cpp

@@ -4,7 +4,7 @@
 //-------------------------------------------------------------------------------------------------------
 #include "RuntimeLibraryPch.h"
 
-#include "DataStructures/BigInt.h"
+#include "DataStructures/BigUInt.h"
 #include "Library/EngineInterfaceObject.h"
 #include "Library/IntlEngineInterfaceExtensionObject.h"
 
@@ -2962,7 +2962,7 @@ case_2:
             return JavascriptNumber::ToVar(value, this->GetScriptContext());
         }
 
-        BigInt bi;
+        BigUInt bi;
         for ( ; pch < pchEnd ; pch++)
         {
             char16 ch = *pch;