quickjs 0.10.0 → 0.11.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/quickjs/cutils.h +56 -0
- data/ext/quickjsrb/quickjs/libregexp-opcode.h +11 -1
- data/ext/quickjsrb/quickjs/libregexp.c +883 -132
- data/ext/quickjsrb/quickjs/libregexp.h +1 -0
- data/ext/quickjsrb/quickjs/libunicode-table.h +420 -1
- data/ext/quickjsrb/quickjs/libunicode.c +224 -11
- data/ext/quickjsrb/quickjs/libunicode.h +9 -5
- data/ext/quickjsrb/quickjs/qjs.c +1 -1
- data/ext/quickjsrb/quickjs/qjsc.c +81 -26
- data/ext/quickjsrb/quickjs/quickjs-atom.h +7 -0
- data/ext/quickjsrb/quickjs/quickjs-libc.c +254 -65
- data/ext/quickjsrb/quickjs/quickjs-libc.h +7 -1
- data/ext/quickjsrb/quickjs/quickjs-opcode.h +2 -2
- data/ext/quickjsrb/quickjs/quickjs.c +2021 -686
- data/ext/quickjsrb/quickjs/quickjs.h +52 -8
- data/ext/quickjsrb/quickjs/run-test262.c +109 -32
- data/ext/quickjsrb/quickjs/unicode_gen.c +541 -5
- data/ext/quickjsrb/quickjs/unicode_gen_def.h +15 -0
- data/ext/quickjsrb/quickjsrb.c +1 -1
- data/lib/quickjs/version.rb +1 -1
- metadata +2 -2
@@ -499,6 +499,9 @@ int cr_op(CharRange *cr, const uint32_t *a_pt, int a_len,
|
|
499
499
|
case CR_OP_XOR:
|
500
500
|
is_in = (a_idx & 1) ^ (b_idx & 1);
|
501
501
|
break;
|
502
|
+
case CR_OP_SUB:
|
503
|
+
is_in = (a_idx & 1) & ((b_idx & 1) ^ 1);
|
504
|
+
break;
|
502
505
|
default:
|
503
506
|
abort();
|
504
507
|
}
|
@@ -511,14 +514,14 @@ int cr_op(CharRange *cr, const uint32_t *a_pt, int a_len,
|
|
511
514
|
return 0;
|
512
515
|
}
|
513
516
|
|
514
|
-
int
|
517
|
+
int cr_op1(CharRange *cr, const uint32_t *b_pt, int b_len, int op)
|
515
518
|
{
|
516
519
|
CharRange a = *cr;
|
517
520
|
int ret;
|
518
521
|
cr->len = 0;
|
519
522
|
cr->size = 0;
|
520
523
|
cr->points = NULL;
|
521
|
-
ret = cr_op(cr, a.points, a.len, b_pt, b_len,
|
524
|
+
ret = cr_op(cr, a.points, a.len, b_pt, b_len, op);
|
522
525
|
cr_free(&a);
|
523
526
|
return ret;
|
524
527
|
}
|
@@ -1282,8 +1285,6 @@ int unicode_script(CharRange *cr,
|
|
1282
1285
|
script_idx = unicode_find_name(unicode_script_name_table, script_name);
|
1283
1286
|
if (script_idx < 0)
|
1284
1287
|
return -2;
|
1285
|
-
/* Note: we remove the "Unknown" Script */
|
1286
|
-
script_idx += UNICODE_SCRIPT_Unknown + 1;
|
1287
1288
|
|
1288
1289
|
is_common = (script_idx == UNICODE_SCRIPT_Common ||
|
1289
1290
|
script_idx == UNICODE_SCRIPT_Inherited);
|
@@ -1313,17 +1314,21 @@ int unicode_script(CharRange *cr,
|
|
1313
1314
|
n |= *p++;
|
1314
1315
|
n += 96 + (1 << 12);
|
1315
1316
|
}
|
1316
|
-
if (type == 0)
|
1317
|
-
v = 0;
|
1318
|
-
else
|
1319
|
-
v = *p++;
|
1320
1317
|
c1 = c + n + 1;
|
1321
|
-
if (
|
1322
|
-
|
1323
|
-
|
1318
|
+
if (type != 0) {
|
1319
|
+
v = *p++;
|
1320
|
+
if (v == script_idx || script_idx == UNICODE_SCRIPT_Unknown) {
|
1321
|
+
if (cr_add_interval(cr1, c, c1))
|
1322
|
+
goto fail;
|
1323
|
+
}
|
1324
1324
|
}
|
1325
1325
|
c = c1;
|
1326
1326
|
}
|
1327
|
+
if (script_idx == UNICODE_SCRIPT_Unknown) {
|
1328
|
+
/* Unknown is all the characters outside scripts */
|
1329
|
+
if (cr_invert(cr1))
|
1330
|
+
goto fail;
|
1331
|
+
}
|
1327
1332
|
|
1328
1333
|
if (is_ext) {
|
1329
1334
|
/* add the script extensions */
|
@@ -1554,6 +1559,7 @@ static int unicode_prop_ops(CharRange *cr, ...)
|
|
1554
1559
|
cr2 = &stack[stack_len - 1];
|
1555
1560
|
cr3 = &stack[stack_len++];
|
1556
1561
|
cr_init(cr3, cr->mem_opaque, cr->realloc_func);
|
1562
|
+
/* CR_OP_XOR may be used here */
|
1557
1563
|
if (cr_op(cr3, cr1->points, cr1->len,
|
1558
1564
|
cr2->points, cr2->len, op - POP_UNION + CR_OP_UNION))
|
1559
1565
|
goto fail;
|
@@ -1908,3 +1914,210 @@ BOOL lre_is_space_non_ascii(uint32_t c)
|
|
1908
1914
|
}
|
1909
1915
|
return FALSE;
|
1910
1916
|
}
|
1917
|
+
|
1918
|
+
#define SEQ_MAX_LEN 16
|
1919
|
+
|
1920
|
+
static int unicode_sequence_prop1(int seq_prop_idx, UnicodeSequencePropCB *cb, void *opaque,
|
1921
|
+
CharRange *cr)
|
1922
|
+
{
|
1923
|
+
int i, c, j;
|
1924
|
+
uint32_t seq[SEQ_MAX_LEN];
|
1925
|
+
|
1926
|
+
switch(seq_prop_idx) {
|
1927
|
+
case UNICODE_SEQUENCE_PROP_Basic_Emoji:
|
1928
|
+
if (unicode_prop1(cr, UNICODE_PROP_Basic_Emoji1) < 0)
|
1929
|
+
return -1;
|
1930
|
+
for(i = 0; i < cr->len; i += 2) {
|
1931
|
+
for(c = cr->points[i]; c < cr->points[i + 1]; c++) {
|
1932
|
+
seq[0] = c;
|
1933
|
+
cb(opaque, seq, 1);
|
1934
|
+
}
|
1935
|
+
}
|
1936
|
+
|
1937
|
+
cr->len = 0;
|
1938
|
+
|
1939
|
+
if (unicode_prop1(cr, UNICODE_PROP_Basic_Emoji2) < 0)
|
1940
|
+
return -1;
|
1941
|
+
for(i = 0; i < cr->len; i += 2) {
|
1942
|
+
for(c = cr->points[i]; c < cr->points[i + 1]; c++) {
|
1943
|
+
seq[0] = c;
|
1944
|
+
seq[1] = 0xfe0f;
|
1945
|
+
cb(opaque, seq, 2);
|
1946
|
+
}
|
1947
|
+
}
|
1948
|
+
|
1949
|
+
break;
|
1950
|
+
case UNICODE_SEQUENCE_PROP_RGI_Emoji_Modifier_Sequence:
|
1951
|
+
if (unicode_prop1(cr, UNICODE_PROP_Emoji_Modifier_Base) < 0)
|
1952
|
+
return -1;
|
1953
|
+
for(i = 0; i < cr->len; i += 2) {
|
1954
|
+
for(c = cr->points[i]; c < cr->points[i + 1]; c++) {
|
1955
|
+
for(j = 0; j < 5; j++) {
|
1956
|
+
seq[0] = c;
|
1957
|
+
seq[1] = 0x1f3fb + j;
|
1958
|
+
cb(opaque, seq, 2);
|
1959
|
+
}
|
1960
|
+
}
|
1961
|
+
}
|
1962
|
+
break;
|
1963
|
+
case UNICODE_SEQUENCE_PROP_RGI_Emoji_Flag_Sequence:
|
1964
|
+
if (unicode_prop1(cr, UNICODE_PROP_RGI_Emoji_Flag_Sequence) < 0)
|
1965
|
+
return -1;
|
1966
|
+
for(i = 0; i < cr->len; i += 2) {
|
1967
|
+
for(c = cr->points[i]; c < cr->points[i + 1]; c++) {
|
1968
|
+
int c0, c1;
|
1969
|
+
c0 = c / 26;
|
1970
|
+
c1 = c % 26;
|
1971
|
+
seq[0] = 0x1F1E6 + c0;
|
1972
|
+
seq[1] = 0x1F1E6 + c1;
|
1973
|
+
cb(opaque, seq, 2);
|
1974
|
+
}
|
1975
|
+
}
|
1976
|
+
break;
|
1977
|
+
case UNICODE_SEQUENCE_PROP_RGI_Emoji_ZWJ_Sequence:
|
1978
|
+
{
|
1979
|
+
int len, code, pres, k, mod, mod_count, mod_pos[2], hc_pos, n_mod, n_hc, mod1;
|
1980
|
+
int mod_idx, hc_idx, i0, i1;
|
1981
|
+
const uint8_t *tab = unicode_rgi_emoji_zwj_sequence;
|
1982
|
+
|
1983
|
+
for(i = 0; i < countof(unicode_rgi_emoji_zwj_sequence);) {
|
1984
|
+
len = tab[i++];
|
1985
|
+
k = 0;
|
1986
|
+
mod = 0;
|
1987
|
+
mod_count = 0;
|
1988
|
+
hc_pos = -1;
|
1989
|
+
for(j = 0; j < len; j++) {
|
1990
|
+
code = tab[i++];
|
1991
|
+
code |= tab[i++] << 8;
|
1992
|
+
pres = code >> 15;
|
1993
|
+
mod1 = (code >> 13) & 3;
|
1994
|
+
code &= 0x1fff;
|
1995
|
+
if (code < 0x1000) {
|
1996
|
+
c = code + 0x2000;
|
1997
|
+
} else {
|
1998
|
+
c = 0x1f000 + (code - 0x1000);
|
1999
|
+
}
|
2000
|
+
if (c == 0x1f9b0)
|
2001
|
+
hc_pos = k;
|
2002
|
+
seq[k++] = c;
|
2003
|
+
if (mod1 != 0) {
|
2004
|
+
assert(mod_count < 2);
|
2005
|
+
mod = mod1;
|
2006
|
+
mod_pos[mod_count++] = k;
|
2007
|
+
seq[k++] = 0; /* will be filled later */
|
2008
|
+
}
|
2009
|
+
if (pres) {
|
2010
|
+
seq[k++] = 0xfe0f;
|
2011
|
+
}
|
2012
|
+
if (j < len - 1) {
|
2013
|
+
seq[k++] = 0x200d;
|
2014
|
+
}
|
2015
|
+
}
|
2016
|
+
|
2017
|
+
/* genrate all the variants */
|
2018
|
+
switch(mod) {
|
2019
|
+
case 1:
|
2020
|
+
n_mod = 5;
|
2021
|
+
break;
|
2022
|
+
case 2:
|
2023
|
+
n_mod = 25;
|
2024
|
+
break;
|
2025
|
+
case 3:
|
2026
|
+
n_mod = 20;
|
2027
|
+
break;
|
2028
|
+
default:
|
2029
|
+
n_mod = 1;
|
2030
|
+
break;
|
2031
|
+
}
|
2032
|
+
if (hc_pos >= 0)
|
2033
|
+
n_hc = 4;
|
2034
|
+
else
|
2035
|
+
n_hc = 1;
|
2036
|
+
for(hc_idx = 0; hc_idx < n_hc; hc_idx++) {
|
2037
|
+
for(mod_idx = 0; mod_idx < n_mod; mod_idx++) {
|
2038
|
+
if (hc_pos >= 0)
|
2039
|
+
seq[hc_pos] = 0x1f9b0 + hc_idx;
|
2040
|
+
|
2041
|
+
switch(mod) {
|
2042
|
+
case 1:
|
2043
|
+
seq[mod_pos[0]] = 0x1f3fb + mod_idx;
|
2044
|
+
break;
|
2045
|
+
case 2:
|
2046
|
+
case 3:
|
2047
|
+
i0 = mod_idx / 5;
|
2048
|
+
i1 = mod_idx % 5;
|
2049
|
+
/* avoid identical values */
|
2050
|
+
if (mod == 3 && i0 >= i1)
|
2051
|
+
i0++;
|
2052
|
+
seq[mod_pos[0]] = 0x1f3fb + i0;
|
2053
|
+
seq[mod_pos[1]] = 0x1f3fb + i1;
|
2054
|
+
break;
|
2055
|
+
default:
|
2056
|
+
break;
|
2057
|
+
}
|
2058
|
+
#if 0
|
2059
|
+
for(j = 0; j < k; j++)
|
2060
|
+
printf(" %04x", seq[j]);
|
2061
|
+
printf("\n");
|
2062
|
+
#endif
|
2063
|
+
cb(opaque, seq, k);
|
2064
|
+
}
|
2065
|
+
}
|
2066
|
+
}
|
2067
|
+
}
|
2068
|
+
break;
|
2069
|
+
case UNICODE_SEQUENCE_PROP_RGI_Emoji_Tag_Sequence:
|
2070
|
+
{
|
2071
|
+
for(i = 0; i < countof(unicode_rgi_emoji_tag_sequence);) {
|
2072
|
+
j = 0;
|
2073
|
+
seq[j++] = 0x1F3F4;
|
2074
|
+
for(;;) {
|
2075
|
+
c = unicode_rgi_emoji_tag_sequence[i++];
|
2076
|
+
if (c == 0x00)
|
2077
|
+
break;
|
2078
|
+
seq[j++] = 0xe0000 + c;
|
2079
|
+
}
|
2080
|
+
seq[j++] = 0xe007f;
|
2081
|
+
cb(opaque, seq, j);
|
2082
|
+
}
|
2083
|
+
}
|
2084
|
+
break;
|
2085
|
+
case UNICODE_SEQUENCE_PROP_Emoji_Keycap_Sequence:
|
2086
|
+
if (unicode_prop1(cr, UNICODE_PROP_Emoji_Keycap_Sequence) < 0)
|
2087
|
+
return -1;
|
2088
|
+
for(i = 0; i < cr->len; i += 2) {
|
2089
|
+
for(c = cr->points[i]; c < cr->points[i + 1]; c++) {
|
2090
|
+
seq[0] = c;
|
2091
|
+
seq[1] = 0xfe0f;
|
2092
|
+
seq[2] = 0x20e3;
|
2093
|
+
cb(opaque, seq, 3);
|
2094
|
+
}
|
2095
|
+
}
|
2096
|
+
break;
|
2097
|
+
case UNICODE_SEQUENCE_PROP_RGI_Emoji:
|
2098
|
+
/* all prevous sequences */
|
2099
|
+
for(i = UNICODE_SEQUENCE_PROP_Basic_Emoji; i <= UNICODE_SEQUENCE_PROP_RGI_Emoji_ZWJ_Sequence; i++) {
|
2100
|
+
int ret;
|
2101
|
+
ret = unicode_sequence_prop1(i, cb, opaque, cr);
|
2102
|
+
if (ret < 0)
|
2103
|
+
return ret;
|
2104
|
+
cr->len = 0;
|
2105
|
+
}
|
2106
|
+
break;
|
2107
|
+
default:
|
2108
|
+
return -2;
|
2109
|
+
}
|
2110
|
+
return 0;
|
2111
|
+
}
|
2112
|
+
|
2113
|
+
/* build a unicode sequence property */
|
2114
|
+
/* return -2 if not found, -1 if other error. 'cr' is used as temporary memory. */
|
2115
|
+
int unicode_sequence_prop(const char *prop_name, UnicodeSequencePropCB *cb, void *opaque,
|
2116
|
+
CharRange *cr)
|
2117
|
+
{
|
2118
|
+
int seq_prop_idx;
|
2119
|
+
seq_prop_idx = unicode_find_name(unicode_sequence_prop_name_table, prop_name);
|
2120
|
+
if (seq_prop_idx < 0)
|
2121
|
+
return -2;
|
2122
|
+
return unicode_sequence_prop1(seq_prop_idx, cb, opaque, cr);
|
2123
|
+
}
|
@@ -45,6 +45,7 @@ typedef enum {
|
|
45
45
|
CR_OP_UNION,
|
46
46
|
CR_OP_INTER,
|
47
47
|
CR_OP_XOR,
|
48
|
+
CR_OP_SUB,
|
48
49
|
} CharRangeOpEnum;
|
49
50
|
|
50
51
|
void cr_init(CharRange *cr, void *mem_opaque, void *(*realloc_func)(void *opaque, void *ptr, size_t size));
|
@@ -73,19 +74,18 @@ static inline int cr_add_interval(CharRange *cr, uint32_t c1, uint32_t c2)
|
|
73
74
|
return 0;
|
74
75
|
}
|
75
76
|
|
76
|
-
int
|
77
|
+
int cr_op(CharRange *cr, const uint32_t *a_pt, int a_len,
|
78
|
+
const uint32_t *b_pt, int b_len, int op);
|
79
|
+
int cr_op1(CharRange *cr, const uint32_t *b_pt, int b_len, int op);
|
77
80
|
|
78
81
|
static inline int cr_union_interval(CharRange *cr, uint32_t c1, uint32_t c2)
|
79
82
|
{
|
80
83
|
uint32_t b_pt[2];
|
81
84
|
b_pt[0] = c1;
|
82
85
|
b_pt[1] = c2 + 1;
|
83
|
-
return
|
86
|
+
return cr_op1(cr, b_pt, 2, CR_OP_UNION);
|
84
87
|
}
|
85
88
|
|
86
|
-
int cr_op(CharRange *cr, const uint32_t *a_pt, int a_len,
|
87
|
-
const uint32_t *b_pt, int b_len, int op);
|
88
|
-
|
89
89
|
int cr_invert(CharRange *cr);
|
90
90
|
|
91
91
|
int cr_regexp_canonicalize(CharRange *cr, int is_unicode);
|
@@ -107,6 +107,10 @@ int unicode_script(CharRange *cr, const char *script_name, int is_ext);
|
|
107
107
|
int unicode_general_category(CharRange *cr, const char *gc_name);
|
108
108
|
int unicode_prop(CharRange *cr, const char *prop_name);
|
109
109
|
|
110
|
+
typedef void UnicodeSequencePropCB(void *opaque, const uint32_t *buf, int len);
|
111
|
+
int unicode_sequence_prop(const char *prop_name, UnicodeSequencePropCB *cb, void *opaque,
|
112
|
+
CharRange *cr);
|
113
|
+
|
110
114
|
int lre_case_conv(uint32_t *res, uint32_t c, int conv_type);
|
111
115
|
int lre_canonicalize(uint32_t c, int is_unicode);
|
112
116
|
|
data/ext/quickjsrb/quickjs/qjs.c
CHANGED
@@ -465,7 +465,7 @@ int main(int argc, char **argv)
|
|
465
465
|
}
|
466
466
|
|
467
467
|
/* loader for ES6 modules */
|
468
|
-
|
468
|
+
JS_SetModuleLoaderFunc2(rt, NULL, js_module_loader, js_module_check_attributes, NULL);
|
469
469
|
|
470
470
|
if (dump_unhandled_promise_rejection) {
|
471
471
|
JS_SetHostPromiseRejectionTracker(rt, js_std_promise_rejection_tracker,
|
@@ -170,14 +170,24 @@ static void dump_hex(FILE *f, const uint8_t *buf, size_t len)
|
|
170
170
|
fprintf(f, "\n");
|
171
171
|
}
|
172
172
|
|
173
|
+
typedef enum {
|
174
|
+
CNAME_TYPE_SCRIPT,
|
175
|
+
CNAME_TYPE_MODULE,
|
176
|
+
CNAME_TYPE_JSON_MODULE,
|
177
|
+
} CNameTypeEnum;
|
178
|
+
|
173
179
|
static void output_object_code(JSContext *ctx,
|
174
180
|
FILE *fo, JSValueConst obj, const char *c_name,
|
175
|
-
|
181
|
+
CNameTypeEnum c_name_type)
|
176
182
|
{
|
177
183
|
uint8_t *out_buf;
|
178
184
|
size_t out_buf_len;
|
179
185
|
int flags;
|
180
|
-
|
186
|
+
|
187
|
+
if (c_name_type == CNAME_TYPE_JSON_MODULE)
|
188
|
+
flags = 0;
|
189
|
+
else
|
190
|
+
flags = JS_WRITE_OBJ_BYTECODE;
|
181
191
|
if (byte_swap)
|
182
192
|
flags |= JS_WRITE_OBJ_BSWAP;
|
183
193
|
out_buf = JS_WriteObject(ctx, &out_buf_len, obj, flags);
|
@@ -186,7 +196,7 @@ static void output_object_code(JSContext *ctx,
|
|
186
196
|
exit(1);
|
187
197
|
}
|
188
198
|
|
189
|
-
namelist_add(&cname_list, c_name, NULL,
|
199
|
+
namelist_add(&cname_list, c_name, NULL, c_name_type);
|
190
200
|
|
191
201
|
fprintf(fo, "const uint32_t %s_size = %u;\n\n",
|
192
202
|
c_name, (unsigned int)out_buf_len);
|
@@ -227,7 +237,8 @@ static void find_unique_cname(char *cname, size_t cname_size)
|
|
227
237
|
}
|
228
238
|
|
229
239
|
JSModuleDef *jsc_module_loader(JSContext *ctx,
|
230
|
-
|
240
|
+
const char *module_name, void *opaque,
|
241
|
+
JSValueConst attributes)
|
231
242
|
{
|
232
243
|
JSModuleDef *m;
|
233
244
|
namelist_entry_t *e;
|
@@ -249,9 +260,9 @@ JSModuleDef *jsc_module_loader(JSContext *ctx,
|
|
249
260
|
} else {
|
250
261
|
size_t buf_len;
|
251
262
|
uint8_t *buf;
|
252
|
-
JSValue func_val;
|
253
263
|
char cname[1024];
|
254
|
-
|
264
|
+
int res;
|
265
|
+
|
255
266
|
buf = js_load_file(ctx, &buf_len, module_name);
|
256
267
|
if (!buf) {
|
257
268
|
JS_ThrowReferenceError(ctx, "could not load module filename '%s'",
|
@@ -259,21 +270,59 @@ JSModuleDef *jsc_module_loader(JSContext *ctx,
|
|
259
270
|
return NULL;
|
260
271
|
}
|
261
272
|
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
+
res = js_module_test_json(ctx, attributes);
|
274
|
+
if (has_suffix(module_name, ".json") || res > 0) {
|
275
|
+
/* compile as JSON or JSON5 depending on "type" */
|
276
|
+
JSValue val;
|
277
|
+
int flags;
|
278
|
+
|
279
|
+
if (res == 2)
|
280
|
+
flags = JS_PARSE_JSON_EXT;
|
281
|
+
else
|
282
|
+
flags = 0;
|
283
|
+
val = JS_ParseJSON2(ctx, (char *)buf, buf_len, module_name, flags);
|
284
|
+
js_free(ctx, buf);
|
285
|
+
if (JS_IsException(val))
|
286
|
+
return NULL;
|
287
|
+
/* create a dummy module */
|
288
|
+
m = JS_NewCModule(ctx, module_name, js_module_dummy_init);
|
289
|
+
if (!m) {
|
290
|
+
JS_FreeValue(ctx, val);
|
291
|
+
return NULL;
|
292
|
+
}
|
273
293
|
|
274
|
-
|
275
|
-
|
276
|
-
|
294
|
+
get_c_name(cname, sizeof(cname), module_name);
|
295
|
+
if (namelist_find(&cname_list, cname)) {
|
296
|
+
find_unique_cname(cname, sizeof(cname));
|
297
|
+
}
|
298
|
+
|
299
|
+
/* output the module name */
|
300
|
+
fprintf(outfile, "static const uint8_t %s_module_name[] = {\n",
|
301
|
+
cname);
|
302
|
+
dump_hex(outfile, (const uint8_t *)module_name, strlen(module_name) + 1);
|
303
|
+
fprintf(outfile, "};\n\n");
|
304
|
+
|
305
|
+
output_object_code(ctx, outfile, val, cname, CNAME_TYPE_JSON_MODULE);
|
306
|
+
JS_FreeValue(ctx, val);
|
307
|
+
} else {
|
308
|
+
JSValue func_val;
|
309
|
+
|
310
|
+
/* compile the module */
|
311
|
+
func_val = JS_Eval(ctx, (char *)buf, buf_len, module_name,
|
312
|
+
JS_EVAL_TYPE_MODULE | JS_EVAL_FLAG_COMPILE_ONLY);
|
313
|
+
js_free(ctx, buf);
|
314
|
+
if (JS_IsException(func_val))
|
315
|
+
return NULL;
|
316
|
+
get_c_name(cname, sizeof(cname), module_name);
|
317
|
+
if (namelist_find(&cname_list, cname)) {
|
318
|
+
find_unique_cname(cname, sizeof(cname));
|
319
|
+
}
|
320
|
+
output_object_code(ctx, outfile, func_val, cname, CNAME_TYPE_MODULE);
|
321
|
+
|
322
|
+
/* the module is already referenced, so we must free it */
|
323
|
+
m = JS_VALUE_GET_PTR(func_val);
|
324
|
+
JS_FreeValue(ctx, func_val);
|
325
|
+
}
|
277
326
|
}
|
278
327
|
return m;
|
279
328
|
}
|
@@ -313,8 +362,11 @@ static void compile_file(JSContext *ctx, FILE *fo,
|
|
313
362
|
pstrcpy(c_name, sizeof(c_name), c_name1);
|
314
363
|
} else {
|
315
364
|
get_c_name(c_name, sizeof(c_name), filename);
|
365
|
+
if (namelist_find(&cname_list, c_name)) {
|
366
|
+
find_unique_cname(c_name, sizeof(c_name));
|
367
|
+
}
|
316
368
|
}
|
317
|
-
output_object_code(ctx, fo, obj, c_name,
|
369
|
+
output_object_code(ctx, fo, obj, c_name, CNAME_TYPE_SCRIPT);
|
318
370
|
JS_FreeValue(ctx, obj);
|
319
371
|
}
|
320
372
|
|
@@ -709,7 +761,7 @@ int main(int argc, char **argv)
|
|
709
761
|
JS_SetStripInfo(rt, strip_flags);
|
710
762
|
|
711
763
|
/* loader for ES6 modules */
|
712
|
-
|
764
|
+
JS_SetModuleLoaderFunc2(rt, NULL, jsc_module_loader, NULL, NULL);
|
713
765
|
|
714
766
|
fprintf(fo, "/* File generated automatically by the QuickJS compiler. */\n"
|
715
767
|
"\n"
|
@@ -732,7 +784,7 @@ int main(int argc, char **argv)
|
|
732
784
|
}
|
733
785
|
|
734
786
|
for(i = 0; i < dynamic_module_list.count; i++) {
|
735
|
-
if (!jsc_module_loader(ctx, dynamic_module_list.array[i].name, NULL)) {
|
787
|
+
if (!jsc_module_loader(ctx, dynamic_module_list.array[i].name, NULL, JS_UNDEFINED)) {
|
736
788
|
fprintf(stderr, "Could not load dynamic module '%s'\n",
|
737
789
|
dynamic_module_list.array[i].name);
|
738
790
|
exit(1);
|
@@ -770,9 +822,12 @@ int main(int argc, char **argv)
|
|
770
822
|
}
|
771
823
|
for(i = 0; i < cname_list.count; i++) {
|
772
824
|
namelist_entry_t *e = &cname_list.array[i];
|
773
|
-
if (e->flags) {
|
825
|
+
if (e->flags == CNAME_TYPE_MODULE) {
|
774
826
|
fprintf(fo, " js_std_eval_binary(ctx, %s, %s_size, 1);\n",
|
775
827
|
e->name, e->name);
|
828
|
+
} else if (e->flags == CNAME_TYPE_JSON_MODULE) {
|
829
|
+
fprintf(fo, " js_std_eval_binary_json_module(ctx, %s, %s_size, (const char *)%s_module_name);\n",
|
830
|
+
e->name, e->name, e->name);
|
776
831
|
}
|
777
832
|
}
|
778
833
|
fprintf(fo,
|
@@ -788,7 +843,7 @@ int main(int argc, char **argv)
|
|
788
843
|
|
789
844
|
/* add the module loader if necessary */
|
790
845
|
if (feature_bitmap & (1 << FE_MODULE_LOADER)) {
|
791
|
-
fprintf(fo, "
|
846
|
+
fprintf(fo, " JS_SetModuleLoaderFunc2(rt, NULL, js_module_loader, js_module_check_attributes, NULL);\n");
|
792
847
|
}
|
793
848
|
|
794
849
|
fprintf(fo,
|
@@ -797,7 +852,7 @@ int main(int argc, char **argv)
|
|
797
852
|
|
798
853
|
for(i = 0; i < cname_list.count; i++) {
|
799
854
|
namelist_entry_t *e = &cname_list.array[i];
|
800
|
-
if (
|
855
|
+
if (e->flags == CNAME_TYPE_SCRIPT) {
|
801
856
|
fprintf(fo, " js_std_eval_binary(ctx, %s, %s_size, 0);\n",
|
802
857
|
e->name, e->name);
|
803
858
|
}
|
@@ -177,6 +177,12 @@ DEF(minus_zero, "-0")
|
|
177
177
|
DEF(Infinity, "Infinity")
|
178
178
|
DEF(minus_Infinity, "-Infinity")
|
179
179
|
DEF(NaN, "NaN")
|
180
|
+
DEF(hasIndices, "hasIndices")
|
181
|
+
DEF(ignoreCase, "ignoreCase")
|
182
|
+
DEF(multiline, "multiline")
|
183
|
+
DEF(dotAll, "dotAll")
|
184
|
+
DEF(sticky, "sticky")
|
185
|
+
DEF(unicodeSets, "unicodeSets")
|
180
186
|
/* the following 3 atoms are only used with CONFIG_ATOMICS */
|
181
187
|
DEF(not_equal, "not-equal")
|
182
188
|
DEF(timed_out, "timed-out")
|
@@ -211,6 +217,7 @@ DEF(Int32Array, "Int32Array")
|
|
211
217
|
DEF(Uint32Array, "Uint32Array")
|
212
218
|
DEF(BigInt64Array, "BigInt64Array")
|
213
219
|
DEF(BigUint64Array, "BigUint64Array")
|
220
|
+
DEF(Float16Array, "Float16Array")
|
214
221
|
DEF(Float32Array, "Float32Array")
|
215
222
|
DEF(Float64Array, "Float64Array")
|
216
223
|
DEF(DataView, "DataView")
|