5 #ifndef V8_CONVERSIONS_H_ 6 #define V8_CONVERSIONS_H_ 10 #include "src/base/logging.h" 11 #include "src/utils.h" 22 const int kMaxFractionDigits = 100;
28 inline int FastD2IChecked(
double x) {
29 if (!(x >= INT_MIN))
return INT_MIN;
30 if (x > INT_MAX)
return INT_MAX;
31 return static_cast<int>(x);
38 inline int FastD2I(
double x) {
41 return static_cast<int32_t
>(x);
44 inline unsigned int FastD2UI(
double x);
47 inline double FastI2D(
int x) {
51 return static_cast<double>(x);
55 inline double FastUI2D(
unsigned x) {
59 return static_cast<double>(x);
64 inline float DoubleToFloat32(
double x);
68 inline double DoubleToInteger(
double x);
72 inline int32_t DoubleToInt32(
double x);
76 inline uint32_t DoubleToUint32(
double x);
81 enum ConversionFlags {
85 ALLOW_IMPLICIT_OCTAL = 4,
87 ALLOW_TRAILING_JUNK = 16
92 double StringToDouble(Vector<const uint8_t> str,
int flags,
93 double empty_string_val = 0);
94 double StringToDouble(Vector<const uc16> str,
int flags,
95 double empty_string_val = 0);
97 double StringToDouble(
const char* str,
int flags,
double empty_string_val = 0);
99 double StringToInt(Isolate* isolate, Handle<String>
string,
int radix);
103 MaybeHandle<BigInt> StringToBigInt(Isolate* isolate, Handle<String>
string);
110 V8_EXPORT_PRIVATE MaybeHandle<BigInt> BigIntLiteral(Isolate* isolate,
113 const int kDoubleToCStringMinBufferSize = 100;
118 const char* DoubleToCString(
double value, Vector<char> buffer);
122 const char* IntToCString(
int n, Vector<char> buffer);
126 char* DoubleToFixedCString(
double value,
int f);
127 char* DoubleToExponentialCString(
double value,
int f);
128 char* DoubleToPrecisionCString(
double value,
int f);
129 char* DoubleToRadixCString(
double value,
int radix);
131 static inline bool IsMinusZero(
double value) {
132 return bit_cast<
int64_t>(value) == bit_cast<int64_t>(-0.0);
137 inline bool DoubleToSmiInteger(
double value,
int* smi_int_value);
139 inline bool IsSmiDouble(
double value);
144 inline bool IsInt32Double(
double value);
149 inline bool IsUint32Double(
double value);
156 inline bool DoubleToUint32IfEqualToSelf(
double value,
uint32_t* uint32_value);
159 inline uint32_t PositiveNumberToUint32(Object* number);
160 inline int32_t NumberToInt32(Object* number);
161 inline uint32_t NumberToUint32(Object* number);
162 inline int64_t NumberToInt64(Object* number);
163 inline uint64_t PositiveNumberToUint64(Object* number);
165 double StringToDouble(Isolate* isolate, Handle<String>
string,
int flags,
166 double empty_string_val = 0.0);
168 inline bool TryNumberToSize(Object* number,
size_t* result);
171 inline size_t NumberToSize(Object* number);
174 bool IsSpecialIndex(String
string);
179 #endif // V8_CONVERSIONS_H_