jseption 0.0.5 → 0.0.7
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.
- package/README.md +30 -6
- package/dist/atoms.d.ts +1 -0
- package/dist/atoms.js +2 -1
- package/dist/atoms.js.map +1 -1
- package/dist/builtins/base64.d.ts +14 -0
- package/dist/builtins/base64.js +219 -0
- package/dist/builtins/base64.js.map +1 -0
- package/dist/builtins/bigint.js +3 -3
- package/dist/builtins/bigint.js.map +1 -1
- package/dist/builtins/date.d.ts +1 -0
- package/dist/builtins/date.js +26 -12
- package/dist/builtins/date.js.map +1 -1
- package/dist/builtins/error.js +9 -0
- package/dist/builtins/error.js.map +1 -1
- package/dist/builtins/float16.d.ts +3 -0
- package/dist/builtins/float16.js +69 -0
- package/dist/builtins/float16.js.map +1 -0
- package/dist/builtins/function.js +2 -2
- package/dist/builtins/index.js +9 -6
- package/dist/builtins/index.js.map +1 -1
- package/dist/builtins/iterator.d.ts +2 -0
- package/dist/builtins/iterator.js +624 -0
- package/dist/builtins/iterator.js.map +1 -0
- package/dist/builtins/json.d.ts +13 -1
- package/dist/builtins/json.js +283 -211
- package/dist/builtins/json.js.map +1 -1
- package/dist/builtins/mapset.js +365 -6
- package/dist/builtins/mapset.js.map +1 -1
- package/dist/builtins/math.js +203 -3
- package/dist/builtins/math.js.map +1 -1
- package/dist/builtins/native.js +6 -6
- package/dist/builtins/object.js +9 -2
- package/dist/builtins/object.js.map +1 -1
- package/dist/builtins/promise.js +31 -11
- package/dist/builtins/promise.js.map +1 -1
- package/dist/builtins/proxy.js +2 -2
- package/dist/builtins/reflect.js +6 -2
- package/dist/builtins/reflect.js.map +1 -1
- package/dist/builtins/regexp.js +74 -3
- package/dist/builtins/regexp.js.map +1 -1
- package/dist/builtins/string.js +1 -1
- package/dist/builtins/symbol.js +1 -1
- package/dist/builtins/symbol.js.map +1 -1
- package/dist/builtins/typedarray.d.ts +4 -1
- package/dist/builtins/typedarray.js +325 -37
- package/dist/builtins/typedarray.js.map +1 -1
- package/dist/builtins/weakref.js +7 -7
- package/dist/embed.d.ts +5 -0
- package/dist/embed.js +36 -11
- package/dist/embed.js.map +1 -1
- package/dist/interpreter.js +15 -14
- package/dist/interpreter.js.map +1 -1
- package/dist/jit.d.ts +1 -0
- package/dist/jit.js +51 -13
- package/dist/jit.js.map +1 -1
- package/dist/jit_hook.d.ts +1 -0
- package/dist/jit_hook.js.map +1 -1
- package/dist/jit_runtime.d.ts +1 -1
- package/dist/jit_runtime.js +6 -6
- package/dist/jit_runtime.js.map +1 -1
- package/dist/jit_stack.d.ts +1 -0
- package/dist/jit_stack.js +2 -1
- package/dist/jit_stack.js.map +1 -1
- package/dist/jseption.d.ts +2 -0
- package/dist/jseption.js +1 -0
- package/dist/jseption.js.map +1 -1
- package/dist/membrane.d.ts +6 -0
- package/dist/membrane.js +7 -3
- package/dist/membrane.js.map +1 -1
- package/dist/module.js +5 -3
- package/dist/module.js.map +1 -1
- package/dist/parser.js +26 -9
- package/dist/parser.js.map +1 -1
- package/dist/print.d.ts +12 -0
- package/dist/print.js +494 -0
- package/dist/print.js.map +1 -0
- package/dist/qjs.js +13 -10
- package/dist/qjs.js.map +1 -1
- package/dist/quickjs.d.ts +8 -0
- package/dist/quickjs.js +132 -53
- package/dist/quickjs.js.map +1 -1
- package/dist/std.d.ts +4 -2
- package/dist/std.js +42 -8
- package/dist/std.js.map +1 -1
- package/dist/values.d.ts +31 -27
- package/dist/values.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* IEEE 754 binary16 conversions (port of tofp16 / fromfp16 in cutils.h).
|
|
3
|
+
*
|
|
4
|
+
* They are implemented here rather than borrowed from the host so that
|
|
5
|
+
* Math.f16round and DataView.prototype.getFloat16 / setFloat16 behave the
|
|
6
|
+
* same on every host, including hosts without Float16Array. The bit
|
|
7
|
+
* patterns are QuickJS's: a NaN is stored as 0x7c01 with its sign.
|
|
8
|
+
*/
|
|
9
|
+
/* the bits of 0x1p-25. Written without a hex bigint literal containing the
|
|
10
|
+
digit 'e' (0x3e60000000000000n), which jseption's own lexer rejects, so
|
|
11
|
+
that this file still parses with jseption (tests/strip-types.test.ts) */
|
|
12
|
+
const P2_M25 = BigInt(0x3e6) << 52n;
|
|
13
|
+
const f64 = new Float64Array(1);
|
|
14
|
+
const u64 = new BigUint64Array(f64.buffer);
|
|
15
|
+
function float64_as_uint64(d) {
|
|
16
|
+
f64[0] = d;
|
|
17
|
+
return u64[0];
|
|
18
|
+
}
|
|
19
|
+
function uint64_as_float64(v) {
|
|
20
|
+
u64[0] = v;
|
|
21
|
+
return f64[0];
|
|
22
|
+
}
|
|
23
|
+
/* binary16 bits -> double */
|
|
24
|
+
export function fromfp16(v) {
|
|
25
|
+
let v1 = v & 0x7fff;
|
|
26
|
+
if (v1 >= 0x7c00)
|
|
27
|
+
v1 += 0x1f8000; /* NaN or infinity */
|
|
28
|
+
const d = uint64_as_float64((BigInt(v >> 15) << 63n) | (BigInt(v1) << 42n));
|
|
29
|
+
return d * 2 ** 1008;
|
|
30
|
+
}
|
|
31
|
+
/* double -> binary16 bits, rounding to nearest with ties to even */
|
|
32
|
+
export function tofp16(d) {
|
|
33
|
+
let a = float64_as_uint64(d);
|
|
34
|
+
const sgn = Number(a >> 63n);
|
|
35
|
+
a &= 0x7fffffffffffffffn;
|
|
36
|
+
let v;
|
|
37
|
+
if (a > 0x7ff0000000000000n) {
|
|
38
|
+
/* nan */
|
|
39
|
+
v = 0x7c01;
|
|
40
|
+
}
|
|
41
|
+
else if (a < 0x3f10000000000000n) { /* 0x1p-14 */
|
|
42
|
+
/* subnormal f16 number or zero */
|
|
43
|
+
if (a <= P2_M25) { /* 0x1p-25 */
|
|
44
|
+
v = 0x0000; /* zero */
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
const shift = 1051n - (a >> 52n);
|
|
48
|
+
a = (1n << 52n) | (a & ((1n << 52n) - 1n));
|
|
49
|
+
const addend = ((a >> shift) & 1n) + ((1n << (shift - 1n)) - 1n);
|
|
50
|
+
v = Number((a + addend) >> shift);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
/* normal number or infinity */
|
|
55
|
+
a -= 0x3f00000000000000n; /* adjust the exponent */
|
|
56
|
+
/* round */
|
|
57
|
+
const addend = ((a >> 42n) & 1n) + ((1n << 41n) - 1n);
|
|
58
|
+
v = Number((a + addend) >> 42n);
|
|
59
|
+
/* overflow ? */
|
|
60
|
+
if (v > 0x7c00)
|
|
61
|
+
v = 0x7c00;
|
|
62
|
+
}
|
|
63
|
+
return v | (sgn << 15);
|
|
64
|
+
}
|
|
65
|
+
/* Math.f16round */
|
|
66
|
+
export function f16round(a) {
|
|
67
|
+
return fromfp16(tofp16(a));
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=float16.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"float16.js","sourceRoot":"","sources":["../../src/builtins/float16.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;2EAE2E;AAC3E,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC;AAEpC,MAAM,GAAG,GAAG,IAAI,YAAY,CAAC,CAAC,CAAC,CAAC;AAChC,MAAM,GAAG,GAAG,IAAI,cAAc,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;AAE3C,SAAS,iBAAiB,CAAC,CAAS;IAClC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACX,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC;AAChB,CAAC;AAED,SAAS,iBAAiB,CAAC,CAAS;IAClC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACX,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC;AAChB,CAAC;AAED,6BAA6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AAC,KAAK,GAAG,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC;YACjE,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,IAAI,KAAK,CAAC,CAAC;QACpC,CAAC;IACH,CAAC;SAAM,CAAC;QACN,+BAA+B;QAC/B,CAAC,IAAI,mBAAmB,CAAC,CAAC,yBAAyB;QACnD,WAAW;QACX,MAAM,MAAM,GAAG,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC;QACtD,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,IAAI,GAAG,CAAC,CAAC;QAChC,gBAAgB;QAChB,IAAI,CAAC,GAAG,MAAM;YAAE,CAAC,GAAG,MAAM,CAAC;IAC7B,CAAC;IACD,OAAO,CAAC,GAAG,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC;AACzB,CAAC;AAED,mBAAmB;AACnB,MAAM,UAAU,QAAQ,CAAC,CAAS;IAChC,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;AAC7B,CAAC","sourcesContent":["/*\n * IEEE 754 binary16 conversions (port of tofp16 / fromfp16 in cutils.h).\n *\n * They are implemented here rather than borrowed from the host so that\n * Math.f16round and DataView.prototype.getFloat16 / setFloat16 behave the\n * same on every host, including hosts without Float16Array. The bit\n * patterns are QuickJS's: a NaN is stored as 0x7c01 with its sign.\n */\n\n/* the bits of 0x1p-25. Written without a hex bigint literal containing the\n digit 'e' (0x3e60000000000000n), which jseption's own lexer rejects, so\n that this file still parses with jseption (tests/strip-types.test.ts) */\nconst P2_M25 = BigInt(0x3e6) << 52n;\n\nconst f64 = new Float64Array(1);\nconst u64 = new BigUint64Array(f64.buffer);\n\nfunction float64_as_uint64(d: number): bigint {\n f64[0] = d;\n return u64[0];\n}\n\nfunction uint64_as_float64(v: bigint): number {\n u64[0] = v;\n return f64[0];\n}\n\n/* binary16 bits -> double */\nexport function fromfp16(v: number): number {\n let v1 = v & 0x7fff;\n if (v1 >= 0x7c00) v1 += 0x1f8000; /* NaN or infinity */\n const d = uint64_as_float64((BigInt(v >> 15) << 63n) | (BigInt(v1) << 42n));\n return d * 2 ** 1008;\n}\n\n/* double -> binary16 bits, rounding to nearest with ties to even */\nexport function tofp16(d: number): number {\n let a = float64_as_uint64(d);\n const sgn = Number(a >> 63n);\n a &= 0x7fffffffffffffffn;\n let v: number;\n if (a > 0x7ff0000000000000n) {\n /* nan */\n v = 0x7c01;\n } else if (a < 0x3f10000000000000n) { /* 0x1p-14 */\n /* subnormal f16 number or zero */\n if (a <= P2_M25) { /* 0x1p-25 */\n v = 0x0000; /* zero */\n } else {\n const shift = 1051n - (a >> 52n);\n a = (1n << 52n) | (a & ((1n << 52n) - 1n));\n const addend = ((a >> shift) & 1n) + ((1n << (shift - 1n)) - 1n);\n v = Number((a + addend) >> shift);\n }\n } else {\n /* normal number or infinity */\n a -= 0x3f00000000000000n; /* adjust the exponent */\n /* round */\n const addend = ((a >> 42n) & 1n) + ((1n << 41n) - 1n);\n v = Number((a + addend) >> 42n);\n /* overflow ? */\n if (v > 0x7c00) v = 0x7c00;\n }\n return v | (sgn << 15);\n}\n\n/* Math.f16round */\nexport function f16round(a: number): number {\n return fromfp16(tofp16(a));\n}\n"]}
|
|
@@ -54,10 +54,10 @@ export function js_function_constructor(ctx, new_target, argv, magic) {
|
|
|
54
54
|
class_id = 16 /* JSClassID.GENERATOR_FUNCTION */;
|
|
55
55
|
break;
|
|
56
56
|
case 2 /* JSFunctionKind.ASYNC */:
|
|
57
|
-
class_id =
|
|
57
|
+
class_id = 49 /* JSClassID.ASYNC_FUNCTION */;
|
|
58
58
|
break;
|
|
59
59
|
case 3 /* JSFunctionKind.ASYNC_GENERATOR */:
|
|
60
|
-
class_id =
|
|
60
|
+
class_id = 53 /* JSClassID.ASYNC_GENERATOR_FUNCTION */;
|
|
61
61
|
break;
|
|
62
62
|
default:
|
|
63
63
|
class_id = 13 /* JSClassID.BYTECODE_FUNCTION */;
|
package/dist/builtins/index.js
CHANGED
|
@@ -21,6 +21,7 @@ import { JS_AddIntrinsicProxy } from "./proxy.js";
|
|
|
21
21
|
import { JS_AddIntrinsicTypedArrays } from "./typedarray.js";
|
|
22
22
|
import { JS_AddIntrinsicGlobal } from "./global.js";
|
|
23
23
|
import { JS_AddIntrinsicWeakRef } from "./weakref.js";
|
|
24
|
+
import { JS_AddIntrinsicIterator } from "./iterator.js";
|
|
24
25
|
/* %IteratorPrototype%[Symbol.iterator]() and %AsyncIteratorPrototype%[Symbol.asyncIterator]() */
|
|
25
26
|
function js_iterator_proto_iterator(ctx, this_val, argv) {
|
|
26
27
|
return this_val;
|
|
@@ -63,7 +64,7 @@ export function JS_AddIntrinsicBasicObjects(ctx) {
|
|
|
63
64
|
JS_DefinePropertyValue(ctx, ctx.async_iterator_proto, JS_ATOM_Symbol_asyncIterator, aiter_fn, JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE);
|
|
64
65
|
/* Array iterator */
|
|
65
66
|
ctx.array_iterator_proto = JS_NewObjectProto(ctx, ctx.iterator_proto);
|
|
66
|
-
ctx.class_proto[
|
|
67
|
+
ctx.class_proto[41 /* JSClassID.ARRAY_ITERATOR */] = ctx.array_iterator_proto;
|
|
67
68
|
JS_SetPropertyFunctionList(ctx, ctx.array_iterator_proto, js_array_iterator_proto_funcs);
|
|
68
69
|
}
|
|
69
70
|
export function JS_AddIntrinsicBaseObjects(ctx) {
|
|
@@ -72,6 +73,8 @@ export function JS_AddIntrinsicBaseObjects(ctx) {
|
|
|
72
73
|
JS_DefinePropertyValueStr(ctx, ctx.global_obj, 'globalThis', ctx.global_obj, JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE);
|
|
73
74
|
JS_AddIntrinsicObject(ctx);
|
|
74
75
|
JS_AddIntrinsicFunction(ctx);
|
|
76
|
+
/* Iterator (after Function, as in quickjs.c: its prototype is %IteratorPrototype%) */
|
|
77
|
+
JS_AddIntrinsicIterator(ctx);
|
|
75
78
|
JS_AddIntrinsicError(ctx);
|
|
76
79
|
JS_AddIntrinsicSymbol(ctx);
|
|
77
80
|
JS_AddIntrinsicArray(ctx);
|
|
@@ -102,7 +105,7 @@ export function JS_AddIntrinsicBaseObjects(ctx) {
|
|
|
102
105
|
}
|
|
103
106
|
/* Generator */
|
|
104
107
|
const gen_proto = JS_NewObjectProto(ctx, ctx.iterator_proto);
|
|
105
|
-
ctx.class_proto[
|
|
108
|
+
ctx.class_proto[44 /* JSClassID.GENERATOR */] = gen_proto;
|
|
106
109
|
ctx.generator_proto = gen_proto;
|
|
107
110
|
JS_SetPropertyFunctionList(ctx, gen_proto, js_generator_proto_funcs);
|
|
108
111
|
const gen_func_proto = JS_NewObjectProto(ctx, ctx.function_proto);
|
|
@@ -115,21 +118,21 @@ export function JS_AddIntrinsicBaseObjects(ctx) {
|
|
|
115
118
|
JS_AddIntrinsicPromise(ctx);
|
|
116
119
|
/* AsyncFunction */
|
|
117
120
|
const async_func_proto = JS_NewObjectProto(ctx, ctx.function_proto);
|
|
118
|
-
ctx.class_proto[
|
|
121
|
+
ctx.class_proto[49 /* JSClassID.ASYNC_FUNCTION */] = async_func_proto;
|
|
119
122
|
const async_ctor = JS_NewCFunctionMagic(ctx, js_function_constructor, 'AsyncFunction', 1, 5 /* JSCFunctionEnum.constructor_or_func_magic */, 2 /* JSFunctionKind.ASYNC */);
|
|
120
123
|
JS_SetPropertyFunctionList(ctx, async_func_proto, js_async_function_proto_funcs);
|
|
121
124
|
JS_SetConstructor2(ctx, async_ctor, async_func_proto, 0, JS_PROP_CONFIGURABLE);
|
|
122
125
|
/* AsyncIteratorPrototype / AsyncFromSyncIterator */
|
|
123
126
|
const afs_proto = JS_NewObjectProto(ctx, ctx.async_iterator_proto);
|
|
124
|
-
ctx.class_proto[
|
|
127
|
+
ctx.class_proto[52 /* JSClassID.ASYNC_FROM_SYNC_ITERATOR */] = afs_proto;
|
|
125
128
|
JS_SetPropertyFunctionList(ctx, afs_proto, js_async_from_sync_iterator_proto_funcs);
|
|
126
129
|
/* AsyncGenerator */
|
|
127
130
|
const agen_proto = JS_NewObjectProto(ctx, ctx.async_iterator_proto);
|
|
128
|
-
ctx.class_proto[
|
|
131
|
+
ctx.class_proto[54 /* JSClassID.ASYNC_GENERATOR */] = agen_proto;
|
|
129
132
|
ctx.async_generator_proto = agen_proto;
|
|
130
133
|
JS_SetPropertyFunctionList(ctx, agen_proto, js_async_generator_proto_funcs);
|
|
131
134
|
const agen_func_proto = JS_NewObjectProto(ctx, ctx.function_proto);
|
|
132
|
-
ctx.class_proto[
|
|
135
|
+
ctx.class_proto[53 /* JSClassID.ASYNC_GENERATOR_FUNCTION */] = agen_func_proto;
|
|
133
136
|
const agen_ctor = JS_NewCFunctionMagic(ctx, js_function_constructor, 'AsyncGeneratorFunction', 1, 5 /* JSCFunctionEnum.constructor_or_func_magic */, 3 /* JSFunctionKind.ASYNC_GENERATOR */);
|
|
134
137
|
JS_SetPropertyFunctionList(ctx, agen_func_proto, js_async_generator_function_proto_funcs);
|
|
135
138
|
JS_SetConstructor2(ctx, agen_func_proto, agen_proto, 0, JS_PROP_CONFIGURABLE);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/builtins/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAEL,iBAAiB,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,eAAe,EAAE,oBAAoB,EAClG,sBAAsB,EAAE,yBAAyB,EAAE,gBAAgB,EAAE,oBAAoB,EACzF,iBAAiB,EAAE,0BAA0B,EAAoC,aAAa,EAC9F,kBAAkB,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,uBAAuB,EACrF,4BAA4B,EAAE,0BAA0B,EAAgC,cAAc,EAC3C,WAAW,EAAE,cAAc,EAAE,iBAAiB,EACzG,qBAAqB,EAAE,KAAK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IAC9E,kBAAkB,CAAC,GAAG,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC,EAAE,oBAAoB,CAAC,CAAC;AAC/E,CAAC;AAED,KAAK,CAAC,0BAA0B,GAAG,0BAA0B,CAAC","sourcesContent":["/*\n * Intrinsic objects: port of JS_AddIntrinsicBasicObjects / JS_AddIntrinsicBaseObjects\n */\nimport * as Q from '../quickjs.ts';\nimport {\n JSContext, JSValue, JSObject, JSClassID, JSFunctionKind, JS_EXCEPTION, JS_IsException, JS_IsUndefined, JS_IsObject,\n JS_NewObjectProto, JS_NewObjectProtoClass, JS_NewCFunction3, JS_NewCFunction, JS_NewCFunctionMagic, JSCFunctionEnum,\n JS_DefinePropertyValue, JS_DefinePropertyValueStr, JS_PROP_WRITABLE, JS_PROP_CONFIGURABLE, JS_PROP_C_W_E,\n JS_ThrowTypeError, JS_SetPropertyFunctionList, JS_CFUNC_DEF, JS_CFUNC_MAGIC_DEF, JS_NATIVE_DEF,\n JS_PROP_STRING_DEF, JS_SetConstructor2, JS_PreventExtensions, JS_ATOM_Symbol_iterator,\n JS_ATOM_Symbol_asyncIterator, JS_ATOM_Symbol_toStringTag, JS_ATOM_length, JS_ATOM_name, JS_ATOM_values,\n JS_ATOM_Generator, JS_ATOM_prototype, JS_ATOM_constructor, JS_EvalThis, JS_GetProperty, JS_GetPropertyStr,\n JS_EVAL_TYPE_INDIRECT, hooks, JS_NewAtom, JS_ATOM_Symbol_hasInstance, JS_PROP_ENUMERABLE,\n} from '../quickjs.ts';\nimport {\n js_generator_proto_funcs, js_generator_function_proto_funcs, js_async_function_proto_funcs,\n js_async_generator_proto_funcs, js_async_generator_function_proto_funcs, js_async_from_sync_iterator_proto_funcs,\n} from '../interpreter.ts';\nimport { HOST_ARRAY_ITERATOR_PROTO, fix_iter_result_entries } from './native.ts';\nimport { JS_AddIntrinsicError } from './error.ts';\nimport { JS_AddIntrinsicSymbol } from './symbol.ts';\nimport { JS_AddIntrinsicFunction, js_function_proto, js_function_constructor, js_function_proto_caller } from './function.ts';\nimport { JS_AddIntrinsicPromise } from './promise.ts';\nimport { JS_AddIntrinsicObject } from './object.ts';\nimport { JS_AddIntrinsicArray } from './array.ts';\nimport { JS_AddIntrinsicNumber } from './number.ts';\nimport { JS_AddIntrinsicBoolean } from './boolean.ts';\nimport { JS_AddIntrinsicString } from './string.ts';\nimport { JS_AddIntrinsicMath } from './math.ts';\nimport { JS_AddIntrinsicJSON } from './json.ts';\nimport { JS_AddIntrinsicReflect } from './reflect.ts';\nimport { JS_AddIntrinsicMapSet } from './mapset.ts';\nimport { JS_AddIntrinsicRegExp } from './regexp.ts';\nimport { JS_AddIntrinsicDate } from './date.ts';\nimport { JS_AddIntrinsicBigInt } from './bigint.ts';\nimport { JS_AddIntrinsicProxy } from './proxy.ts';\nimport { JS_AddIntrinsicTypedArrays } from './typedarray.ts';\nimport { JS_AddIntrinsicGlobal } from './global.ts';\nimport { JS_AddIntrinsicWeakRef } from './weakref.ts';\n\n/* %IteratorPrototype%[Symbol.iterator]() and %AsyncIteratorPrototype%[Symbol.asyncIterator]() */\nfunction js_iterator_proto_iterator(ctx: JSContext, this_val: JSValue, argv: JSValue[]): JSValue {\n return this_val;\n}\n\n/* Array iterator: the host array iterators (created by the borrowed\n Array.prototype.values/keys/entries and the typed array equivalents) are\n re-prototyped to this prototype, whose `next` is the host one */\nconst js_array_iterator_proto_funcs = [\n JS_NATIVE_DEF('next', 0, (HOST_ARRAY_ITERATOR_PROTO as any).next, fix_iter_result_entries),\n JS_PROP_STRING_DEF(JS_ATOM_Symbol_toStringTag, 'Array Iterator', JS_PROP_CONFIGURABLE),\n];\n\nfunction js_throw_type_error(ctx: JSContext, this_val: JSValue, argv: JSValue[]): JSValue {\n return JS_ThrowTypeError(ctx, 'invalid property access');\n}\n\n/* indirect eval */\nfunction js_global_eval(ctx: JSContext, this_val: JSValue, argv: JSValue[]): JSValue {\n const val = argv[0];\n if (typeof val !== 'string') return val;\n return JS_EvalThis(ctx, ctx.global_obj, val, '<input>', JS_EVAL_TYPE_INDIRECT);\n}\n\nexport function JS_AddIntrinsicBasicObjects(ctx: JSContext): void {\n const proto = ctx.class_proto[JSClassID.OBJECT]!;\n /* Function.prototype is itself a (C) function */\n ctx.function_proto = JS_NewCFunction3(ctx, js_function_proto, '', 0, JSCFunctionEnum.generic, 0, proto) as JSObject;\n /* 'caller' and 'arguments' accessors throw in strict mode */\n ctx.throw_type_error = JS_NewCFunction(ctx, js_throw_type_error, '', 0) as JSObject;\n JS_PreventExtensions(ctx, ctx.throw_type_error);\n /* ArrayPrototype (needed early for JS_NewArray): an array exotic object */\n ctx.class_proto[JSClassID.ARRAY] = JS_NewObjectProtoClass(ctx, proto, JSClassID.ARRAY) as JSObject;\n /* XXX: could use a specific class for the arguments prototype */\n ctx.class_proto[JSClassID.ARGUMENTS] = ctx.class_proto[JSClassID.OBJECT];\n ctx.class_proto[JSClassID.MAPPED_ARGUMENTS] = ctx.class_proto[JSClassID.OBJECT];\n /* iterator prototypes */\n ctx.iterator_proto = JS_NewObjectProto(ctx, proto) as JSObject;\n const iter_fn = JS_NewCFunction3(ctx, js_iterator_proto_iterator, '[Symbol.iterator]', 0, JSCFunctionEnum.generic, 0, ctx.function_proto);\n JS_DefinePropertyValue(ctx, ctx.iterator_proto, JS_ATOM_Symbol_iterator, iter_fn, JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE);\n ctx.async_iterator_proto = JS_NewObjectProto(ctx, proto) as JSObject;\n const aiter_fn = JS_NewCFunction3(ctx, js_iterator_proto_iterator, '[Symbol.asyncIterator]', 0, JSCFunctionEnum.generic, 0, ctx.function_proto);\n JS_DefinePropertyValue(ctx, ctx.async_iterator_proto, JS_ATOM_Symbol_asyncIterator, aiter_fn, JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE);\n /* Array iterator */\n ctx.array_iterator_proto = JS_NewObjectProto(ctx, ctx.iterator_proto) as JSObject;\n ctx.class_proto[JSClassID.ARRAY_ITERATOR] = ctx.array_iterator_proto;\n JS_SetPropertyFunctionList(ctx, ctx.array_iterator_proto, js_array_iterator_proto_funcs);\n}\n\nexport function JS_AddIntrinsicBaseObjects(ctx: JSContext): void {\n JS_AddIntrinsicBasicObjects(ctx);\n\n /* global object: globalThis */\n JS_DefinePropertyValueStr(ctx, ctx.global_obj, 'globalThis', ctx.global_obj, JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE);\n\n JS_AddIntrinsicObject(ctx);\n JS_AddIntrinsicFunction(ctx);\n JS_AddIntrinsicError(ctx);\n JS_AddIntrinsicSymbol(ctx);\n JS_AddIntrinsicArray(ctx);\n\n /* Array.prototype.values (=== Array.prototype[Symbol.iterator]) */\n ctx.array_proto_values = JS_GetProperty(ctx, ctx.class_proto[JSClassID.ARRAY]!, JS_ATOM_values);\n\n JS_AddIntrinsicNumber(ctx);\n JS_AddIntrinsicBoolean(ctx);\n JS_AddIntrinsicString(ctx);\n JS_AddIntrinsicMath(ctx);\n JS_AddIntrinsicJSON(ctx);\n JS_AddIntrinsicReflect(ctx);\n JS_AddIntrinsicMapSet(ctx);\n JS_AddIntrinsicRegExp(ctx);\n JS_AddIntrinsicDate(ctx);\n JS_AddIntrinsicBigInt(ctx);\n JS_AddIntrinsicProxy(ctx);\n JS_AddIntrinsicTypedArrays(ctx);\n JS_AddIntrinsicWeakRef(ctx);\n\n /* eval */\n const eval_obj = JS_NewCFunction(ctx, js_global_eval, 'eval', 1);\n JS_DefinePropertyValueStr(ctx, ctx.global_obj, 'eval', eval_obj, JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE);\n ctx.eval_obj = eval_obj;\n\n JS_AddIntrinsicGlobal(ctx);\n /* Number.parseInt / Number.parseFloat are the global functions */\n const number_ctor = JS_GetPropertyStr(ctx, ctx.global_obj, 'Number');\n for (const name of ['parseInt', 'parseFloat']) {\n JS_DefinePropertyValueStr(ctx, number_ctor, name, JS_GetPropertyStr(ctx, ctx.global_obj, name), JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE);\n }\n\n /* Generator */\n const gen_proto = JS_NewObjectProto(ctx, ctx.iterator_proto) as JSObject;\n ctx.class_proto[JSClassID.GENERATOR] = gen_proto;\n ctx.generator_proto = gen_proto;\n JS_SetPropertyFunctionList(ctx, gen_proto, js_generator_proto_funcs);\n const gen_func_proto = JS_NewObjectProto(ctx, ctx.function_proto) as JSObject;\n ctx.class_proto[JSClassID.GENERATOR_FUNCTION] = gen_func_proto;\n const gen_ctor = JS_NewCFunctionMagic(ctx, js_function_constructor, 'GeneratorFunction', 1, JSCFunctionEnum.constructor_or_func_magic, JSFunctionKind.GENERATOR);\n JS_SetPropertyFunctionList(ctx, gen_func_proto, js_generator_function_proto_funcs);\n JS_SetConstructor2(ctx, gen_func_proto, gen_proto, 0, JS_PROP_CONFIGURABLE);\n JS_SetConstructor2(ctx, gen_ctor, gen_func_proto, 0, JS_PROP_CONFIGURABLE);\n\n /* Promise */\n JS_AddIntrinsicPromise(ctx);\n\n /* AsyncFunction */\n const async_func_proto = JS_NewObjectProto(ctx, ctx.function_proto) as JSObject;\n ctx.class_proto[JSClassID.ASYNC_FUNCTION] = async_func_proto;\n const async_ctor = JS_NewCFunctionMagic(ctx, js_function_constructor, 'AsyncFunction', 1, JSCFunctionEnum.constructor_or_func_magic, JSFunctionKind.ASYNC);\n JS_SetPropertyFunctionList(ctx, async_func_proto, js_async_function_proto_funcs);\n JS_SetConstructor2(ctx, async_ctor, async_func_proto, 0, JS_PROP_CONFIGURABLE);\n\n /* AsyncIteratorPrototype / AsyncFromSyncIterator */\n const afs_proto = JS_NewObjectProto(ctx, ctx.async_iterator_proto) as JSObject;\n ctx.class_proto[JSClassID.ASYNC_FROM_SYNC_ITERATOR] = afs_proto;\n JS_SetPropertyFunctionList(ctx, afs_proto, js_async_from_sync_iterator_proto_funcs);\n\n /* AsyncGenerator */\n const agen_proto = JS_NewObjectProto(ctx, ctx.async_iterator_proto) as JSObject;\n ctx.class_proto[JSClassID.ASYNC_GENERATOR] = agen_proto;\n ctx.async_generator_proto = agen_proto;\n JS_SetPropertyFunctionList(ctx, agen_proto, js_async_generator_proto_funcs);\n const agen_func_proto = JS_NewObjectProto(ctx, ctx.function_proto) as JSObject;\n ctx.class_proto[JSClassID.ASYNC_GENERATOR_FUNCTION] = agen_func_proto;\n const agen_ctor = JS_NewCFunctionMagic(ctx, js_function_constructor, 'AsyncGeneratorFunction', 1, JSCFunctionEnum.constructor_or_func_magic, JSFunctionKind.ASYNC_GENERATOR);\n JS_SetPropertyFunctionList(ctx, agen_func_proto, js_async_generator_function_proto_funcs);\n JS_SetConstructor2(ctx, agen_func_proto, agen_proto, 0, JS_PROP_CONFIGURABLE);\n JS_SetConstructor2(ctx, agen_ctor, agen_func_proto, 0, JS_PROP_CONFIGURABLE);\n}\n\nhooks.JS_AddIntrinsicBaseObjects = JS_AddIntrinsicBaseObjects;\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/builtins/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAEL,iBAAiB,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,eAAe,EAAE,oBAAoB,EAClG,sBAAsB,EAAE,yBAAyB,EAAE,gBAAgB,EAAE,oBAAoB,EACzF,iBAAiB,EAAE,0BAA0B,EAAoC,aAAa,EAC9F,kBAAkB,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,uBAAuB,EACrF,4BAA4B,EAAE,0BAA0B,EAAgC,cAAc,EAC3C,WAAW,EAAE,cAAc,EAAE,iBAAiB,EACzG,qBAAqB,EAAE,KAAK,GAC7B,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,wBAAwB,EAAE,iCAAiC,EAAE,6BAA6B,EAC1F,8BAA8B,EAAE,uCAAuC,EAAE,uCAAuC,GACjH,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,yBAAyB,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AACjF,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,EAAE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AddIntrinsicBasicObjects / JS_AddIntrinsicBaseObjects\n */\nimport * as Q from '../quickjs.ts';\nimport {\n JSContext, JSValue, JSObject, JSClassID, JSFunctionKind, JS_EXCEPTION, JS_IsException, JS_IsUndefined, JS_IsObject,\n JS_NewObjectProto, JS_NewObjectProtoClass, JS_NewCFunction3, JS_NewCFunction, JS_NewCFunctionMagic, JSCFunctionEnum,\n JS_DefinePropertyValue, JS_DefinePropertyValueStr, JS_PROP_WRITABLE, JS_PROP_CONFIGURABLE, JS_PROP_C_W_E,\n JS_ThrowTypeError, JS_SetPropertyFunctionList, JS_CFUNC_DEF, JS_CFUNC_MAGIC_DEF, JS_NATIVE_DEF,\n JS_PROP_STRING_DEF, JS_SetConstructor2, JS_PreventExtensions, JS_ATOM_Symbol_iterator,\n JS_ATOM_Symbol_asyncIterator, JS_ATOM_Symbol_toStringTag, JS_ATOM_length, JS_ATOM_name, JS_ATOM_values,\n JS_ATOM_Generator, JS_ATOM_prototype, JS_ATOM_constructor, JS_EvalThis, JS_GetProperty, JS_GetPropertyStr,\n JS_EVAL_TYPE_INDIRECT, hooks, JS_NewAtom, JS_ATOM_Symbol_hasInstance, JS_PROP_ENUMERABLE,\n} from '../quickjs.ts';\nimport {\n js_generator_proto_funcs, js_generator_function_proto_funcs, js_async_function_proto_funcs,\n js_async_generator_proto_funcs, js_async_generator_function_proto_funcs, js_async_from_sync_iterator_proto_funcs,\n} from '../interpreter.ts';\nimport { HOST_ARRAY_ITERATOR_PROTO, fix_iter_result_entries } from './native.ts';\nimport { JS_AddIntrinsicError } from './error.ts';\nimport { JS_AddIntrinsicSymbol } from './symbol.ts';\nimport { JS_AddIntrinsicFunction, js_function_proto, js_function_constructor, js_function_proto_caller } from './function.ts';\nimport { JS_AddIntrinsicPromise } from './promise.ts';\nimport { JS_AddIntrinsicObject } from './object.ts';\nimport { JS_AddIntrinsicArray } from './array.ts';\nimport { JS_AddIntrinsicNumber } from './number.ts';\nimport { JS_AddIntrinsicBoolean } from './boolean.ts';\nimport { JS_AddIntrinsicString } from './string.ts';\nimport { JS_AddIntrinsicMath } from './math.ts';\nimport { JS_AddIntrinsicJSON } from './json.ts';\nimport { JS_AddIntrinsicReflect } from './reflect.ts';\nimport { JS_AddIntrinsicMapSet } from './mapset.ts';\nimport { JS_AddIntrinsicRegExp } from './regexp.ts';\nimport { JS_AddIntrinsicDate } from './date.ts';\nimport { JS_AddIntrinsicBigInt } from './bigint.ts';\nimport { JS_AddIntrinsicProxy } from './proxy.ts';\nimport { JS_AddIntrinsicTypedArrays } from './typedarray.ts';\nimport { JS_AddIntrinsicGlobal } from './global.ts';\nimport { JS_AddIntrinsicWeakRef } from './weakref.ts';\nimport { JS_AddIntrinsicIterator } from './iterator.ts';\n\n/* %IteratorPrototype%[Symbol.iterator]() and %AsyncIteratorPrototype%[Symbol.asyncIterator]() */\nfunction js_iterator_proto_iterator(ctx: JSContext, this_val: JSValue, argv: JSValue[]): JSValue {\n return this_val;\n}\n\n/* Array iterator: the host array iterators (created by the borrowed\n Array.prototype.values/keys/entries and the typed array equivalents) are\n re-prototyped to this prototype, whose `next` is the host one */\nconst js_array_iterator_proto_funcs = [\n JS_NATIVE_DEF('next', 0, (HOST_ARRAY_ITERATOR_PROTO as any).next, fix_iter_result_entries),\n JS_PROP_STRING_DEF(JS_ATOM_Symbol_toStringTag, 'Array Iterator', JS_PROP_CONFIGURABLE),\n];\n\nfunction js_throw_type_error(ctx: JSContext, this_val: JSValue, argv: JSValue[]): JSValue {\n return JS_ThrowTypeError(ctx, 'invalid property access');\n}\n\n/* indirect eval */\nfunction js_global_eval(ctx: JSContext, this_val: JSValue, argv: JSValue[]): JSValue {\n const val = argv[0];\n if (typeof val !== 'string') return val;\n return JS_EvalThis(ctx, ctx.global_obj, val, '<input>', JS_EVAL_TYPE_INDIRECT);\n}\n\nexport function JS_AddIntrinsicBasicObjects(ctx: JSContext): void {\n const proto = ctx.class_proto[JSClassID.OBJECT]!;\n /* Function.prototype is itself a (C) function */\n ctx.function_proto = JS_NewCFunction3(ctx, js_function_proto, '', 0, JSCFunctionEnum.generic, 0, proto) as JSObject;\n /* 'caller' and 'arguments' accessors throw in strict mode */\n ctx.throw_type_error = JS_NewCFunction(ctx, js_throw_type_error, '', 0) as JSObject;\n JS_PreventExtensions(ctx, ctx.throw_type_error);\n /* ArrayPrototype (needed early for JS_NewArray): an array exotic object */\n ctx.class_proto[JSClassID.ARRAY] = JS_NewObjectProtoClass(ctx, proto, JSClassID.ARRAY) as JSObject;\n /* XXX: could use a specific class for the arguments prototype */\n ctx.class_proto[JSClassID.ARGUMENTS] = ctx.class_proto[JSClassID.OBJECT];\n ctx.class_proto[JSClassID.MAPPED_ARGUMENTS] = ctx.class_proto[JSClassID.OBJECT];\n /* iterator prototypes */\n ctx.iterator_proto = JS_NewObjectProto(ctx, proto) as JSObject;\n const iter_fn = JS_NewCFunction3(ctx, js_iterator_proto_iterator, '[Symbol.iterator]', 0, JSCFunctionEnum.generic, 0, ctx.function_proto);\n JS_DefinePropertyValue(ctx, ctx.iterator_proto, JS_ATOM_Symbol_iterator, iter_fn, JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE);\n ctx.async_iterator_proto = JS_NewObjectProto(ctx, proto) as JSObject;\n const aiter_fn = JS_NewCFunction3(ctx, js_iterator_proto_iterator, '[Symbol.asyncIterator]', 0, JSCFunctionEnum.generic, 0, ctx.function_proto);\n JS_DefinePropertyValue(ctx, ctx.async_iterator_proto, JS_ATOM_Symbol_asyncIterator, aiter_fn, JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE);\n /* Array iterator */\n ctx.array_iterator_proto = JS_NewObjectProto(ctx, ctx.iterator_proto) as JSObject;\n ctx.class_proto[JSClassID.ARRAY_ITERATOR] = ctx.array_iterator_proto;\n JS_SetPropertyFunctionList(ctx, ctx.array_iterator_proto, js_array_iterator_proto_funcs);\n}\n\nexport function JS_AddIntrinsicBaseObjects(ctx: JSContext): void {\n JS_AddIntrinsicBasicObjects(ctx);\n\n /* global object: globalThis */\n JS_DefinePropertyValueStr(ctx, ctx.global_obj, 'globalThis', ctx.global_obj, JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE);\n\n JS_AddIntrinsicObject(ctx);\n JS_AddIntrinsicFunction(ctx);\n /* Iterator (after Function, as in quickjs.c: its prototype is %IteratorPrototype%) */\n JS_AddIntrinsicIterator(ctx);\n JS_AddIntrinsicError(ctx);\n JS_AddIntrinsicSymbol(ctx);\n JS_AddIntrinsicArray(ctx);\n\n /* Array.prototype.values (=== Array.prototype[Symbol.iterator]) */\n ctx.array_proto_values = JS_GetProperty(ctx, ctx.class_proto[JSClassID.ARRAY]!, JS_ATOM_values);\n\n JS_AddIntrinsicNumber(ctx);\n JS_AddIntrinsicBoolean(ctx);\n JS_AddIntrinsicString(ctx);\n JS_AddIntrinsicMath(ctx);\n JS_AddIntrinsicJSON(ctx);\n JS_AddIntrinsicReflect(ctx);\n JS_AddIntrinsicMapSet(ctx);\n JS_AddIntrinsicRegExp(ctx);\n JS_AddIntrinsicDate(ctx);\n JS_AddIntrinsicBigInt(ctx);\n JS_AddIntrinsicProxy(ctx);\n JS_AddIntrinsicTypedArrays(ctx);\n JS_AddIntrinsicWeakRef(ctx);\n\n /* eval */\n const eval_obj = JS_NewCFunction(ctx, js_global_eval, 'eval', 1);\n JS_DefinePropertyValueStr(ctx, ctx.global_obj, 'eval', eval_obj, JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE);\n ctx.eval_obj = eval_obj;\n\n JS_AddIntrinsicGlobal(ctx);\n /* Number.parseInt / Number.parseFloat are the global functions */\n const number_ctor = JS_GetPropertyStr(ctx, ctx.global_obj, 'Number');\n for (const name of ['parseInt', 'parseFloat']) {\n JS_DefinePropertyValueStr(ctx, number_ctor, name, JS_GetPropertyStr(ctx, ctx.global_obj, name), JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE);\n }\n\n /* Generator */\n const gen_proto = JS_NewObjectProto(ctx, ctx.iterator_proto) as JSObject;\n ctx.class_proto[JSClassID.GENERATOR] = gen_proto;\n ctx.generator_proto = gen_proto;\n JS_SetPropertyFunctionList(ctx, gen_proto, js_generator_proto_funcs);\n const gen_func_proto = JS_NewObjectProto(ctx, ctx.function_proto) as JSObject;\n ctx.class_proto[JSClassID.GENERATOR_FUNCTION] = gen_func_proto;\n const gen_ctor = JS_NewCFunctionMagic(ctx, js_function_constructor, 'GeneratorFunction', 1, JSCFunctionEnum.constructor_or_func_magic, JSFunctionKind.GENERATOR);\n JS_SetPropertyFunctionList(ctx, gen_func_proto, js_generator_function_proto_funcs);\n JS_SetConstructor2(ctx, gen_func_proto, gen_proto, 0, JS_PROP_CONFIGURABLE);\n JS_SetConstructor2(ctx, gen_ctor, gen_func_proto, 0, JS_PROP_CONFIGURABLE);\n\n /* Promise */\n JS_AddIntrinsicPromise(ctx);\n\n /* AsyncFunction */\n const async_func_proto = JS_NewObjectProto(ctx, ctx.function_proto) as JSObject;\n ctx.class_proto[JSClassID.ASYNC_FUNCTION] = async_func_proto;\n const async_ctor = JS_NewCFunctionMagic(ctx, js_function_constructor, 'AsyncFunction', 1, JSCFunctionEnum.constructor_or_func_magic, JSFunctionKind.ASYNC);\n JS_SetPropertyFunctionList(ctx, async_func_proto, js_async_function_proto_funcs);\n JS_SetConstructor2(ctx, async_ctor, async_func_proto, 0, JS_PROP_CONFIGURABLE);\n\n /* AsyncIteratorPrototype / AsyncFromSyncIterator */\n const afs_proto = JS_NewObjectProto(ctx, ctx.async_iterator_proto) as JSObject;\n ctx.class_proto[JSClassID.ASYNC_FROM_SYNC_ITERATOR] = afs_proto;\n JS_SetPropertyFunctionList(ctx, afs_proto, js_async_from_sync_iterator_proto_funcs);\n\n /* AsyncGenerator */\n const agen_proto = JS_NewObjectProto(ctx, ctx.async_iterator_proto) as JSObject;\n ctx.class_proto[JSClassID.ASYNC_GENERATOR] = agen_proto;\n ctx.async_generator_proto = agen_proto;\n JS_SetPropertyFunctionList(ctx, agen_proto, js_async_generator_proto_funcs);\n const agen_func_proto = JS_NewObjectProto(ctx, ctx.function_proto) as JSObject;\n ctx.class_proto[JSClassID.ASYNC_GENERATOR_FUNCTION] = agen_func_proto;\n const agen_ctor = JS_NewCFunctionMagic(ctx, js_function_constructor, 'AsyncGeneratorFunction', 1, JSCFunctionEnum.constructor_or_func_magic, JSFunctionKind.ASYNC_GENERATOR);\n JS_SetPropertyFunctionList(ctx, agen_func_proto, js_async_generator_function_proto_funcs);\n JS_SetConstructor2(ctx, agen_func_proto, agen_proto, 0, JS_PROP_CONFIGURABLE);\n JS_SetConstructor2(ctx, agen_ctor, agen_func_proto, 0, JS_PROP_CONFIGURABLE);\n}\n\nhooks.JS_AddIntrinsicBaseObjects = JS_AddIntrinsicBaseObjects;\n"]}
|