#ifndef V8_BIGINT_BIGINT_H_
#define V8_BIGINT_BIGINT_H_
#include <stdint.h>
#include <algorithm>
#include <cstring>
#include <iostream>
#include <vector>
namespace v8 {
namespace bigint {
#ifdef DEBUG
#define BIGINT_H_DCHECK …
extern bool kAdvancedAlgorithmsEnabledInLibrary;
#else
#define BIGINT_H_DCHECK …
#endif
digit_t;
signed_digit_t;
#if UINTPTR_MAX == 0xFFFFFFFF
using twodigit_t = uint64_t;
#define HAVE_TWODIGIT_T …
static constexpr int kLog2DigitBits = 5;
#elif UINTPTR_MAX == 0xFFFFFFFFFFFFFFFF
static constexpr int kLog2DigitBits = …;
#if defined(__SIZEOF_INT128__)
twodigit_t;
#define HAVE_TWODIGIT_T …
#endif
#else
#error Unsupported platform.
#endif
static constexpr int kDigitBits = …;
static_assert …;
class Digits { … };
class RWDigits : public Digits { … };
class Platform { … };
inline int Compare(Digits A, Digits B) { … }
void Add(RWDigits Z, Digits X, Digits Y);
bool AddSigned(RWDigits Z, Digits X, bool x_negative, Digits Y,
bool y_negative);
void AddOne(RWDigits Z, Digits X);
void Subtract(RWDigits Z, Digits X, Digits Y);
bool SubtractSigned(RWDigits Z, Digits X, bool x_negative, Digits Y,
bool y_negative);
void SubtractOne(RWDigits Z, Digits X);
void BitwiseAnd_PosPos(RWDigits Z, Digits X, Digits Y);
void BitwiseAnd_NegNeg(RWDigits Z, Digits X, Digits Y);
void BitwiseAnd_PosNeg(RWDigits Z, Digits X, Digits Y);
void BitwiseOr_PosPos(RWDigits Z, Digits X, Digits Y);
void BitwiseOr_NegNeg(RWDigits Z, Digits X, Digits Y);
void BitwiseOr_PosNeg(RWDigits Z, Digits X, Digits Y);
void BitwiseXor_PosPos(RWDigits Z, Digits X, Digits Y);
void BitwiseXor_NegNeg(RWDigits Z, Digits X, Digits Y);
void BitwiseXor_PosNeg(RWDigits Z, Digits X, Digits Y);
void LeftShift(RWDigits Z, Digits X, digit_t shift);
struct RightShiftState { … };
void RightShift(RWDigits Z, Digits X, digit_t shift,
const RightShiftState& state);
bool AsIntN(RWDigits Z, Digits X, bool x_negative, int n);
void AsUintN_Pos(RWDigits Z, Digits X, int n);
void AsUintN_Neg(RWDigits Z, Digits X, int n);
enum class Status { … };
class FromStringAccumulator;
class Processor { … };
inline int AddResultLength(int x_length, int y_length) { … }
inline int AddSignedResultLength(int x_length, int y_length, bool same_sign) { … }
inline int SubtractResultLength(int x_length, int y_length) { … }
inline int SubtractSignedResultLength(int x_length, int y_length,
bool same_sign) { … }
inline int MultiplyResultLength(Digits X, Digits Y) { … }
constexpr int kBarrettThreshold = …;
inline int DivideResultLength(Digits A, Digits B) { … }
inline int ModuloResultLength(Digits B) { … }
int ToStringResultLength(Digits X, int radix, bool sign);
constexpr char kStringZapValue = …;
int RightShift_ResultLength(Digits X, bool x_sign, digit_t shift,
RightShiftState* state);
int AsIntNResultLength(Digits X, bool x_negative, int n);
int AsUintN_Pos_ResultLength(Digits X, int n);
inline int AsUintN_Neg_ResultLength(int n) { … }
class ProcessorImpl;
#if !defined(DEBUG) && (defined(__GNUC__) || defined(__clang__))
#define ALWAYS_INLINE …
#elif !defined(DEBUG) && defined(_MSC_VER)
#define ALWAYS_INLINE …
#else
#define ALWAYS_INLINE …
#endif
static constexpr int kStackParts = …;
class FromStringAccumulator { … };
#if defined(__GNUC__) || defined(__clang__)
#define HAVE_BUILTIN_MUL_OVERFLOW …
#else
#define HAVE_BUILTIN_MUL_OVERFLOW …
#endif
static constexpr uint8_t kCharValue[] = …;
static constexpr uint8_t kCharBits[] = …;
template <class CharIt>
CharIt FromStringAccumulator::ParsePowerTwo(CharIt current, CharIt end,
digit_t radix) { … }
template <class CharIt>
CharIt FromStringAccumulator::Parse(CharIt start, CharIt end, digit_t radix) { … }
bool FromStringAccumulator::AddPart(digit_t multiplier, digit_t part,
bool is_last) { … }
bool FromStringAccumulator::AddPart(digit_t part) { … }
}
}
#undef BIGINT_H_DCHECK
#undef ALWAYS_INLINE
#undef HAVE_BUILTIN_MUL_OVERFLOW
#endif