quickjs 0.9.0 → 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/quickjs/cutils.c +2 -0
- data/ext/quickjsrb/quickjs/dtoa.c +5 -11
- data/ext/quickjsrb/quickjs/libunicode-table.h +1792 -1619
- data/ext/quickjsrb/quickjs/qjs.c +47 -8
- data/ext/quickjsrb/quickjs/qjsc.c +135 -47
- data/ext/quickjsrb/quickjs/quickjs-atom.h +7 -0
- data/ext/quickjsrb/quickjs/quickjs-libc.c +206 -109
- data/ext/quickjsrb/quickjs/quickjs-opcode.h +3 -2
- data/ext/quickjsrb/quickjs/quickjs.c +2506 -952
- data/ext/quickjsrb/quickjs/quickjs.h +30 -7
- 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/lib/quickjs/version.rb +1 -1
- metadata +2 -2
@@ -27,6 +27,7 @@
|
|
27
27
|
|
28
28
|
#include <stdio.h>
|
29
29
|
#include <stdint.h>
|
30
|
+
#include <string.h>
|
30
31
|
|
31
32
|
#ifdef __cplusplus
|
32
33
|
extern "C" {
|
@@ -48,7 +49,6 @@ extern "C" {
|
|
48
49
|
|
49
50
|
typedef struct JSRuntime JSRuntime;
|
50
51
|
typedef struct JSContext JSContext;
|
51
|
-
typedef struct JSObject JSObject;
|
52
52
|
typedef struct JSClass JSClass;
|
53
53
|
typedef uint32_t JSClassID;
|
54
54
|
typedef uint32_t JSAtom;
|
@@ -78,6 +78,7 @@ enum {
|
|
78
78
|
JS_TAG_BIG_INT = -9,
|
79
79
|
JS_TAG_SYMBOL = -8,
|
80
80
|
JS_TAG_STRING = -7,
|
81
|
+
JS_TAG_STRING_ROPE = -6,
|
81
82
|
JS_TAG_MODULE = -3, /* used internally */
|
82
83
|
JS_TAG_FUNCTION_BYTECODE = -2, /* used internally */
|
83
84
|
JS_TAG_OBJECT = -1,
|
@@ -280,8 +281,6 @@ static inline JSValue __JS_NewShortBigInt(JSContext *ctx, int64_t d)
|
|
280
281
|
#define JS_VALUE_IS_BOTH_INT(v1, v2) ((JS_VALUE_GET_TAG(v1) | JS_VALUE_GET_TAG(v2)) == 0)
|
281
282
|
#define JS_VALUE_IS_BOTH_FLOAT(v1, v2) (JS_TAG_IS_FLOAT64(JS_VALUE_GET_TAG(v1)) && JS_TAG_IS_FLOAT64(JS_VALUE_GET_TAG(v2)))
|
282
283
|
|
283
|
-
#define JS_VALUE_GET_OBJ(v) ((JSObject *)JS_VALUE_GET_PTR(v))
|
284
|
-
#define JS_VALUE_GET_STRING(v) ((JSString *)JS_VALUE_GET_PTR(v))
|
285
284
|
#define JS_VALUE_HAS_REF_COUNT(v) ((unsigned)JS_VALUE_GET_TAG(v) >= (unsigned)JS_TAG_FIRST)
|
286
285
|
|
287
286
|
/* special values */
|
@@ -323,7 +322,9 @@ static inline JSValue __JS_NewShortBigInt(JSContext *ctx, int64_t d)
|
|
323
322
|
#define JS_PROP_NO_ADD (1 << 16) /* internal use */
|
324
323
|
#define JS_PROP_NO_EXOTIC (1 << 17) /* internal use */
|
325
324
|
|
326
|
-
#
|
325
|
+
#ifndef JS_DEFAULT_STACK_SIZE
|
326
|
+
#define JS_DEFAULT_STACK_SIZE (1024 * 1024)
|
327
|
+
#endif
|
327
328
|
|
328
329
|
/* JS_Eval() flags */
|
329
330
|
#define JS_EVAL_TYPE_GLOBAL (0 << 0) /* global code (default) */
|
@@ -333,7 +334,6 @@ static inline JSValue __JS_NewShortBigInt(JSContext *ctx, int64_t d)
|
|
333
334
|
#define JS_EVAL_TYPE_MASK (3 << 0)
|
334
335
|
|
335
336
|
#define JS_EVAL_FLAG_STRICT (1 << 3) /* force 'strict' mode */
|
336
|
-
#define JS_EVAL_FLAG_STRIP (1 << 4) /* force 'strip' mode */
|
337
337
|
/* compile but do not run. The result is an object with a
|
338
338
|
JS_TAG_FUNCTION_BYTECODE or JS_TAG_MODULE tag. It can be executed
|
339
339
|
with JS_EvalFunction(). */
|
@@ -406,6 +406,7 @@ void JS_AddIntrinsicProxy(JSContext *ctx);
|
|
406
406
|
void JS_AddIntrinsicMapSet(JSContext *ctx);
|
407
407
|
void JS_AddIntrinsicTypedArrays(JSContext *ctx);
|
408
408
|
void JS_AddIntrinsicPromise(JSContext *ctx);
|
409
|
+
void JS_AddIntrinsicWeakRef(JSContext *ctx);
|
409
410
|
|
410
411
|
JSValue js_string_codePointRange(JSContext *ctx, JSValueConst this_val,
|
411
412
|
int argc, JSValueConst *argv);
|
@@ -500,6 +501,17 @@ typedef struct JSClassExoticMethods {
|
|
500
501
|
/* return < 0 if exception or TRUE/FALSE */
|
501
502
|
int (*set_property)(JSContext *ctx, JSValueConst obj, JSAtom atom,
|
502
503
|
JSValueConst value, JSValueConst receiver, int flags);
|
504
|
+
|
505
|
+
/* To get a consistent object behavior when get_prototype != NULL,
|
506
|
+
get_property, set_property and set_prototype must be != NULL
|
507
|
+
and the object must be created with a JS_NULL prototype. */
|
508
|
+
JSValue (*get_prototype)(JSContext *ctx, JSValueConst obj);
|
509
|
+
/* return < 0 if exception or TRUE/FALSE */
|
510
|
+
int (*set_prototype)(JSContext *ctx, JSValueConst obj, JSValueConst proto_val);
|
511
|
+
/* return < 0 if exception or TRUE/FALSE */
|
512
|
+
int (*is_extensible)(JSContext *ctx, JSValueConst obj);
|
513
|
+
/* return < 0 if exception or TRUE/FALSE */
|
514
|
+
int (*prevent_extensions)(JSContext *ctx, JSValueConst obj);
|
503
515
|
} JSClassExoticMethods;
|
504
516
|
|
505
517
|
typedef void JSClassFinalizer(JSRuntime *rt, JSValue val);
|
@@ -632,7 +644,8 @@ static inline JS_BOOL JS_IsUninitialized(JSValueConst v)
|
|
632
644
|
|
633
645
|
static inline JS_BOOL JS_IsString(JSValueConst v)
|
634
646
|
{
|
635
|
-
return JS_VALUE_GET_TAG(v) == JS_TAG_STRING
|
647
|
+
return JS_VALUE_GET_TAG(v) == JS_TAG_STRING ||
|
648
|
+
JS_VALUE_GET_TAG(v) == JS_TAG_STRING_ROPE;
|
636
649
|
}
|
637
650
|
|
638
651
|
static inline JS_BOOL JS_IsSymbol(JSValueConst v)
|
@@ -717,7 +730,10 @@ int JS_ToBigInt64(JSContext *ctx, int64_t *pres, JSValueConst val);
|
|
717
730
|
int JS_ToInt64Ext(JSContext *ctx, int64_t *pres, JSValueConst val);
|
718
731
|
|
719
732
|
JSValue JS_NewStringLen(JSContext *ctx, const char *str1, size_t len1);
|
720
|
-
JSValue JS_NewString(JSContext *ctx, const char *str)
|
733
|
+
static inline JSValue JS_NewString(JSContext *ctx, const char *str)
|
734
|
+
{
|
735
|
+
return JS_NewStringLen(ctx, str, strlen(str));
|
736
|
+
}
|
721
737
|
JSValue JS_NewAtomString(JSContext *ctx, const char *str);
|
722
738
|
JSValue JS_ToString(JSContext *ctx, JSValueConst val);
|
723
739
|
JSValue JS_ToPropertyKey(JSContext *ctx, JSValueConst val);
|
@@ -827,6 +843,7 @@ int JS_DefinePropertyGetSet(JSContext *ctx, JSValueConst this_obj,
|
|
827
843
|
void JS_SetOpaque(JSValue obj, void *opaque);
|
828
844
|
void *JS_GetOpaque(JSValueConst obj, JSClassID class_id);
|
829
845
|
void *JS_GetOpaque2(JSContext *ctx, JSValueConst obj, JSClassID class_id);
|
846
|
+
void *JS_GetAnyOpaque(JSValueConst obj, JSClassID *class_id);
|
830
847
|
|
831
848
|
/* 'buf' must be zero terminated i.e. buf[buf_len] = '\0'. */
|
832
849
|
JSValue JS_ParseJSON(JSContext *ctx, const char *buf, size_t buf_len,
|
@@ -895,6 +912,12 @@ typedef int JSInterruptHandler(JSRuntime *rt, void *opaque);
|
|
895
912
|
void JS_SetInterruptHandler(JSRuntime *rt, JSInterruptHandler *cb, void *opaque);
|
896
913
|
/* if can_block is TRUE, Atomics.wait() can be used */
|
897
914
|
void JS_SetCanBlock(JSRuntime *rt, JS_BOOL can_block);
|
915
|
+
/* select which debug info is stripped from the compiled code */
|
916
|
+
#define JS_STRIP_SOURCE (1 << 0) /* strip source code */
|
917
|
+
#define JS_STRIP_DEBUG (1 << 1) /* strip all debug info including source code */
|
918
|
+
void JS_SetStripInfo(JSRuntime *rt, int flags);
|
919
|
+
int JS_GetStripInfo(JSRuntime *rt);
|
920
|
+
|
898
921
|
/* set the [IsHTMLDDA] internal slot */
|
899
922
|
void JS_SetIsHTMLDDA(JSContext *ctx, JSValueConst obj);
|
900
923
|
|
@@ -757,6 +757,13 @@ static JSValue js_IsHTMLDDA(JSContext *ctx, JSValue this_val,
|
|
757
757
|
return JS_NULL;
|
758
758
|
}
|
759
759
|
|
760
|
+
static JSValue js_gc(JSContext *ctx, JSValueConst this_val,
|
761
|
+
int argc, JSValueConst *argv)
|
762
|
+
{
|
763
|
+
JS_RunGC(JS_GetRuntime(ctx));
|
764
|
+
return JS_UNDEFINED;
|
765
|
+
}
|
766
|
+
|
760
767
|
static JSValue add_helpers1(JSContext *ctx)
|
761
768
|
{
|
762
769
|
JSValue global_obj;
|
@@ -790,6 +797,8 @@ static JSValue add_helpers1(JSContext *ctx)
|
|
790
797
|
obj = JS_NewCFunction(ctx, js_IsHTMLDDA, "IsHTMLDDA", 0);
|
791
798
|
JS_SetIsHTMLDDA(ctx, obj);
|
792
799
|
JS_SetPropertyStr(ctx, obj262, "IsHTMLDDA", obj);
|
800
|
+
JS_SetPropertyStr(ctx, obj262, "gc",
|
801
|
+
JS_NewCFunction(ctx, js_gc, "gc", 0));
|
793
802
|
|
794
803
|
JS_SetPropertyStr(ctx, global_obj, "$262", JS_DupValue(ctx, obj262));
|
795
804
|
|
@@ -1571,7 +1580,7 @@ int run_test_buf(const char *filename, const char *harness, namelist_t *ip,
|
|
1571
1580
|
|
1572
1581
|
for (i = 0; i < ip->count; i++) {
|
1573
1582
|
if (eval_file(ctx, harness, ip->array[i],
|
1574
|
-
JS_EVAL_TYPE_GLOBAL
|
1583
|
+
JS_EVAL_TYPE_GLOBAL)) {
|
1575
1584
|
fatal(1, "error including %s for %s", ip->array[i], filename);
|
1576
1585
|
}
|
1577
1586
|
}
|
@@ -625,7 +625,7 @@ void parse_derived_core_properties(const char *filename)
|
|
625
625
|
p++;
|
626
626
|
p += strspn(p, " \t");
|
627
627
|
q = buf;
|
628
|
-
while (*p != '\0' && *p != ' ' && *p != '#' && *p != '\t') {
|
628
|
+
while (*p != '\0' && *p != ' ' && *p != '#' && *p != '\t' && *p != ';') {
|
629
629
|
if ((q - buf) < sizeof(buf) - 1)
|
630
630
|
*q++ = *p;
|
631
631
|
p++;
|
@@ -1117,6 +1117,24 @@ void find_run_type(TableEntry *te, CCInfo *tab, int code)
|
|
1117
1117
|
te->ext_data[1] = ci->u_data[1];
|
1118
1118
|
te->ext_data[2] = ci->u_data[2];
|
1119
1119
|
te->ext_len = 3;
|
1120
|
+
} else if (ci->u_len == 2 && ci->l_len == 0 && ci->f_len == 1) {
|
1121
|
+
// U+FB05 LATIN SMALL LIGATURE LONG S T
|
1122
|
+
assert(code == 0xFB05);
|
1123
|
+
te->len = 1;
|
1124
|
+
te->type = RUN_TYPE_UF_EXT2;
|
1125
|
+
te->ext_data[0] = ci->u_data[0];
|
1126
|
+
te->ext_data[1] = ci->u_data[1];
|
1127
|
+
te->ext_len = 2;
|
1128
|
+
} else if (ci->u_len == 3 && ci->l_len == 0 && ci->f_len == 1) {
|
1129
|
+
// U+1FD3 GREEK SMALL LETTER IOTA WITH DIALYTIKA AND OXIA or
|
1130
|
+
// U+1FE3 GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND OXIA
|
1131
|
+
assert(code == 0x1FD3 || code == 0x1FE3);
|
1132
|
+
te->len = 1;
|
1133
|
+
te->type = RUN_TYPE_UF_EXT3;
|
1134
|
+
te->ext_data[0] = ci->u_data[0];
|
1135
|
+
te->ext_data[1] = ci->u_data[1];
|
1136
|
+
te->ext_data[2] = ci->u_data[2];
|
1137
|
+
te->ext_len = 3;
|
1120
1138
|
} else {
|
1121
1139
|
printf("unsupported encoding case:\n");
|
1122
1140
|
dump_cc_info(ci, code);
|
@@ -82,6 +82,7 @@ DEF(Egyptian_Hieroglyphs, "Egyp")
|
|
82
82
|
DEF(Elbasan, "Elba")
|
83
83
|
DEF(Elymaic, "Elym")
|
84
84
|
DEF(Ethiopic, "Ethi")
|
85
|
+
DEF(Garay, "Gara")
|
85
86
|
DEF(Georgian, "Geor")
|
86
87
|
DEF(Glagolitic, "Glag")
|
87
88
|
DEF(Gothic, "Goth")
|
@@ -90,6 +91,7 @@ DEF(Greek, "Grek")
|
|
90
91
|
DEF(Gujarati, "Gujr")
|
91
92
|
DEF(Gunjala_Gondi, "Gong")
|
92
93
|
DEF(Gurmukhi, "Guru")
|
94
|
+
DEF(Gurung_Khema, "Gukh")
|
93
95
|
DEF(Han, "Hani")
|
94
96
|
DEF(Hangul, "Hang")
|
95
97
|
DEF(Hanifi_Rohingya, "Rohg")
|
@@ -112,6 +114,7 @@ DEF(Khmer, "Khmr")
|
|
112
114
|
DEF(Khojki, "Khoj")
|
113
115
|
DEF(Khitan_Small_Script, "Kits")
|
114
116
|
DEF(Khudawadi, "Sind")
|
117
|
+
DEF(Kirat_Rai, "Krai")
|
115
118
|
DEF(Lao, "Laoo")
|
116
119
|
DEF(Latin, "Latn")
|
117
120
|
DEF(Lepcha, "Lepc")
|
@@ -149,6 +152,7 @@ DEF(Nushu, "Nshu")
|
|
149
152
|
DEF(Nyiakeng_Puachue_Hmong, "Hmnp")
|
150
153
|
DEF(Ogham, "Ogam")
|
151
154
|
DEF(Ol_Chiki, "Olck")
|
155
|
+
DEF(Ol_Onal, "Onao")
|
152
156
|
DEF(Old_Hungarian, "Hung")
|
153
157
|
DEF(Old_Italic, "Ital")
|
154
158
|
DEF(Old_North_Arabian, "Narb")
|
@@ -180,6 +184,7 @@ DEF(Sogdian, "Sogd")
|
|
180
184
|
DEF(Sora_Sompeng, "Sora")
|
181
185
|
DEF(Soyombo, "Soyo")
|
182
186
|
DEF(Sundanese, "Sund")
|
187
|
+
DEF(Sunuwar, "Sunu")
|
183
188
|
DEF(Syloti_Nagri, "Sylo")
|
184
189
|
DEF(Syriac, "Syrc")
|
185
190
|
DEF(Tagalog, "Tglg")
|
@@ -197,7 +202,9 @@ DEF(Tibetan, "Tibt")
|
|
197
202
|
DEF(Tifinagh, "Tfng")
|
198
203
|
DEF(Tirhuta, "Tirh")
|
199
204
|
DEF(Tangsa, "Tnsa")
|
205
|
+
DEF(Todhri, "Todr")
|
200
206
|
DEF(Toto, "Toto")
|
207
|
+
DEF(Tulu_Tigalari, "Tutg")
|
201
208
|
DEF(Ugaritic, "Ugar")
|
202
209
|
DEF(Vai, "Vaii")
|
203
210
|
DEF(Vithkuqi, "Vith")
|
@@ -236,11 +243,13 @@ DEF(Deprecated, "Dep")
|
|
236
243
|
DEF(Diacritic, "Dia")
|
237
244
|
DEF(Extender, "Ext")
|
238
245
|
DEF(Hex_Digit, "Hex")
|
246
|
+
DEF(IDS_Unary_Operator, "IDSU")
|
239
247
|
DEF(IDS_Binary_Operator, "IDSB")
|
240
248
|
DEF(IDS_Trinary_Operator, "IDST")
|
241
249
|
DEF(Ideographic, "Ideo")
|
242
250
|
DEF(Join_Control, "Join_C")
|
243
251
|
DEF(Logical_Order_Exception, "LOE")
|
252
|
+
DEF(Modifier_Combining_Mark, "MCM")
|
244
253
|
DEF(Noncharacter_Code_Point, "NChar")
|
245
254
|
DEF(Pattern_Syntax, "Pat_Syn")
|
246
255
|
DEF(Pattern_White_Space, "Pat_WS")
|
@@ -279,6 +288,9 @@ DEF(Changes_When_Uppercased, "CWU")
|
|
279
288
|
DEF(Grapheme_Base, "Gr_Base")
|
280
289
|
DEF(Grapheme_Extend, "Gr_Ext")
|
281
290
|
DEF(ID_Continue, "IDC")
|
291
|
+
DEF(ID_Compat_Math_Start, "")
|
292
|
+
DEF(ID_Compat_Math_Continue, "")
|
293
|
+
DEF(InCB, "")
|
282
294
|
DEF(Lowercase, "Lower")
|
283
295
|
DEF(Math, "")
|
284
296
|
DEF(Uppercase, "Upper")
|
data/lib/quickjs/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: quickjs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- hmsk
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-06-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|