quickjs 0.8.1 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -45,11 +45,6 @@
45
45
 
46
46
  extern const uint8_t qjsc_repl[];
47
47
  extern const uint32_t qjsc_repl_size;
48
- #ifdef CONFIG_BIGNUM
49
- extern const uint8_t qjsc_qjscalc[];
50
- extern const uint32_t qjsc_qjscalc_size;
51
- static int bignum_ext;
52
- #endif
53
48
 
54
49
  static int eval_buf(JSContext *ctx, const void *buf, int buf_len,
55
50
  const char *filename, int eval_flags)
@@ -112,14 +107,6 @@ static JSContext *JS_NewCustomContext(JSRuntime *rt)
112
107
  ctx = JS_NewContext(rt);
113
108
  if (!ctx)
114
109
  return NULL;
115
- #ifdef CONFIG_BIGNUM
116
- if (bignum_ext) {
117
- JS_AddIntrinsicBigFloat(ctx);
118
- JS_AddIntrinsicBigDecimal(ctx);
119
- JS_AddIntrinsicOperators(ctx);
120
- JS_EnableBignumExt(ctx, TRUE);
121
- }
122
- #endif
123
110
  /* system modules */
124
111
  js_init_module_std(ctx, "std");
125
112
  js_init_module_os(ctx, "os");
@@ -283,10 +270,6 @@ void help(void)
283
270
  " --script load as ES6 script (default=autodetect)\n"
284
271
  "-I --include file include an additional file\n"
285
272
  " --std make 'std' and 'os' available to the loaded script\n"
286
- #ifdef CONFIG_BIGNUM
287
- " --bignum enable the bignum extensions (BigFloat, BigDecimal)\n"
288
- " --qjscalc load the QJSCalc runtime (default if invoked as qjscalc)\n"
289
- #endif
290
273
  "-T --trace trace memory allocation\n"
291
274
  "-d --dump dump the memory usage stats\n"
292
275
  " --memory-limit n limit the memory usage to 'n' bytes\n"
@@ -313,23 +296,8 @@ int main(int argc, char **argv)
313
296
  size_t memory_limit = 0;
314
297
  char *include_list[32];
315
298
  int i, include_count = 0;
316
- #ifdef CONFIG_BIGNUM
317
- int load_jscalc;
318
- #endif
319
299
  size_t stack_size = 0;
320
300
 
321
- #ifdef CONFIG_BIGNUM
322
- /* load jscalc runtime if invoked as 'qjscalc' */
323
- {
324
- const char *p, *exename;
325
- exename = argv[0];
326
- p = strrchr(exename, '/');
327
- if (p)
328
- exename = p + 1;
329
- load_jscalc = !strcmp(exename, "qjscalc");
330
- }
331
- #endif
332
-
333
301
  /* cannot use getopt because we want to pass the command line to
334
302
  the script */
335
303
  optind = 1;
@@ -407,16 +375,6 @@ int main(int argc, char **argv)
407
375
  dump_unhandled_promise_rejection = 1;
408
376
  continue;
409
377
  }
410
- #ifdef CONFIG_BIGNUM
411
- if (!strcmp(longopt, "bignum")) {
412
- bignum_ext = 1;
413
- continue;
414
- }
415
- if (!strcmp(longopt, "qjscalc")) {
416
- load_jscalc = 1;
417
- continue;
418
- }
419
- #endif
420
378
  if (opt == 'q' || !strcmp(longopt, "quit")) {
421
379
  empty_run++;
422
380
  continue;
@@ -446,11 +404,6 @@ int main(int argc, char **argv)
446
404
  }
447
405
  }
448
406
 
449
- #ifdef CONFIG_BIGNUM
450
- if (load_jscalc)
451
- bignum_ext = 1;
452
- #endif
453
-
454
407
  if (trace_memory) {
455
408
  js_trace_malloc_init(&trace_data);
456
409
  rt = JS_NewRuntime2(&trace_mf, &trace_data);
@@ -482,11 +435,6 @@ int main(int argc, char **argv)
482
435
  }
483
436
 
