quickjs 0.8.1 → 0.10.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.
- checksums.yaml +4 -4
- data/ext/quickjsrb/extconf.rb +4 -6
- data/ext/quickjsrb/quickjs/cutils.c +2 -0
- data/ext/quickjsrb/quickjs/cutils.h +20 -0
- data/ext/quickjsrb/quickjs/dtoa.c +1620 -0
- data/ext/quickjsrb/quickjs/dtoa.h +83 -0
- data/ext/quickjsrb/quickjs/libregexp.c +34 -6
- data/ext/quickjsrb/quickjs/libregexp.h +5 -0
- data/ext/quickjsrb/quickjs/libunicode-table.h +1792 -1619
- data/ext/quickjsrb/quickjs/libunicode.c +201 -201
- data/ext/quickjsrb/quickjs/qjs.c +47 -60
- data/ext/quickjsrb/quickjs/qjsc.c +136 -76
- data/ext/quickjsrb/quickjs/quickjs-atom.h +7 -17
- data/ext/quickjsrb/quickjs/quickjs-libc.c +206 -109
- data/ext/quickjsrb/quickjs/quickjs-opcode.h +4 -6
- data/ext/quickjsrb/quickjs/quickjs.c +5500 -6786
- data/ext/quickjsrb/quickjs/quickjs.h +69 -32
- data/ext/quickjsrb/quickjs/run-test262.c +10 -1
- data/ext/quickjsrb/quickjs/unicode_gen.c +19 -1
- data/ext/quickjsrb/quickjs/unicode_gen_def.h +12 -0
- data/ext/quickjsrb/quickjsrb.c +9 -10
- data/lib/quickjs/version.rb +1 -1
- metadata +4 -4
- data/ext/quickjsrb/quickjs/libbf.c +0 -8475
- data/ext/quickjsrb/quickjs/libbf.h +0 -535
@@ -76,7 +76,7 @@ static const FeatureEntry feature_list[] = {
|
|
76
76
|
{ "promise", "Promise" },
|
77
77
|
#define FE_MODULE_LOADER 9
|
78
78
|
{ "module-loader", NULL },
|
79
|
-
{ "
|
79
|
+
{ "weakref", "WeakRef" },
|
80
80
|
};
|
81
81
|
|
82
82
|
void namelist_add(namelist_t *lp, const char *name, const char *short_name,
|
@@ -353,13 +353,14 @@ void help(void)
|
|
353
353
|
"-M module_name[,cname] add initialization code for an external C module\n"
|
354
354
|
"-x byte swapped output\n"
|
355
355
|
"-p prefix set the prefix of the generated C names\n"
|
356
|
-
"-S n set the maximum stack size to 'n' bytes (default=%d)\n"
|
356
|
+
"-S n set the maximum stack size to 'n' bytes (default=%d)\n"
|
357
|
+
"-s strip all the debug info\n"
|
358
|
+
"--keep-source keep the source code\n",
|
357
359
|
JS_DEFAULT_STACK_SIZE);
|
358
360
|
#ifdef CONFIG_LTO
|
359
361
|
{
|
360
362
|
int i;
|
361
363
|
printf("-flto use link time optimization\n");
|
362
|
-
printf("-fbignum enable bignum extensions\n");
|
363
364
|
printf("-fno-[");
|
364
365
|
for(i = 0; i < countof(feature_list); i++) {
|
365
366
|
if (i != 0)
|
@@ -473,6 +474,31 @@ static int output_executable(const char *out_filename, const char *cfilename,
|
|
473
474
|
}
|
474
475
|
#endif
|
475
476
|
|
477
|
+
static size_t get_suffixed_size(const char *str)
|
478
|
+
{
|
479
|
+
char *p;
|
480
|
+
size_t v;
|
481
|
+
v = (size_t)strtod(str, &p);
|
482
|
+
switch(*p) {
|
483
|
+
case 'G':
|
484
|
+
v <<= 30;
|
485
|
+
break;
|
486
|
+
case 'M':
|
487
|
+
v <<= 20;
|
488
|
+
break;
|
489
|
+
case 'k':
|
490
|
+
case 'K':
|
491
|
+
v <<= 10;
|
492
|
+
break;
|
493
|
+
default:
|
494
|
+
if (*p != '\0') {
|
495
|
+
fprintf(stderr, "qjs: invalid suffix: %s\n", p);
|
496
|
+
exit(1);
|
497
|
+
}
|
498
|
+
break;
|
499
|
+
}
|
500
|
+
return v;
|
501
|
+
}
|
476
502
|
|
477
503
|
typedef enum {
|
478
504
|
OUTPUT_C,
|
@@ -480,9 +506,24 @@ typedef enum {
|
|
480
506
|
OUTPUT_EXECUTABLE,
|
481
507
|
} OutputTypeEnum;
|
482
508
|
|
509
|
+
static const char *get_short_optarg(int *poptind, int opt,
|
510
|
+
const char *arg, int argc, char **argv)
|
511
|
+
{
|
512
|
+
const char *optarg;
|
513
|
+
if (*arg) {
|
514
|
+
optarg = arg;
|
515
|
+
} else if (*poptind < argc) {
|
516
|
+
optarg = argv[(*poptind)++];
|
517
|
+
} else {
|
518
|
+
fprintf(stderr, "qjsc: expecting parameter for -%c\n", opt);
|
519
|
+
exit(1);
|
520
|
+
}
|
521
|
+
return optarg;
|
522
|
+
}
|
523
|
+
|
483
524
|
int main(int argc, char **argv)
|
484
525
|
{
|
485
|
-
int
|
526
|
+
int i, verbose, strip_flags;
|
486
527
|
const char *out_filename, *cname;
|
487
528
|
char cfilename[1024];
|
488
529
|
FILE *fo;
|
@@ -492,9 +533,6 @@ int main(int argc, char **argv)
|
|
492
533
|
int module;
|
493
534
|
OutputTypeEnum output_type;
|
494
535
|
size_t stack_size;
|
495
|
-
#ifdef CONFIG_BIGNUM
|
496
|
-
BOOL bignum_ext = FALSE;
|
497
|
-
#endif
|
498
536
|
namelist_t dynamic_module_list;
|
499
537
|
|
500
538
|
out_filename = NULL;
|
@@ -504,6 +542,7 @@ int main(int argc, char **argv)
|
|
504
542
|
module = -1;
|
505
543
|
byte_swap = FALSE;
|
506
544
|
verbose = 0;
|
545
|
+
strip_flags = JS_STRIP_SOURCE;
|
507
546
|
use_lto = FALSE;
|
508
547
|
stack_size = 0;
|
509
548
|
memset(&dynamic_module_list, 0, sizeof(dynamic_module_list));
|
@@ -512,30 +551,51 @@ int main(int argc, char **argv)
|
|
512
551
|
namelist_add(&cmodule_list, "std", "std", 0);
|
513
552
|
namelist_add(&cmodule_list, "os", "os", 0);
|
514
553
|
|
515
|
-
|
516
|
-
|
517
|
-
|
554
|
+
optind = 1;
|
555
|
+
while (optind < argc && *argv[optind] == '-') {
|
556
|
+
char *arg = argv[optind] + 1;
|
557
|
+
const char *longopt = "";
|
558
|
+
const char *optarg;
|
559
|
+
/* a single - is not an option, it also stops argument scanning */
|
560
|
+
if (!*arg)
|
518
561
|
break;
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
{
|
562
|
+
optind++;
|
563
|
+
if (*arg == '-') {
|
564
|
+
longopt = arg + 1;
|
565
|
+
arg += strlen(arg);
|
566
|
+
/* -- stops argument scanning */
|
567
|
+
if (!*longopt)
|
568
|
+
break;
|
569
|
+
}
|
570
|
+
for (; *arg || *longopt; longopt = "") {
|
571
|
+
char opt = *arg;
|
572
|
+
if (opt)
|
573
|
+
arg++;
|
574
|
+
if (opt == 'h' || opt == '?' || !strcmp(longopt, "help")) {
|
575
|
+
help();
|
576
|
+
continue;
|
577
|
+
}
|
578
|
+
if (opt == 'o') {
|
579
|
+
out_filename = get_short_optarg(&optind, opt, arg, argc, argv);
|
580
|
+
break;
|
581
|
+
}
|
582
|
+
if (opt == 'c') {
|
583
|
+
output_type = OUTPUT_C;
|
584
|
+
continue;
|
585
|
+
}
|
586
|
+
if (opt == 'e') {
|
587
|
+
output_type = OUTPUT_C_MAIN;
|
588
|
+
continue;
|
589
|
+
}
|
590
|
+
if (opt == 'N') {
|
591
|
+
cname = get_short_optarg(&optind, opt, arg, argc, argv);
|
592
|
+
break;
|
593
|
+
}
|
594
|
+
if (opt == 'f') {
|
536
595
|
const char *p;
|
596
|
+
optarg = get_short_optarg(&optind, opt, arg, argc, argv);
|
537
597
|
p = optarg;
|
538
|
-
if (!strcmp(
|
598
|
+
if (!strcmp(p, "lto")) {
|
539
599
|
use_lto = TRUE;
|
540
600
|
} else if (strstart(p, "no-", &p)) {
|
541
601
|
use_lto = TRUE;
|
@@ -547,27 +607,23 @@ int main(int argc, char **argv)
|
|
547
607
|
}
|
548
608
|
if (i == countof(feature_list))
|
549
609
|
goto bad_feature;
|
550
|
-
} else
|
551
|
-
#ifdef CONFIG_BIGNUM
|
552
|
-
if (!strcmp(optarg, "bignum")) {
|
553
|
-
bignum_ext = TRUE;
|
554
|
-
} else
|
555
|
-
#endif
|
556
|
-
{
|
610
|
+
} else {
|
557
611
|
bad_feature:
|
558
612
|
fprintf(stderr, "unsupported feature: %s\n", optarg);
|
559
613
|
exit(1);
|
560
614
|
}
|
615
|
+
break;
|
561
616
|
}
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
{
|
617
|
+
if (opt == 'm') {
|
618
|
+
module = 1;
|
619
|
+
continue;
|
620
|
+
}
|
621
|
+
if (opt == 'M') {
|
568
622
|
char *p;
|
569
623
|
char path[1024];
|
570
624
|
char cname[1024];
|
625
|
+
|
626
|
+
optarg = get_short_optarg(&optind, opt, arg, argc, argv);
|
571
627
|
pstrcpy(path, sizeof(path), optarg);
|
572
628
|
p = strchr(path, ',');
|
573
629
|
if (p) {
|
@@ -577,25 +633,44 @@ int main(int argc, char **argv)
|
|
577
633
|
get_c_name(cname, sizeof(cname), path);
|
578
634
|
}
|
579
635
|
namelist_add(&cmodule_list, path, cname, 0);
|
636
|
+
break;
|
580
637
|
}
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
638
|
+
if (opt == 'D') {
|
639
|
+
optarg = get_short_optarg(&optind, opt, arg, argc, argv);
|
640
|
+
namelist_add(&dynamic_module_list, optarg, NULL, 0);
|
641
|
+
break;
|
642
|
+
}
|
643
|
+
if (opt == 'x') {
|
644
|
+
byte_swap = 1;
|
645
|
+
continue;
|
646
|
+
}
|
647
|
+
if (opt == 'v') {
|
648
|
+
verbose++;
|
649
|
+
continue;
|
650
|
+
}
|
651
|
+
if (opt == 'p') {
|
652
|
+
c_ident_prefix = get_short_optarg(&optind, opt, arg, argc, argv);
|
653
|
+
break;
|
654
|
+
}
|
655
|
+
if (opt == 'S') {
|
656
|
+
optarg = get_short_optarg(&optind, opt, arg, argc, argv);
|
657
|
+
stack_size = get_suffixed_size(optarg);
|
658
|
+
break;
|
659
|
+
}
|
660
|
+
if (opt == 's') {
|
661
|
+
strip_flags = JS_STRIP_DEBUG;
|
662
|
+
continue;
|
663
|
+
}
|
664
|
+
if (!strcmp(longopt, "keep-source")) {
|
665
|
+
strip_flags = 0;
|
666
|
+
continue;
|
667
|
+
}
|
668
|
+
if (opt) {
|
669
|
+
fprintf(stderr, "qjsc: unknown option '-%c'\n", opt);
|
670
|
+
} else {
|
671
|
+
fprintf(stderr, "qjsc: unknown option '--%s'\n", longopt);
|
672
|
+
}
|
673
|
+
help();
|
599
674
|
}
|
600
675
|
}
|
601
676
|
|
@@ -630,14 +705,8 @@ int main(int argc, char **argv)
|
|
630
705
|
|
631
706
|
rt = JS_NewRuntime();
|
632
707
|
ctx = JS_NewContext(rt);
|
633
|
-
|
634
|
-
|
635
|
-
JS_AddIntrinsicBigFloat(ctx);
|
636
|
-
JS_AddIntrinsicBigDecimal(ctx);
|
637
|
-
JS_AddIntrinsicOperators(ctx);
|
638
|
-
JS_EnableBignumExt(ctx, TRUE);
|
639
|
-
}
|
640
|
-
#endif
|
708
|
+
|
709
|
+
JS_SetStripInfo(rt, strip_flags);
|
641
710
|
|
642
711
|
/* loader for ES6 modules */
|
643
712
|
JS_SetModuleLoaderFunc(rt, NULL, jsc_module_loader, NULL);
|
@@ -686,15 +755,6 @@ int main(int argc, char **argv)
|
|
686
755
|
feature_list[i].init_name);
|
687
756
|
}
|
688
757
|
}
|
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
758
|
/* add the precompiled modules (XXX: could modify the module
|
699
759
|
loader instead) */
|
700
760
|
for(i = 0; i < init_module_list.count; i++) {
|
@@ -81,6 +81,7 @@ DEF(empty_string, "")
|
|
81
81
|
DEF(length, "length")
|
82
82
|
DEF(fileName, "fileName")
|
83
83
|
DEF(lineNumber, "lineNumber")
|
84
|
+
DEF(columnNumber, "columnNumber")
|
84
85
|
DEF(message, "message")
|
85
86
|
DEF(cause, "cause")
|
86
87
|
DEF(errors, "errors")
|
@@ -172,13 +173,10 @@ DEF(status, "status")
|
|
172
173
|
DEF(reason, "reason")
|
173
174
|
DEF(globalThis, "globalThis")
|
174
175
|
DEF(bigint, "bigint")
|
175
|
-
|
176
|
-
DEF(
|
177
|
-
DEF(
|
178
|
-
DEF(
|
179
|
-
DEF(maximumSignificantDigits, "maximumSignificantDigits")
|
180
|
-
DEF(maximumFractionDigits, "maximumFractionDigits")
|
181
|
-
#endif
|
176
|
+
DEF(minus_zero, "-0")
|
177
|
+
DEF(Infinity, "Infinity")
|
178
|
+
DEF(minus_Infinity, "-Infinity")
|
179
|
+
DEF(NaN, "NaN")
|
182
180
|
/* the following 3 atoms are only used with CONFIG_ATOMICS */
|
183
181
|
DEF(not_equal, "not-equal")
|
184
182
|
DEF(timed_out, "timed-out")
|
@@ -217,13 +215,8 @@ DEF(Float32Array, "Float32Array")
|
|
217
215
|
DEF(Float64Array, "Float64Array")
|
218
216
|
DEF(DataView, "DataView")
|
219
217
|
DEF(BigInt, "BigInt")
|
220
|
-
|
221
|
-
DEF(
|
222
|
-
DEF(BigFloatEnv, "BigFloatEnv")
|
223
|
-
DEF(BigDecimal, "BigDecimal")
|
224
|
-
DEF(OperatorSet, "OperatorSet")
|
225
|
-
DEF(Operators, "Operators")
|
226
|
-
#endif
|
218
|
+
DEF(WeakRef, "WeakRef")
|
219
|
+
DEF(FinalizationRegistry, "FinalizationRegistry")
|
227
220
|
DEF(Map, "Map")
|
228
221
|
DEF(Set, "Set") /* Map + 1 */
|
229
222
|
DEF(WeakMap, "WeakMap") /* Map + 2 */
|
@@ -266,8 +259,5 @@ DEF(Symbol_hasInstance, "Symbol.hasInstance")
|
|
266
259
|
DEF(Symbol_species, "Symbol.species")
|
267
260
|
DEF(Symbol_unscopables, "Symbol.unscopables")
|
268
261
|
DEF(Symbol_asyncIterator, "Symbol.asyncIterator")
|
269
|
-
#ifdef CONFIG_BIGNUM
|
270
|
-
DEF(Symbol_operatorSet, "Symbol.operatorSet")
|
271
|
-
#endif
|
272
262
|
|
273
263
|
#endif /* DEF */
|