Skip to content

Commit e2ca437

Browse files
committed
[MERGE #5665 @duongnhn] rename existing BigInt class to BigUInt since it support unsigned only
Merge pull request #5665 from duongnhn:user/duongn/rename-biguint rename existing class to BigUInt since it only support unsigned number
2 parents f54b1f2 + dbeedc3 commit e2ca437

9 files changed

+57
-57
lines changed

bin/NativeTests/BigIntTest.cpp bin/NativeTests/BigUIntTest.cpp

+12-12
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,19 @@
99
#pragma warning(disable:26451) // Arithmetic overflow
1010
#pragma warning(disable:26495) // Uninitialized member variable
1111
#include "catch.hpp"
12-
#include "BigIntTest.h"
12+
#include "BigUIntTest.h"
1313

1414
#pragma warning(disable:4100) // unreferenced formal parameter
1515
#pragma warning(disable:6387) // suppressing preFAST which raises warning for passing null to the JsRT APIs
1616
#pragma warning(disable:6262) // CATCH is using stack variables to report errors, suppressing the preFAST warning.
1717

18-
namespace BigIntTest
18+
namespace BigUIntTest
1919
{
20-
TEST_CASE("Init_Compare", "[BigIntTest]")
20+
TEST_CASE("Init_Compare", "[BigUIntTest]")
2121
{
2222
uint32 digits[1];
2323
int32 length = 1;
24-
Js::BigInt bi1, bi2;
24+
Js::BigUInt bi1, bi2;
2525
BOOL f;
2626
int result;
2727

@@ -64,11 +64,11 @@ namespace BigIntTest
6464
}
6565
}
6666

67-
TEST_CASE("Addition", "[BigIntTest]")
67+
TEST_CASE("Addition", "[BigUIntTest]")
6868
{
6969
uint32 digits[1], digit1s[2];
7070
int32 length = 1;
71-
Js::BigInt bi1, bi2, bi3;
71+
Js::BigUInt bi1, bi2, bi3;
7272
BOOL f;
7373
int result;
7474

@@ -126,11 +126,11 @@ namespace BigIntTest
126126
}
127127
}
128128

129-
TEST_CASE("Addition_Subtraction_Large_Number", "[BigIntTest]")
129+
TEST_CASE("Addition_Subtraction_Large_Number", "[BigUIntTest]")
130130
{
131131
const int l1 = 50, l2 = 1;
132132
uint32 digit1s[l1], digit2s[l2];
133-
Js::BigInt bi1, bi2;
133+
Js::BigUInt bi1, bi2;
134134
BOOL f;
135135

136136
SECTION("Check 0xf...0xf + 0x1 = 0x1_0x0...0x0")
@@ -158,11 +158,11 @@ namespace BigIntTest
158158
}
159159
}
160160

161-
TEST_CASE("Subtraction", "[BigIntTest]")
161+
TEST_CASE("Subtraction", "[BigUIntTest]")
162162
{
163163
uint32 digits[1], digit1s[2];
164164
int32 length = 1;
165-
Js::BigInt bi1, bi2, bi3;
165+
Js::BigUInt bi1, bi2, bi3;
166166
BOOL f;
167167
int result;
168168

@@ -223,9 +223,9 @@ namespace BigIntTest
223223
}
224224
}
225225