484
437
  if (!empty_run) {
485
- #ifdef CONFIG_BIGNUM
486
- if (load_jscalc) {
487
- js_std_eval_binary(ctx, qjsc_qjscalc, qjsc_qjscalc_size, 0);
488
- }
489
- #endif
490
438
  js_std_add_helpers(ctx, argc - optind, argv + optind);
491
439
 
492
440
  /* make 'std' and 'os' visible to non module code */
@@ -76,7 +76,6 @@ static const FeatureEntry feature_list[] = {
76
76
  { "promise", "Promise" },
77
77
  #define FE_MODULE_LOADER 9
78
78
  { "module-loader", NULL },
79
- { "bigint", "BigInt" },
80
79
  };
81
80
 
82
81
  void namelist_add(namelist_t *lp, const char *name, const char *short_name,
@@ -359,7 +358,6 @@ void help(void)
359
358
  {
360
359
  int i;
361
360
  printf("-flto use link time optimization\n");
362
- printf("-fbignum enable bignum extensions\n");
363
361
  printf("-fno-[");
364
362
  for(i = 0; i < countof(feature_list); i++) {
365
363
  if (i != 0)
@@ -492,9 +490,6 @@ int main(int argc, char **argv)
492
490
  int module;
493
491
  OutputTypeEnum output_type;
494
492
  size_t stack_size;
495
- #ifdef CONFIG_BIGNUM
496
- BOOL bignum_ext = FALSE;
497
- #endif
498
493
  namelist_t dynamic_module_list;
499
494
 
500
495
  out_filename = NULL;
@@ -547,13 +542,7 @@ int main(int argc, char **argv)
547
542
  }
548
543
  if (i == countof(feature_list))
549
544
  goto bad_feature;
550
- } else
551
- #ifdef CONFIG_BIGNUM
552
- if (!strcmp(optarg, "bignum")) {
553
- bignum_ext = TRUE;
554
- } else
555
- #endif
556
- {
545
+ } else {
557
546
  bad_feature:
558
547
  fprintf(stderr, "unsupported feature: %s\n", optarg);
559
548
  exit(1);
@@ -630,14 +619,6 @@ int main(int argc, char **argv)
630
619
 
631
620
  rt = JS_NewRuntime();
632
621
  ctx = JS_NewContext(rt);
633
- #ifdef CONFIG_BIGNUM
634
- if (bignum_ext) {
635
- JS_AddIntrinsicBigFloat(ctx);
636
- JS_AddIntrinsicBigDecimal(ctx);
637
- JS_AddIntrinsicOperators(ctx);
638
- JS_EnableBignumExt(ctx, TRUE);
639
- }
640
- #endif
641
622
 
642
623
  /* loader for ES6 modules */
643
624
  JS_SetModuleLoaderFunc(rt, NULL, jsc_module_loader, NULL);
@@ -686,15 +667,6 @@ int main(int argc, char **argv)
686
667
  feature_list[i].init_name);
687
668
  }
688
669
  }
689
- #ifdef CONFIG_BIGNUM
690
- if (bignum_ext) {
691
- fprintf(fo,
692
- " JS_AddIntrinsicBigFloat(ctx);\n"
693
- " JS_AddIntrinsicBigDecimal(ctx);\n"
694
- " JS_AddIntrinsicOperators(ctx);\n"
695
- " JS_EnableBignumExt(ctx, 1);\n");
696
- }
697
- #endif
698
670
  /* add the precompiled modules (XXX: could modify the module
699
671
  loader instead) */
700
672
  for(i = 0; i < init_module_list.count; i++) {
@@ -172,13 +172,6 @@ DEF(status, "status")
172
172
  DEF(reason, "reason")
173
173
  DEF(globalThis, "globalThis")
174
174
  DEF(bigint, "bigint")
175
- #ifdef CONFIG_BIGNUM
176
- DEF(bigfloat, "bigfloat")
177
- DEF(bigdecimal, "bigdecimal")
178
- DEF(roundingMode, "roundingMode")
179
- DEF(maximumSignificantDigits, "maximumSignificantDigits")
180
- DEF(maximumFractionDigits, "maximumFractionDigits")
181
- #endif
182
175
  /* the following 3 atoms are only used with CONFIG_ATOMICS */
183
176
  DEF(not_equal, "not-equal")
184
177
  DEF(timed_out, "timed-out")
@@ -217,13 +210,6 @@ DEF(Float32Array, "Float32Array")
217
210
  DEF(Float64Array, "Float64Array")
218
211
  DEF(DataView, "DataView")
219
212
  DEF(BigInt, "BigInt")
220
- #ifdef CONFIG_BIGNUM
221
- DEF(BigFloat, "BigFloat")
222
- DEF(BigFloatEnv, "BigFloatEnv")
223
- DEF(BigDecimal, "BigDecimal")
224
- DEF(OperatorSet, "OperatorSet")
225
- DEF(Operators, "Operators")
226
- #endif
227
213
  DEF(Map, "Map")
228
214
  DEF(Set, "Set") /* Map + 1 */
229
215
  DEF(WeakMap, "WeakMap") /* Map + 2 */
@@ -266,8 +252,5 @@ DEF(Symbol_hasInstance, "Symbol.hasInstance")
266
252
  DEF(Symbol_species, "Symbol.species")
267
253
  DEF(Symbol_unscopables, "Symbol.unscopables")
268
254
  DEF(Symbol_asyncIterator, "Symbol.asyncIterator")
269
- #ifdef CONFIG_BIGNUM
270
- DEF(Symbol_operatorSet, "Symbol.operatorSet")
271
- #endif
272
255
 
273
256
  #endif /* DEF */
@@ -258,10 +258,7 @@ DEF( xor, 1, 2, 1, none)
258
258
  DEF( or, 1, 2, 1, none)
259
259
  DEF(is_undefined_or_null, 1, 1, 1, none)
260
260
  DEF( private_in, 1, 2, 1, none)
261
- #ifdef CONFIG_BIGNUM
262
- DEF( mul_pow10, 1, 2, 1, none)
263
- DEF( math_mod, 1, 2, 1, none)
264
- #endif
261
+ DEF(push_bigint_i32, 5, 0, 1, i32)
265
262
  /* must be the last non short and non temporary opcode */
266
263
  DEF( nop, 1, 0, 0, none)
267
264