Skip to content

Commit

Permalink
Remove operator overloading (#32)
Browse files Browse the repository at this point in the history
Part of #17
  • Loading branch information
bnoordhuis authored Nov 10, 2023
1 parent 39e834f commit ae17b85
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 1,111 deletions.
13 changes: 4 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ examples/point.so: $(OBJDIR)/examples/point.pic.o
###############################################################################
# documentation

DOCS=doc/quickjs.pdf doc/quickjs.html doc/jsbignum.pdf doc/jsbignum.html
DOCS=doc/quickjs.pdf doc/quickjs.html

build_doc: $(DOCS)

Expand Down Expand Up @@ -420,17 +420,13 @@ ifndef CONFIG_MINGW
endif
ifndef CONFIG_MINGW
ifndef CONFIG_DARWIN
ifdef CONFIG_BIGNUM
./qjs --bignum tests/test_bjson.js
else
./qjs tests/test_bjson.js
endif
./qjs tests/test_bjson.js
./qjs examples/test_point.js
endif
endif
ifdef CONFIG_BIGNUM
./qjs --bignum tests/test_op_overloading.js
./qjs --bignum tests/test_bignum.js
./qjs tests/test_bignum.js
endif
ifdef CONFIG_M32
./qjs32 tests/test_closure.js
Expand All @@ -440,8 +436,7 @@ ifdef CONFIG_M32
./qjs32 tests/test_std.js
./qjs32 tests/test_worker.js
ifdef CONFIG_BIGNUM
./qjs32 --bignum tests/test_op_overloading.js
./qjs32 --bignum tests/test_bignum.js
./qjs32 tests/test_bignum.js
endif
endif

Expand Down
15 changes: 0 additions & 15 deletions qjs.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@

extern const uint8_t qjsc_repl[];
extern const uint32_t qjsc_repl_size;
#ifdef CONFIG_BIGNUM
static int bignum_ext;
#endif

static int eval_buf(JSContext *ctx, const void *buf, int buf_len,
const char *filename, int eval_flags)
Expand Down Expand Up @@ -107,12 +104,6 @@ static JSContext *JS_NewCustomContext(JSRuntime *rt)
ctx = JS_NewContext(rt);
if (!ctx)
return NULL;
#ifdef CONFIG_BIGNUM
if (bignum_ext) {
JS_AddIntrinsicOperators(ctx);
JS_EnableBignumExt(ctx, TRUE);
}
#endif
/* system modules */
js_init_module_std(ctx, "std");
js_init_module_os(ctx, "os");
Expand Down Expand Up @@ -392,12 +383,6 @@ int main(int argc, char **argv)
dump_unhandled_promise_rejection = 1;
continue;
}
#ifdef CONFIG_BIGNUM
if (!strcmp(longopt, "bignum")) {
bignum_ext = 1;
continue;
}
#endif
if (opt == 'q' || !strcmp(longopt, "quit")) {
empty_run++;
continue;
Expand Down
25 changes: 1 addition & 24 deletions qjsc.c
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,6 @@ void help(void)
{
int i;
printf("-flto use link time optimization\n");
printf("-fbignum enable bignum extensions\n");
printf("-fno-[");
for(i = 0; i < countof(feature_list); i++) {
if (i != 0)
Expand Down Expand Up @@ -493,9 +492,6 @@ int main(int argc, char **argv)
int module;
OutputTypeEnum output_type;
size_t stack_size;
#ifdef CONFIG_BIGNUM
BOOL bignum_ext = FALSE;
#endif
namelist_t dynamic_module_list;

out_filename = NULL;
Expand Down Expand Up @@ -548,13 +544,7 @@ int main(int argc, char **argv)
}
if (i == countof(feature_list))
goto bad_feature;
} else
#ifdef CONFIG_BIGNUM
if (!strcmp(optarg, "bignum")) {
bignum_ext = TRUE;
} else
#endif
{
} else {
bad_feature:
fprintf(stderr, "unsupported feature: %s\n", optarg);
exit(1);
Expand Down Expand Up @@ -631,12 +621,6 @@ int main(int argc, char **argv)

rt = JS_NewRuntime();
ctx = JS_NewContext(rt);
#ifdef CONFIG_BIGNUM
if (bignum_ext) {
JS_AddIntrinsicOperators(ctx);
JS_EnableBignumExt(ctx, TRUE);
}
#endif

/* loader for ES6 modules */
JS_SetModuleLoaderFunc(rt, NULL, jsc_module_loader, NULL);
Expand Down Expand Up @@ -685,13 +669,6 @@ int main(int argc, char **argv)
feature_list[i].init_name);
}
}
#ifdef CONFIG_BIGNUM
if (bignum_ext) {
fprintf(fo,
" JS_AddIntrinsicOperators(ctx);\n"
" JS_EnableBignumExt(ctx, 1);\n");
}
#endif
/* add the precompiled modules (XXX: could modify the module
loader instead) */
for(i = 0; i < init_module_list.count; i++) {
Expand Down
5 changes: 0 additions & 5 deletions quickjs-atom.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,6 @@ DEF(Float64Array, "Float64Array")
DEF(DataView, "DataView")
#ifdef CONFIG_BIGNUM
DEF(BigInt, "BigInt")
DEF(OperatorSet, "OperatorSet")
DEF(Operators, "Operators")
#endif
DEF(Map, "Map")
DEF(Set, "Set") /* Map + 1 */
Expand Down Expand Up @@ -258,8 +256,5 @@ DEF(Symbol_hasInstance, "Symbol.hasInstance")
DEF(Symbol_species, "Symbol.species")
DEF(Symbol_unscopables, "Symbol.unscopables")
DEF(Symbol_asyncIterator, "Symbol.asyncIterator")
#ifdef CONFIG_BIGNUM
DEF(Symbol_operatorSet, "Symbol.operatorSet")
#endif

#endif /* DEF */
Loading

0 comments on commit ae17b85

Please sign in to comment.