Skip to content

Commit

Permalink
squash
Browse files Browse the repository at this point in the history
  • Loading branch information
bnoordhuis committed Nov 10, 2023
1 parent 02a15ca commit 6d5695d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -415,15 +415,15 @@ ifndef CONFIG_DARWIN
./qjs examples/test_point.js
endif
endif
./qjs tests/test_bignum.js
./qjs tests/test_bigint.js
ifdef CONFIG_M32
./qjs32 tests/test_closure.js
./qjs32 tests/test_language.js
./qjs32 tests/test_builtin.js
./qjs32 tests/test_loop.js
./qjs32 tests/test_std.js
./qjs32 tests/test_worker.js
./qjs32 tests/test_bignum.js
./qjs32 tests/test_bigint.js
endif

stats: qjs qjs32
Expand Down
18 changes: 8 additions & 10 deletions quickjs.c
Original file line number Diff line number Diff line change
Expand Up @@ -2998,8 +2998,6 @@ static JSValue JS_AtomIsNumericIndex1(JSContext *ctx, JSAtom atom)
return JS_UNDEFINED;
}
}
/* XXX: bignum: would be better to only accept integer to avoid
relying on current floating point precision */
/* this is ECMA CanonicalNumericIndexString primitive */
num = JS_ToNumber(ctx, JS_MKPTR(JS_TAG_STRING, p));
if (JS_IsException(num))
Expand Down Expand Up @@ -31844,7 +31842,7 @@ static void JS_WriteString(BCWriterState *s, JSString *p)
}
}

static int JS_WriteBigNum(BCWriterState *s, JSValueConst obj)
static int JS_WriteBigInt(BCWriterState *s, JSValueConst obj)
{
uint32_t tag, tag1;
int64_t e;
Expand Down Expand Up @@ -31876,7 +31874,7 @@ static int JS_WriteBigNum(BCWriterState *s, JSValueConst obj)
e = a->expn;
e = (e * 2) | a->sign;
if (e < INT32_MIN || e > INT32_MAX) {
JS_ThrowInternalError(s->ctx, "bignum exponent is too large");
JS_ThrowInternalError(s->ctx, "bigint exponent is too large");
return -1;
}
bc_put_sleb128(s, e);
Expand All @@ -31896,7 +31894,7 @@ static int JS_WriteBigNum(BCWriterState *s, JSValueConst obj)
i++;
len = (a->len - i) * sizeof(limb_t) + n1;
if (len > INT32_MAX) {
JS_ThrowInternalError(s->ctx, "bignum is too large");
JS_ThrowInternalError(s->ctx, "bigint is too large");
return -1;
}
bc_put_leb128(s, len);
Expand Down Expand Up @@ -32297,7 +32295,7 @@ static int JS_WriteObjectRec(BCWriterState *s, JSValueConst obj)
}
break;
case JS_TAG_BIG_INT:
if (JS_WriteBigNum(s, obj))
if (JS_WriteBigInt(s, obj))
goto fail;
break;
default:
Expand Down Expand Up @@ -32691,7 +32689,7 @@ static int JS_ReadFunctionBytecode(BCReaderState *s, JSFunctionBytecode *b,
return 0;
}

static JSValue JS_ReadBigNum(BCReaderState *s, int tag)
static JSValue JS_ReadBigInt(BCReaderState *s, int tag)
{
JSValue obj = JS_UNDEFINED;
uint8_t v8;
Expand Down Expand Up @@ -32739,7 +32737,7 @@ static JSValue JS_ReadBigNum(BCReaderState *s, int tag)
goto fail;
bc_read_trace(s, "len=%" PRId64 "\n", (int64_t)len);
if (len == 0) {
JS_ThrowInternalError(s->ctx, "invalid bignum length");
JS_ThrowInternalError(s->ctx, "invalid bigint length");
goto fail;
}
l = (len + sizeof(limb_t) - 1) / sizeof(limb_t);
Expand Down Expand Up @@ -33408,7 +33406,7 @@ static JSValue JS_ReadObjectRec(BCReaderState *s)
obj = JS_ReadObjectValue(s);
break;
case BC_TAG_BIG_INT:
obj = JS_ReadBigNum(s, tag);
obj = JS_ReadBigInt(s, tag);
break;
case BC_TAG_OBJECT_REFERENCE:
{
Expand Down Expand Up @@ -43312,7 +43310,7 @@ static uint32_t map_hash_key(JSContext *ctx, JSValueConst key)
h = (u.u32[0] ^ u.u32[1]) * 3163;
break;
default:
h = 0; /* XXX: bignum support */
h = 0; /* XXX: bigint support */
break;
}
h ^= tag;
Expand Down
File renamed without changes.

0 comments on commit 6d5695d

Please sign in to comment.