226-
TEST_CASE("Init_From_Char_Of_Digits", "[BigIntTest]")
226+
TEST_CASE("Init_From_Char_Of_Digits", "[BigUIntTest]")
227227
{
228-
BigInt biDec;
228+
BigUInt biDec;
229229
char *charDigit;
230230
bool result;
231231
int charDigitLength;

bin/NativeTests/BigIntTest.h bin/NativeTests/BigUIntTest.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,5 @@ AutoSystemInfo AutoSystemInfo::Data;
4545
void AutoSystemInfo::Initialize(void){}
4646
#endif
4747

48-
#include "..\..\lib\Common\DataStructures\BigInt.h"
49-
#include "..\..\lib\Common\DataStructures\BigInt.cpp"
48+
#include "..\..\lib\Common\DataStructures\BigUInt.h"
49+
#include "..\..\lib\Common\DataStructures\BigUInt.cpp"

bin/NativeTests/NativeTests.vcxproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
<ClInclude Include="stdafx.h" />
4949
</ItemGroup>
5050
<ItemGroup>
51-
<ClCompile Include="BigIntTest.cpp" />
51+
<ClCompile Include="BigUIntTest.cpp" />
5252
<ClCompile Include="CodexAssert.cpp" />
5353
<ClCompile Include="CodexTests.cpp" />
5454
<ClCompile Include="FileLoadHelpers.cpp" />

lib/Common/Common/NumberUtilities_strtod.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
44
//-------------------------------------------------------------------------------------------------------
55
#include "CommonCommonPch.h"
6-
#include "DataStructures/BigInt.h"
6+
#include "DataStructures/BigUInt.h"
77

88
namespace Js
99
{
@@ -719,7 +719,7 @@ and re-compare.
719719
template <typename EncodedChar>
720720
static double AdjustDbl(double dbl, const EncodedChar *prgch, int32 cch, int32 lwExp)
721721
{
722-
Js::BigInt biDec, biDbl;
722+
Js::BigUInt biDec, biDbl;
723723
int32 c2Dec, c2Dbl;
724724
int32 c5Dec, c5Dbl;
725725
int wAddHi, wT;
@@ -1272,9 +1272,9 @@ static BOOL FDblToRgbPrecise(double dbl, __out_ecount(kcbMaxRgb) byte *prgb, int
12721272
int wExp10, wExp2, w1, w2;
12731273
int c2Num, c2Den, c5Num, c5Den;
12741274
double dblT;
1275-
Js::BigInt biNum, biDen, biHi, biLo;
1276-
Js::BigInt *pbiLo;
1277-
Js::BigInt biT;
1275+
Js::BigUInt biNum, biDen, biHi, biLo;
1276+
Js::BigUInt *pbiLo;
1277+
Js::BigUInt biT;
12781278
uint32 rglu[2];
12791279

12801280
// Caller should take care of 0, negative and non-finite values.

lib/Common/DataStructures/BigInt.cpp lib/Common/DataStructures/BigUInt.cpp

+23-23
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@
33
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
44
//-------------------------------------------------------------------------------------------------------
55
#include "CommonDataStructuresPch.h"
6-
#include "DataStructures/BigInt.h"
6+
#include "DataStructures/BigUInt.h"
77
#include "Common/NumberUtilitiesBase.h"
88
#include "Common/NumberUtilities.h"
99

1010
namespace Js
1111
{
12-
BigInt & BigInt::operator= (BigInt &bi)
12+
BigUInt & BigUInt::operator= (BigUInt &bi)
1313
{
1414
AssertMsg(false, "can't assign BigInts");
1515
return *this;
1616
}
1717

1818
#if DBG
19-
void BigInt::AssertValid(bool fCheckVal)
19+
void BigUInt::AssertValid(bool fCheckVal)
2020
{
2121
Assert(m_cluMax >= kcluMaxInit);
2222
Assert(m_prglu != 0);
@@ -26,33 +26,33 @@ namespace Js
2626
}
2727
#endif
2828

29-
BigInt::BigInt(void)
29+
BigUInt::BigUInt(void)
3030
{
3131
m_cluMax = kcluMaxInit;
3232
m_clu = 0;
3333
m_prglu = m_rgluInit;
3434
AssertBi(this);
3535
}
3636

37-
BigInt::~BigInt(void)
37+
BigUInt::~BigUInt(void)
3838
{
3939
if (m_prglu != m_rgluInit)
4040
free(m_prglu);
4141
}
4242

43-
int32 BigInt::Clu(void)
43+
int32 BigUInt::Clu(void)
4444
{
4545
return m_clu;
4646
}
4747

48-
uint32 BigInt::Lu(int32 ilu)
48+
uint32 BigUInt::Lu(int32 ilu)
4949
{
5050
AssertBi(this);
5151
Assert(ilu < m_clu);
5252
return m_prglu[ilu];
5353
}
5454

55-
bool BigInt::FResize(int32 clu)
55+
bool BigUInt::FResize(int32 clu)
5656
{
5757
AssertBiNoVal(this);
5858

@@ -79,7 +79,7 @@ namespace Js
7979
return true;
8080
}
8181

82-
bool BigInt::FInitFromRglu(uint32 *prglu, int32 clu)
82+
bool BigUInt::FInitFromRglu(uint32 *prglu, int32 clu)
8383
{
8484
AssertBi(this);
8585
Assert(clu >= 0);
@@ -95,7 +95,7 @@ namespace Js
9595
return true;
9696
}
9797

98-
bool BigInt::FInitFromBigint(BigInt *pbiSrc)
98+
bool BigUInt::FInitFromBigint(BigUInt *pbiSrc)
9999
{
100100
AssertBi(this);
101101
AssertBi(pbiSrc);
@@ -105,7 +105,7 @@ namespace Js
105105
}
106106

107107
template <typename EncodedChar>
108-
bool BigInt::FInitFromDigits(const EncodedChar *prgch, int32 cch, int32 *pcchDig)
108+
bool BigUInt::FInitFromDigits(const EncodedChar *prgch, int32 cch, int32 *pcchDig)
109109
{
110110
AssertBi(this);
111111
Assert(cch >= 0);
@@ -147,7 +147,7 @@ namespace Js
147147
return true;
148148
}
149149

150-
bool BigInt::FMulAdd(uint32 luMul, uint32 luAdd)
150+
bool BigUInt::FMulAdd(uint32 luMul, uint32 luAdd)
151151
{
152152
AssertBi(this);
153153
Assert(luMul != 0);
@@ -174,7 +174,7 @@ namespace Js
174174
return true;
175175
}
176176

177-
bool BigInt::FMulPow5(int32 c5)
177+
bool BigUInt::FMulPow5(int32 c5)
178178
{
179179
AssertBi(this);
180180
Assert(c5 >= 0);
@@ -203,7 +203,7 @@ namespace Js
203203
return true;
204204
}
205205

206-
bool BigInt::FShiftLeft(int32 cbit)
206+
bool BigUInt::FShiftLeft(int32 cbit)
207207
{
208208
AssertBi(this);
209209
Assert(cbit >= 0);
@@ -258,7 +258,7 @@ namespace Js
258258
return true;
259259
}
260260

261-
void BigInt::ShiftLusRight(int32 clu)
261+
void BigUInt::ShiftLusRight(int32 clu)
262262
{
263263
AssertBi(this);
264264
Assert(clu >= 0);
@@ -278,7 +278,7 @@ namespace Js
278278
AssertBi(this);
279279
}
280280

281-
void BigInt::ShiftRight(int32 cbit)
281+
void BigUInt::ShiftRight(int32 cbit)
282282
{
283283
AssertBi(this);
284284
Assert(cbit >= 0);
@@ -312,7 +312,7 @@ namespace Js
312312
AssertBi(this);
313313
}
314314

315-
int BigInt::Compare(BigInt *pbi)
315+
int BigUInt::Compare(BigUInt *pbi)
316316
{
317317
AssertBi(this);
318318
AssertBi(pbi);
@@ -338,7 +338,7 @@ namespace Js
338338
return (m_prglu[ilu] > pbi->m_prglu[ilu]) ? 1 : -1;
339339
}
340340

341-
bool BigInt::FAdd(BigInt *pbi)
341+
bool BigUInt::FAdd(BigUInt *pbi)
342342
{
343343
AssertBi(this);
344344
AssertBi(pbi);
@@ -391,7 +391,7 @@ namespace Js
391391
return true;
392392
}
393393

394-
void BigInt::Subtract(BigInt *pbi)
394+
void BigUInt::Subtract(BigUInt *pbi)
395395
{
396396
AssertBi(this);
397397
AssertBi(pbi);
@@ -443,7 +443,7 @@ namespace Js
443443
AssertBi(this);
444444
}
445445

446-
int BigInt::DivRem(BigInt *pbi)
446+
int BigUInt::DivRem(BigUInt *pbi)
447447
{
448448
AssertBi(this);
449449
AssertBi(pbi);
@@ -510,7 +510,7 @@ namespace Js
510510
return wQuo;
511511
}
512512

513-
double BigInt::GetDbl(void)
513+
double BigUInt::GetDbl(void)
514514
{
515515
double dbl;
516516
uint32 luHi, luLo;
@@ -591,6 +591,6 @@ namespace Js
591591
return dbl;
592592
}
593593

594-
template bool BigInt::FInitFromDigits<char16>(const char16 *prgch, int32 cch, int32 *pcchDig);
595-
template bool BigInt::FInitFromDigits<utf8char_t>(const utf8char_t *prgch, int32 cch, int32 *pcchDig);
594+
template bool BigUInt::FInitFromDigits<char16>(const char16 *prgch, int32 cch, int32 *pcchDig);
595+
template bool BigUInt::FInitFromDigits<utf8char_t>(const utf8char_t *prgch, int32 cch, int32 *pcchDig);
596596
}

lib/Common/DataStructures/BigInt.h lib/Common/DataStructures/BigUInt.h

+9-9
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace Js
99
/***************************************************************************
1010
Big non-negative integer class.
1111
***************************************************************************/
12-
class BigInt
12+
class BigUInt
1313
{
1414
// Non-negative BigInt is stored as an array of 'digit' where each digit is unit32
1515
private:
@@ -21,7 +21,7 @@ namespace Js
2121
uint32 *m_prglu; // pointer to array of digits
2222
uint32 m_rgluInit[kcluMaxInit]; // pre-defined space to store array
2323

24-
inline BigInt & operator= (BigInt &bi);
24+
inline BigUInt & operator= (BigUInt &bi);
2525
bool FResize(int32 clu);// allocate more space if length go over maximum
2626

2727
#if DBG
@@ -34,22 +34,22 @@ namespace Js
3434
#endif //!DBG
3535

3636
public:
37-
BigInt(void);
38-
~BigInt(void);
37+
BigUInt(void);
38+
~BigUInt(void);
3939

4040
bool FInitFromRglu(uint32 *prglu, int32 clu); // init from array and length
41-
bool FInitFromBigint(BigInt *pbiSrc);
41+
bool FInitFromBigint(BigUInt *pbiSrc);
4242
template <typename EncodedChar>
4343
bool FInitFromDigits(const EncodedChar *prgch, int32 cch, int32 *pcchDec); // init from char of digits
4444
bool FMulAdd(uint32 luMul, uint32 luAdd);
4545
bool FMulPow5(int32 c5);
4646
bool FShiftLeft(int32 cbit);
4747
void ShiftLusRight(int32 clu);
4848
void ShiftRight(int32 cbit);
49-
int Compare(BigInt *pbi);
50-
bool FAdd(BigInt *pbi);
51-
void Subtract(BigInt *pbi);
52-
int DivRem(BigInt *pbi);
49+
int Compare(BigUInt *pbi);
50+
bool FAdd(BigUInt *pbi);
51+
void Subtract(BigUInt *pbi);
52+
int DivRem(BigUInt *pbi);
5353

5454
int32 Clu(void); // return current length
5555
uint32 Lu(int32 ilu); // return digit at position ilu start from 0

lib/Common/DataStructures/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
add_library (Chakra.Common.DataStructures OBJECT
2-
BigInt.cpp
2+
BigUInt.cpp
33
BufferBuilder.cpp
44
CommonDataStructuresPch.cpp
55
DictionaryStats.cpp

lib/Common/DataStructures/Chakra.Common.DataStructures.vcxproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
</ClCompile>
3030
</ItemDefinitionGroup>
3131
<ItemGroup>
32-
<ClCompile Include="$(MSBuildThisFileDirectory)BigInt.cpp" />
32+
<ClCompile Include="$(MSBuildThisFileDirectory)BigUInt.cpp" />
3333
<ClCompile Include="$(MSBuildThisFileDirectory)BufferBuilder.cpp" />
3434
<ClCompile Include="$(MSBuildThisFileDirectory)DictionaryStats.cpp" />
3535
<ClCompile Include="$(MSBuildThisFileDirectory)GrowingArray.cpp" />
@@ -45,7 +45,7 @@
4545
</ClCompile>
4646
</ItemGroup>
4747
<ItemGroup>
48-
<ClInclude Include="BigInt.h" />
48+
<ClInclude Include="BigUInt.h" />
4949
<ClInclude Include="BaseDictionary.h" />
5050
<ClInclude Include="BufferBuilder.h" />
5151
<ClInclude Include="Cache.h" />

0 commit comments

Comments
 (0)