mirror of
https://github.com/bellard/quickjs.git
synced 2025-05-15 10:45:02 +08:00
fixed JS_DumpValue() for BigInt
This commit is contained in:
parent
6de88859e7
commit
5a16c0c1eb
31
quickjs.c
31
quickjs.c
@ -12870,19 +12870,32 @@ static __maybe_unused void JS_DumpValueShort(JSRuntime *rt,
|
|||||||
case JS_TAG_FLOAT64:
|
case JS_TAG_FLOAT64:
|
||||||
printf("%.14g", JS_VALUE_GET_FLOAT64(val));
|
printf("%.14g", JS_VALUE_GET_FLOAT64(val));
|
||||||
break;
|
break;
|
||||||
#if 0
|
case JS_TAG_SHORT_BIG_INT:
|
||||||
/* XXX: TODO */
|
printf("%" PRId64 "n", (int64_t)JS_VALUE_GET_SHORT_BIG_INT(val));
|
||||||
|
break;
|
||||||
case JS_TAG_BIG_INT:
|
case JS_TAG_BIG_INT:
|
||||||
{
|
{
|
||||||
JSBigFloat *p = JS_VALUE_GET_PTR(val);
|
JSBigInt *p = JS_VALUE_GET_PTR(val);
|
||||||
char *str;
|
int sgn, i;
|
||||||
str = bf_ftoa(NULL, &p->num, 10, 0,
|
/* In order to avoid allocations we just dump the limbs */
|
||||||
BF_RNDZ | BF_FTOA_FORMAT_FRAC);
|
sgn = js_bigint_sign(p);
|
||||||
printf("%sn", str);
|
if (sgn)
|
||||||
bf_realloc(&rt->bf_ctx, str, 0);
|
printf("BigInt.asIntN(%d,", p->len * JS_LIMB_BITS);
|
||||||
|
printf("0x");
|
||||||
|
for(i = p->len - 1; i >= 0; i--) {
|
||||||
|
if (i != p->len - 1)
|
||||||
|
printf("_");
|
||||||
|
#if JS_LIMB_BITS == 32
|
||||||
|
printf("%08x", p->tab[i]);
|
||||||
|
#else
|
||||||
|
printf("%016" PRIx64, p->tab[i]);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
printf("n");
|
||||||
|
if (sgn)
|
||||||
|
printf(")");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#endif
|
|
||||||
case JS_TAG_STRING:
|
case JS_TAG_STRING:
|
||||||
{
|
{
|
||||||
JSString *p;
|
JSString *p;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user