mirror of
https://github.com/bellard/quickjs.git
synced 2024-12-12 09:44:33 +08:00
the BigInt support is now always included
This commit is contained in:
parent
03cc5ecc88
commit
94010edb57
10
Makefile
10
Makefile
@ -47,7 +47,7 @@ prefix=/usr/local
|
||||
#CONFIG_PROFILE=y
|
||||
# use address sanitizer
|
||||
#CONFIG_ASAN=y
|
||||
# include the code for BigInt/BigFloat/BigDecimal and math mode
|
||||
# include the code for BigFloat/BigDecimal, math mode and faster large integers
|
||||
CONFIG_BIGNUM=y
|
||||
|
||||
OBJDIR=.obj
|
||||
@ -166,11 +166,10 @@ endif
|
||||
|
||||
all: $(OBJDIR) $(OBJDIR)/quickjs.check.o $(OBJDIR)/qjs.check.o $(PROGS)
|
||||
|
||||
QJS_LIB_OBJS=$(OBJDIR)/quickjs.o $(OBJDIR)/libregexp.o $(OBJDIR)/libunicode.o $(OBJDIR)/cutils.o $(OBJDIR)/quickjs-libc.o
|
||||
QJS_LIB_OBJS=$(OBJDIR)/quickjs.o $(OBJDIR)/libregexp.o $(OBJDIR)/libunicode.o $(OBJDIR)/cutils.o $(OBJDIR)/quickjs-libc.o $(OBJDIR)/libbf.o
|
||||
|
||||
QJS_OBJS=$(OBJDIR)/qjs.o $(OBJDIR)/repl.o $(QJS_LIB_OBJS)
|
||||
ifdef CONFIG_BIGNUM
|
||||
QJS_LIB_OBJS+=$(OBJDIR)/libbf.o
|
||||
QJS_OBJS+=$(OBJDIR)/qjscalc.o
|
||||
endif
|
||||
|
||||
@ -317,10 +316,7 @@ endif
|
||||
HELLO_SRCS=examples/hello.js
|
||||
HELLO_OPTS=-fno-string-normalize -fno-map -fno-promise -fno-typedarray \
|
||||
-fno-typedarray -fno-regexp -fno-json -fno-eval -fno-proxy \
|
||||
-fno-date -fno-module-loader
|
||||
ifdef CONFIG_BIGNUM
|
||||
HELLO_OPTS+=-fno-bigint
|
||||
endif
|
||||
-fno-date -fno-module-loader -fno-bigint
|
||||
|
||||
hello.c: $(QJSC) $(HELLO_SRCS)
|
||||
$(QJSC) -e $(HELLO_OPTS) -o $@ $(HELLO_SRCS)
|
||||
|
9
libbf.c
9
libbf.c
@ -37,10 +37,12 @@
|
||||
|
||||
/* enable it to check the multiplication result */
|
||||
//#define USE_MUL_CHECK
|
||||
#ifdef CONFIG_BIGNUM
|
||||
/* enable it to use FFT/NTT multiplication */
|
||||
#define USE_FFT_MUL
|
||||
/* enable decimal floating point support */
|
||||
#define USE_BF_DEC
|
||||
#endif
|
||||
|
||||
//#define inline __attribute__((always_inline))
|
||||
|
||||
@ -1600,7 +1602,9 @@ int bf_mul(bf_t *r, const bf_t *a, const bf_t *b, limb_t prec,
|
||||
r = &tmp;
|
||||
}
|
||||
if (bf_resize(r, a_len + b_len)) {
|
||||
#ifdef USE_FFT_MUL
|
||||
fail:
|
||||
#endif
|
||||
bf_set_nan(r);
|
||||
ret = BF_ST_MEM_ERROR;
|
||||
goto done;
|
||||
@ -2297,11 +2301,14 @@ static int bf_pow_ui_ui(bf_t *r, limb_t a1, limb_t b,
|
||||
bf_t a;
|
||||
int ret;
|
||||
|
||||
#ifdef USE_BF_DEC
|
||||
if (a1 == 10 && b <= LIMB_DIGITS) {
|
||||
/* use precomputed powers. We do not round at this point
|
||||
because we expect the caller to do it */
|
||||
ret = bf_set_ui(r, mp_pow_dec[b]);
|
||||
} else {
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
bf_init(r->ctx, &a);
|
||||
ret = bf_set_ui(&a, a1);
|
||||
ret |= bf_pow_ui(r, &a, b, prec, flags);
|
||||
|
2
qjs.c
2
qjs.c
@ -454,8 +454,10 @@ int main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef CONFIG_BIGNUM
|
||||
if (load_jscalc)
|
||||
bignum_ext = 1;
|
||||
#endif
|
||||
|
||||
if (trace_memory) {
|
||||
js_trace_malloc_init(&trace_data);
|
||||
|
2
qjsc.c
2
qjsc.c
@ -76,9 +76,7 @@ static const FeatureEntry feature_list[] = {
|
||||
{ "promise", "Promise" },
|
||||
#define FE_MODULE_LOADER 9
|
||||
{ "module-loader", NULL },
|
||||
#ifdef CONFIG_BIGNUM
|
||||
{ "bigint", "BigInt" },
|
||||
#endif
|
||||
};
|
||||
|
||||
void namelist_add(namelist_t *lp, const char *name, const char *short_name,
|
||||
|
@ -169,8 +169,8 @@ DEF(groups, "groups")
|
||||
DEF(status, "status")
|
||||
DEF(reason, "reason")
|
||||
DEF(globalThis, "globalThis")
|
||||
#ifdef CONFIG_BIGNUM
|
||||
DEF(bigint, "bigint")
|
||||
#ifdef CONFIG_BIGNUM
|
||||
DEF(bigfloat, "bigfloat")
|
||||
DEF(bigdecimal, "bigdecimal")
|
||||
DEF(roundingMode, "roundingMode")
|
||||
@ -209,15 +209,13 @@ DEF(Int16Array, "Int16Array")
|
||||
DEF(Uint16Array, "Uint16Array")
|
||||
DEF(Int32Array, "Int32Array")
|
||||
DEF(Uint32Array, "Uint32Array")
|
||||
#ifdef CONFIG_BIGNUM
|
||||
DEF(BigInt64Array, "BigInt64Array")
|
||||
DEF(BigUint64Array, "BigUint64Array")
|
||||
#endif
|
||||
DEF(Float32Array, "Float32Array")
|
||||
DEF(Float64Array, "Float64Array")
|
||||
DEF(DataView, "DataView")
|
||||
#ifdef CONFIG_BIGNUM
|
||||
DEF(BigInt, "BigInt")
|
||||
#ifdef CONFIG_BIGNUM
|
||||
DEF(BigFloat, "BigFloat")
|
||||
DEF(BigFloatEnv, "BigFloatEnv")
|
||||
DEF(BigDecimal, "BigDecimal")
|
||||
|
Loading…
Reference in New Issue
Block a user