20 #ifndef _STLP_VENDOR_CSTD
51 StringCharacterStreamIterator::StringCharacterStreamIterator(
71 const char* str,
int flags,
double empty_string_val) {
74 const uint8_t* start =
reinterpret_cast<const uint8_t*
>(str);
75 const uint8_t* end = start +
StrLength(str);
84 double empty_string_val) {
87 const uint8_t* start =
reinterpret_cast<const uint8_t*
>(str.
start());
88 const uint8_t* end = start + str.
length();
97 double empty_string_val) {
122 switch (fpclassify(v)) {
123 case FP_NAN:
return "NaN";
124 case FP_INFINITE:
return (v < 0.0 ?
"-Infinity" :
"Infinity");
131 char decimal_rep[kV8DtoaBufferCapacity];
136 &
sign, &length, &decimal_point);
140 if (length <= decimal_point && decimal_point <= 21) {
143 builder.
AddPadding(
'0', decimal_point - length);
145 }
else if (0 < decimal_point && decimal_point <= 21) {
149 builder.
AddString(decimal_rep + decimal_point);
151 }
else if (decimal_point <= 0 && decimal_point > -6) {
166 int exponent = decimal_point - 1;
167 if (exponent < 0) exponent = -exponent;
188 buffer[--
i] =
'0' + (n % 10);
192 return buffer.
start() +
i;
197 const int kMaxDigitsBeforePoint = 21;
198 const double kFirstNonFixed = 1e21;
199 const int kMaxDigitsAfterPoint = 20;
201 DCHECK(f <= kMaxDigitsAfterPoint);
204 double abs_value = value;
212 if (abs_value >= kFirstNonFixed) {
222 const int kDecimalRepCapacity =
223 kMaxDigitsBeforePoint + kMaxDigitsAfterPoint + 1;
224 char decimal_rep[kDecimalRepCapacity];
225 int decimal_rep_length;
228 &
sign, &decimal_rep_length, &decimal_point);
231 int zero_prefix_length = 0;
232 int zero_postfix_length = 0;
234 if (decimal_point <= 0) {
235 zero_prefix_length = -decimal_point + 1;
239 if (zero_prefix_length + decimal_rep_length < decimal_point + f) {
240 zero_postfix_length = decimal_point + f - decimal_rep_length -
244 unsigned rep_length =
245 zero_prefix_length + decimal_rep_length + zero_postfix_length;
247 rep_builder.
AddPadding(
'0', zero_prefix_length);
249 rep_builder.
AddPadding(
'0', zero_postfix_length);
254 unsigned result_size = decimal_point + f + 2;
270 int significant_digits) {
271 bool negative_exponent =
false;
273 negative_exponent =
true;
274 exponent = -exponent;
280 unsigned result_size = significant_digits + 7;
285 if (significant_digits != 1) {
289 builder.
AddPadding(
'0', significant_digits - rep_length);
300 const int kMaxDigitsAfterPoint = 20;
302 DCHECK(f >= -1 && f <= kMaxDigitsAfterPoint);
316 const int kV8DtoaBufferCapacity = kMaxDigitsAfterPoint + 1 + 1;
320 char decimal_rep[kV8DtoaBufferCapacity];
321 int decimal_rep_length;
326 &
sign, &decimal_rep_length, &decimal_point);
327 f = decimal_rep_length - 1;
331 &
sign, &decimal_rep_length, &decimal_point);
333 DCHECK(decimal_rep_length > 0);
334 DCHECK(decimal_rep_length <= f + 1);
336 int exponent = decimal_point - 1;
345 const int kMinimalDigits = 1;
346 const int kMaximalDigits = 21;
347 DCHECK(p >= kMinimalDigits && p <= kMaximalDigits);
360 const int kV8DtoaBufferCapacity = kMaximalDigits + 1;
361 char decimal_rep[kV8DtoaBufferCapacity];
362 int decimal_rep_length;
366 &
sign, &decimal_rep_length, &decimal_point);
367 DCHECK(decimal_rep_length <= p);
369 int exponent = decimal_point - 1;
373 if (exponent < -6 || exponent >= p) {
382 unsigned result_size = (decimal_point <= 0)
383 ? -decimal_point + p + 3
387 if (decimal_point <= 0) {
391 builder.
AddPadding(
'0', p - decimal_rep_length);
393 const int m =
Min(decimal_rep_length, decimal_point);
395 builder.
AddPadding(
'0', decimal_point - decimal_rep_length);
396 if (decimal_point < p) {
399 if (decimal_rep_length > decimal_point) {
400 const int len =
StrLength(decimal_rep + decimal_point);
401 const int n =
Min(len, p - (builder.
position() - extra));
415 DCHECK(radix >= 2 && radix <= 36);
418 static const char chars[] =
"0123456789abcdefghijklmnopqrstuvwxyz";
432 bool is_negative = value < 0.0;
433 if (is_negative) value = -value;
436 double integer_part = std::floor(value);
437 double decimal_part = value - integer_part;
443 double remainder = std::fmod(integer_part, radix);
444 integer_buffer[integer_pos--] = chars[
static_cast<int>(remainder)];
445 integer_part -= remainder;
446 integer_part /= radix;
447 }
while (integer_part >= 1.0);
451 if (is_negative) integer_buffer[integer_pos--] =
'-';
463 while ((decimal_part > 0.0) && (decimal_pos <
kBufferSize - 1)) {
464 decimal_part *= radix;
465 decimal_buffer[decimal_pos++] =
466 chars[
static_cast<int>(std::floor(decimal_part))];
467 decimal_part -= std::floor(decimal_part);
469 decimal_buffer[decimal_pos] =
'\0';
472 int integer_part_size =
kBufferSize - 2 - integer_pos;
474 unsigned result_size = integer_part_size + decimal_pos;
476 if (decimal_pos > 0) result_size++;
479 builder.
AddSubstring(integer_buffer + integer_pos + 1, integer_part_size);
489 double empty_string_val) {
void AddDecimalInteger(int value)
void AddPadding(char c, int count)
void AddCharacter(char c)
void AddSubstring(const char *s, int n)
void AddString(const char *s)
Vector< const uint8_t > ToOneByteVector()
Vector< const uc16 > ToUC16Vector()
uint16_t operator*() const
StringCharacterStream *const stream_
bool operator!=(EndMarker const &m) const
bool operator==(EndMarker const &) const
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long enable alignment of csp to bytes on platforms which prefer the register to always be NULL
#define DCHECK(condition)
static const size_t kBufferSize
void DeleteArray(T *array)
const int kBase10MaximalLength
char * DoubleToRadixCString(double value, int radix)
static char * CreateExponentialRepresentation(char *decimal_rep, int exponent, bool negative, int significant_digits)
double InternalStringToDouble(UnicodeCache *unicode_cache, Iterator current, EndMark end, int flags, double empty_string_val)
char * DoubleToFixedCString(double value, int f)
static LifetimePosition Min(LifetimePosition a, LifetimePosition b)
char * DoubleToExponentialCString(double value, int f)
char * DoubleToPrecisionCString(double value, int p)
double StringToInt(UnicodeCache *unicode_cache, Vector< const uint8_t > vector, int radix)
void DoubleToAscii(double v, DtoaMode mode, int requested_digits, Vector< char > buffer, int *sign, int *length, int *point)
double InternalStringToInt(UnicodeCache *unicode_cache, Iterator current, EndMark end, int radix)
const char * DoubleToCString(double v, Vector< char > buffer)
const char * IntToCString(int n, Vector< char > buffer)
int StrLength(const char *string)
double StringToDouble(UnicodeCache *unicode_cache, const char *str, int flags, double empty_string_val)
char * StrDup(const char *str)
Debugger support for the V8 JavaScript engine.