jseption 0.0.5 → 0.0.6
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 +25 -4
- 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 +1 -0
- package/dist/builtins/typedarray.js +302 -32
- package/dist/builtins/typedarray.js.map +1 -1
- package/dist/builtins/weakref.js +7 -7
- package/dist/embed.js +3 -3
- 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.js +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
package/dist/std.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { JSContext } from './quickjs.ts';
|
|
1
|
+
import { JSContext, JSValue } from './quickjs.ts';
|
|
2
2
|
import type { JSModuleLoader } from './module.ts';
|
|
3
3
|
export declare function js_std_add_helpers(ctx: JSContext, args: string[]): void;
|
|
4
|
+
export declare function js_std_dump_error1(ctx: JSContext, exception_val: JSValue): void;
|
|
4
5
|
export declare function js_std_dump_error(ctx: JSContext): void;
|
|
5
|
-
export declare function
|
|
6
|
+
export declare function js_std_promise_rejection_tracker(ctx: JSContext, promise: JSValue, reason: JSValue, is_handled: boolean): void;
|
|
7
|
+
export declare function js_std_loop(ctx: JSContext, ignore_rejections?: readonly JSValue[]): Promise<void>;
|
|
6
8
|
export declare function js_std_module_loader(): JSModuleLoader;
|
package/dist/std.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* of quickjs-libc.c (print, console, scriptArgs, std.*, os.*).
|
|
4
4
|
*/
|
|
5
5
|
import { JS_IsException, JS_ToString, JS_GetException, JS_NewObject, JS_NewCFunction, JS_DefinePropertyValueStr, JS_PROP_WRITABLE, JS_PROP_CONFIGURABLE, JS_NewArrayFrom, JS_SetPropertyFunctionList, JS_CFUNC_DEF, JS_CFUNC_MAGIC_DEF, JS_Call, JS_ThrowTypeError, JS_Eval, JS_EVAL_TYPE_GLOBAL, JS_ToFloat64, JS_IsFunction, JS_ExecutePendingJob, JS_NewObjectProto, JS_EXCEPTION, JS_GetAnyOpaque, JS_SetOpaque, } from "./quickjs.js";
|
|
6
|
-
import {
|
|
6
|
+
import { JS_PrintValue, JS_PrintValueToString } from "./print.js";
|
|
7
7
|
import { js_module_type_of } from "./module.js";
|
|
8
8
|
import { readFileSync, writeFileSync } from 'node:fs';
|
|
9
9
|
import { resolve as path_resolve, dirname as path_dirname } from 'node:path';
|
|
@@ -15,15 +15,18 @@ function write_out(fd, s) {
|
|
|
15
15
|
else
|
|
16
16
|
process.stdout.write(s);
|
|
17
17
|
}
|
|
18
|
+
/* print() and console.log(): strings are written as they are, other values
|
|
19
|
+
with JS_PrintValue (QuickJS be06b3e) */
|
|
18
20
|
function js_print_internal(ctx, argv, fd) {
|
|
19
21
|
let out = '';
|
|
20
22
|
for (let i = 0; i < argv.length; i++) {
|
|
21
23
|
if (i !== 0)
|
|
22
24
|
out += ' ';
|
|
23
|
-
const
|
|
24
|
-
if (
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
const v = argv[i];
|
|
26
|
+
if (typeof v === 'string')
|
|
27
|
+
out += v;
|
|
28
|
+
else
|
|
29
|
+
JS_PrintValue(ctx, (_o, buf) => { out += buf; }, null, v, null);
|
|
27
30
|
}
|
|
28
31
|
write_out(fd, out + '\n');
|
|
29
32
|
return undefined;
|
|
@@ -241,12 +244,41 @@ export function js_std_add_helpers(ctx, args) {
|
|
|
241
244
|
JS_DefinePropertyValueStr(ctx, os, 'platform', process.platform, JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE);
|
|
242
245
|
JS_DefinePropertyValueStr(ctx, global, 'os', os, JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE);
|
|
243
246
|
}
|
|
247
|
+
export function js_std_dump_error1(ctx, exception_val) {
|
|
248
|
+
process.stderr.write(JS_PrintValueToString(ctx, exception_val) + '\n');
|
|
249
|
+
}
|
|
244
250
|
export function js_std_dump_error(ctx) {
|
|
245
|
-
|
|
246
|
-
|
|
251
|
+
js_std_dump_error1(ctx, JS_GetException(ctx));
|
|
252
|
+
}
|
|
253
|
+
/* Promise rejection tracker (QuickJS 3c39307): the unhandled rejections are
|
|
254
|
+
recorded, a rejection handled later is removed, and the remaining ones
|
|
255
|
+
are reported when the event loop is about to sleep or ends */
|
|
256
|
+
const rejected_promises = new Map();
|
|
257
|
+
export function js_std_promise_rejection_tracker(ctx, promise, reason, is_handled) {
|
|
258
|
+
if (!is_handled) {
|
|
259
|
+
if (!rejected_promises.has(promise))
|
|
260
|
+
rejected_promises.set(promise, reason);
|
|
261
|
+
}
|
|
262
|
+
else {
|
|
263
|
+
rejected_promises.delete(promise);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
/* report the pending unhandled rejections and exit (the promises in 'ignore'
|
|
267
|
+
are reported by the caller) */
|
|
268
|
+
function js_std_promise_rejection_check(ctx, ignore) {
|
|
269
|
+
let n = 0;
|
|
270
|
+
for (const [promise, reason] of rejected_promises) {
|
|
271
|
+
if (ignore.includes(promise))
|
|
272
|
+
continue;
|
|
273
|
+
process.stderr.write('Possibly unhandled promise rejection: ');
|
|
274
|
+
js_std_dump_error1(ctx, reason);
|
|
275
|
+
n++;
|
|
276
|
+
}
|
|
277
|
+
if (n > 0)
|
|
278
|
+
process.exit(1);
|
|
247
279
|
}
|
|
248
280
|
/* main loop: run pending jobs and timers until none is left */
|
|
249
|
-
export async function js_std_loop(ctx) {
|
|
281
|
+
export async function js_std_loop(ctx, ignore_rejections = []) {
|
|
250
282
|
const rt = ctx.rt;
|
|
251
283
|
for (;;) {
|
|
252
284
|
/* execute the pending jobs */
|
|
@@ -259,6 +291,8 @@ export async function js_std_loop(ctx) {
|
|
|
259
291
|
break;
|
|
260
292
|
}
|
|
261
293
|
}
|
|
294
|
+
if (rt.host_promise_rejection_tracker !== null)
|
|
295
|
+
js_std_promise_rejection_check(ctx, ignore_rejections);
|
|
262
296
|
if (os_timers.length === 0)
|
|
263
297
|
break;
|
|
264
298
|
/* run the earliest timer */
|
package/dist/std.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"std.js","sourceRoot":"","sources":["../src/std.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EACe,cAAc,EAAE,WAAW,EAAE,eAAe,EAAE,YAAY,EAAE,eAAe,EAC9E,yBAAyB,EAAiB,gBAAgB,EAAE,oBAAoB,EAAE,eAAe,EAClH,0BAA0B,EAAE,YAAY,EAAE,kBAAkB,EAAE,OAAO,EAAE,iBAAiB,EACxF,OAAO,EAAE,mBAAmB,EAAiC,YAAY,EAAE,aAAa,EACxF,oBAAoB,EAA8C,iBAAiB,EAAE,YAAY,EAAE,eAAe,EAClH,YAAY,GACb,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACtD,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,O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AAE,OAAO,YAAY,CAAC,SAAS,CAAC,CAAC;YAC9D,IAAI,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,SAAS,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC9D,MAAM,IAAI,GAAG,QAAQ,KAAK,IAAI,CAAC,CAAC,CAAC,YAAY,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC;gBAC7F,OAAO,YAAY,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,SAAS,CAAC,CAAC;YACrD,CAAC;YACD,MAAM,IAAI,SAAS,CAAC,mBAAmB,SAAS,mDAAmD,CAAC,CAAC;QACvG,CAAC;QACD,IAAI,CAAC,EAAE,EAAE,UAAU;YACjB,IAAI,MAAc,CAAC;YACnB,IAAI,CAAC;gBACH,MAAM,GAAG,YAAY,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;YACpC,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACX,MAAM,IAAI,SAAS,CAAC,uBAAuB,EAAE,MAAO,CAA2B,CAAC,IAAI,IAAK,CAAW,CAAC,OAAO,EAAE,CAAC,CAAC;YAClH,CAAC;YACD,MAAM,IAAI,GAAG,UAAU,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAC;YACzE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,aAAa,CAAC,EAAE,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC;QACvD,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["/*\n * Minimal host bindings for the command line interpreter: port of a subset\n * of quickjs-libc.c (print, console, scriptArgs, std.*, os.*).\n */\nimport {\n JSContext, JSValue, JS_IsException, JS_ToString, JS_GetException, JS_NewObject, JS_NewCFunction, JS_NewCFunctionMagic,\n JSCFunctionEnum, JS_DefinePropertyValueStr, JS_PROP_C_W_E, JS_PROP_WRITABLE, JS_PROP_CONFIGURABLE, JS_NewArrayFrom,\n JS_SetPropertyFunctionList, JS_CFUNC_DEF, JS_CFUNC_MAGIC_DEF, JS_Call, JS_ThrowTypeError, JS_ThrowReferenceError,\n JS_Eval, JS_EVAL_TYPE_GLOBAL, JS_IsError, JS_GetPropertyStr, JS_ToFloat64, JS_IsFunction, JS_NewError,\n JS_ExecutePendingJob, JS_IsJobPending, JSRuntime, JS_IsUndefined, JS_NewObjectProto, JS_EXCEPTION, JS_GetAnyOpaque,\n JS_SetOpaque,\n} from './quickjs.ts';\nimport { formatException } from './jseption.ts';\nimport type { JSModuleLoader } from './module.ts';\nimport { js_module_type_of } from './module.ts';\nimport { readFileSync, writeFileSync } from 'node:fs';\nimport { resolve as path_resolve, dirname as path_dirname } from 'node:path';\nimport { pathToFileURL, fileURLToPath } from 'node:url';\n\nconst enc = new TextEncoder();\n\nfunction write_out(fd: number, s: string): void {\n if (fd === 2) process.stderr.write(s); else process.stdout.write(s);\n}\n\nfunction js_print_internal(ctx: JSContext, argv: JSValue[], fd: number): JSValue {\n let out = '';\n for (let i = 0; i < argv.length; i++) {\n if (i !== 0) out += ' ';\n const str = JS_ToString(ctx, argv[i]);\n if (JS_IsException(str)) return str;\n out += str as string;\n }\n write_out(fd, out + '\\n');\n return undefined;\n}\n\nfunction js_print(ctx: JSContext, this_val: JSValue, argv: JSValue[]): JSValue {\n return js_print_internal(ctx, argv, 1);\n}\n\nfunction js_console_log(ctx: JSContext, this_val: JSValue, argv: JSValue[], magic: number): JSValue {\n return js_print_internal(ctx, argv, magic);\n}\n\n/* std.evalScript(str) */\nfunction js_std_evalScript(ctx: JSContext, this_val: JSValue, argv: JSValue[]): JSValue {\n const str = JS_ToString(ctx, argv[0]);\n if (JS_IsException(str)) return str;\n return JS_Eval(ctx, str as string, '<evalScript>', JS_EVAL_TYPE_GLOBAL);\n}\n\nfunction js_std_loadFile(ctx: JSContext, this_val: JSValue, argv: JSValue[]): JSValue {\n const str = JS_ToString(ctx, argv[0]);\n if (JS_IsException(str)) return str;\n try {\n return readFileSync(str as string, 'utf8');\n } catch {\n return null;\n }\n}\n\nfunction js_std_writeFile(ctx: JSContext, this_val: JSValue, argv: JSValue[]): JSValue {\n const name = JS_ToString(ctx, argv[0]);\n if (JS_IsException(name)) return name;\n const data = JS_ToString(ctx, argv[1]);\n if (JS_IsException(data)) return data;\n writeFileSync(name as string, data as string);\n return undefined;\n}\n\nfunction js_std_exit(ctx: JSContext, this_val: JSValue, argv: JSValue[]): JSValue {\n const code = JS_ToFloat64(ctx, argv[0]);\n process.exit(JS_IsException(code) ? 1 : (code as number) | 0);\n}\n\nfunction js_std_gc(ctx: JSContext, this_val: JSValue, argv: JSValue[]): JSValue {\n return undefined;\n}\n\nfunction js_std_getenv(ctx: JSContext, this_val: JSValue, argv: JSValue[]): JSValue {\n const name = JS_ToString(ctx, argv[0]);\n if (JS_IsException(name)) return name;\n const v = process.env[name as string];\n return v === undefined ? undefined : v;\n}\n\n/* timers: os.setTimeout(func, delay) / os.clearTimeout(id) */\ninterface JSOSTimer { id: number; func: JSValue; timeout: number }\nconst os_timers: JSOSTimer[] = [];\nlet os_timer_id = 1;\n\nfunction js_os_setTimeout(ctx: JSContext, this_val: JSValue, argv: JSValue[]): JSValue {\n const func = argv[0];\n if (!JS_IsFunction(ctx, func)) return JS_ThrowTypeError(ctx, 'not a function');\n const delay = JS_ToFloat64(ctx, argv[1]);\n if (JS_IsException(delay)) return delay;\n const th: JSOSTimer = { id: os_timer_id++, func, timeout: Date.now() + Math.max(0, delay as number) };\n os_timers.push(th);\n return th.id;\n}\n\nfunction js_os_clearTimeout(ctx: JSContext, this_val: JSValue, argv: JSValue[]): JSValue {\n const id = JS_ToFloat64(ctx, argv[0]);\n if (JS_IsException(id)) return id;\n const i = os_timers.findIndex(t => t.id === id);\n if (i >= 0) os_timers.splice(i, 1);\n return undefined;\n}\n\nfunction js_os_now(ctx: JSContext, this_val: JSValue, argv: JSValue[]): JSValue {\n return performance.now();\n}\n\n/* std.open(filename, mode): minimal FILE object (in-memory buffer) */\nclass StdFile {\n data: string;\n pos = 0;\n constructor(public name: string, public mode: string, data: string) { this.data = data; }\n}\n\nfunction std_file_get(ctx: JSContext, this_val: JSValue): StdFile | null {\n const f = JS_GetAnyOpaque(this_val);\n if (f instanceof StdFile) return f;\n JS_ThrowTypeError(ctx, 'not a FILE object');\n return null;\n}\n\nfunction js_std_file_puts(ctx: JSContext, this_val: JSValue, argv: JSValue[]): JSValue {\n const f = std_file_get(ctx, this_val);\n if (!f) return JS_EXCEPTION;\n for (const a of argv) {\n const str = JS_ToString(ctx, a);\n if (JS_IsException(str)) return str;\n f.data += str as string;\n }\n return undefined;\n}\n\nfunction js_std_file_getline(ctx: JSContext, this_val: JSValue, argv: JSValue[]): JSValue {\n const f = std_file_get(ctx, this_val);\n if (!f) return JS_EXCEPTION;\n if (f.pos >= f.data.length) return null;\n let end = f.data.indexOf('\\n', f.pos);\n if (end < 0) end = f.data.length;\n const line = f.data.substring(f.pos, end);\n f.pos = end + 1;\n return line;\n}\n\nfunction js_std_file_readAsString(ctx: JSContext, this_val: JSValue, argv: JSValue[]): JSValue {\n const f = std_file_get(ctx, this_val);\n if (!f) return JS_EXCEPTION;\n const r = f.data.substring(f.pos);\n f.pos = f.data.length;\n return r;\n}\n\nfunction js_std_file_eof(ctx: JSContext, this_val: JSValue, argv: JSValue[]): JSValue {\n const f = std_file_get(ctx, this_val);\n if (!f) return JS_EXCEPTION;\n return f.pos >= f.data.length;\n}\n\nfunction js_std_file_close(ctx: JSContext, this_val: JSValue, argv: JSValue[]): JSValue {\n const f = std_file_get(ctx, this_val);\n if (!f) return JS_EXCEPTION;\n if (f.mode.includes('w') || f.mode.includes('a')) {\n try { writeFileSync(f.name, f.data); } catch { return -1; }\n }\n return 0;\n}\n\nlet std_file_proto: JSValue = undefined;\n\nfunction js_std_open(ctx: JSContext, this_val: JSValue, argv: JSValue[]): JSValue {\n const name = JS_ToString(ctx, argv[0]);\n if (JS_IsException(name)) return name;\n const mode = JS_ToString(ctx, argv[1]);\n if (JS_IsException(mode)) return mode;\n let data = '';\n if ((mode as string).includes('r') || (mode as string).includes('a')) {\n try { data = readFileSync(name as string, 'utf8'); } catch { if (!(mode as string).includes('a')) return null; }\n }\n if (std_file_proto === undefined) {\n std_file_proto = JS_NewObject(ctx);\n JS_SetPropertyFunctionList(ctx, std_file_proto, [\n JS_CFUNC_DEF('puts', 1, js_std_file_puts),\n JS_CFUNC_DEF('getline', 0, js_std_file_getline),\n JS_CFUNC_DEF('readAsString', 0, js_std_file_readAsString),\n JS_CFUNC_DEF('eof', 0, js_std_file_eof),\n JS_CFUNC_DEF('close', 0, js_std_file_close),\n ]);\n }\n const obj = JS_NewObjectProto(ctx, std_file_proto);\n JS_SetOpaque(obj, new StdFile(name as string, mode as string, data));\n return obj;\n}\n\nconst js_std_funcs = [\n JS_CFUNC_DEF('open', 2, js_std_open),\n JS_CFUNC_DEF('evalScript', 1, js_std_evalScript),\n JS_CFUNC_DEF('loadFile', 1, js_std_loadFile),\n JS_CFUNC_DEF('writeFile', 2, js_std_writeFile),\n JS_CFUNC_DEF('exit', 1, js_std_exit),\n JS_CFUNC_DEF('gc', 0, js_std_gc),\n JS_CFUNC_DEF('getenv', 1, js_std_getenv),\n];\n\nconst js_os_funcs = [\n JS_CFUNC_DEF('setTimeout', 2, js_os_setTimeout),\n JS_CFUNC_DEF('clearTimeout', 1, js_os_clearTimeout),\n JS_CFUNC_DEF('now', 0, js_os_now),\n];\n\nexport function js_std_add_helpers(ctx: JSContext, args: string[]): void {\n const global = ctx.global_obj;\n /* scriptArgs */\n JS_DefinePropertyValueStr(ctx, global, 'scriptArgs', JS_NewArrayFrom(ctx, args.slice()), JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE);\n JS_DefinePropertyValueStr(ctx, global, 'print', JS_NewCFunction(ctx, js_print, 'print', 1), JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE);\n const console = JS_NewObject(ctx);\n JS_SetPropertyFunctionList(ctx, console, [\n JS_CFUNC_MAGIC_DEF('log', 1, js_console_log, 1),\n JS_CFUNC_MAGIC_DEF('info', 1, js_console_log, 1),\n JS_CFUNC_MAGIC_DEF('debug', 1, js_console_log, 1),\n JS_CFUNC_MAGIC_DEF('warn', 1, js_console_log, 2),\n JS_CFUNC_MAGIC_DEF('error', 1, js_console_log, 2),\n ]);\n JS_DefinePropertyValueStr(ctx, global, 'console', console, JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE);\n const std = JS_NewObject(ctx);\n JS_SetPropertyFunctionList(ctx, std, js_std_funcs);\n JS_DefinePropertyValueStr(ctx, global, 'std', std, JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE);\n const os = JS_NewObject(ctx);\n JS_SetPropertyFunctionList(ctx, os, js_os_funcs);\n JS_DefinePropertyValueStr(ctx, os, 'platform', process.platform, JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE);\n JS_DefinePropertyValueStr(ctx, global, 'os', os, JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE);\n}\n\nexport function js_std_dump_error(ctx: JSContext): void {\n const exc = JS_GetException(ctx);\n process.stderr.write(formatException(ctx, exc) + '\\n');\n}\n\n/* main loop: run pending jobs and timers until none is left */\nexport async function js_std_loop(ctx: JSContext): Promise<void> {\n const rt = ctx.rt;\n for (;;) {\n /* execute the pending jobs */\n const pctx = { ctx: null as JSContext | null };\n for (;;) {\n const r = JS_ExecutePendingJob(rt, pctx);\n if (r <= 0) {\n if (r < 0 && pctx.ctx) js_std_dump_error(pctx.ctx);\n break;\n }\n }\n if (os_timers.length === 0) break;\n /* run the earliest timer */\n os_timers.sort((a, b) => a.timeout - b.timeout);\n const th = os_timers[0];\n const delay = th.timeout - Date.now();\n if (delay > 0) await new Promise(res => setTimeout(res, delay));\n os_timers.shift();\n const ret = JS_Call(ctx, th.func, undefined, []);\n if (JS_IsException(ret)) js_std_dump_error(ctx);\n }\n}\n\n/* The module loader of the command line interpreter: relative and absolute paths (and\n file: URLs) are resolved against the importing file and read from disk. Bare specifiers\n are not resolved: there is no package lookup. Ids are absolute paths; import.meta.url is\n their file: URL. .ts, .mts and .cts files are TypeScript. */\nexport function js_std_module_loader(): JSModuleLoader {\n const to_path = (s: string): string => s.startsWith('file:') ? fileURLToPath(s) : s;\n return {\n resolve(specifier, referrer) {\n if (specifier.startsWith('file:')) return fileURLToPath(specifier);\n if (specifier.startsWith('/')) return path_resolve(specifier);\n if (specifier.startsWith('./') || specifier.startsWith('../')) {\n const base = referrer !== null ? path_resolve(to_path(referrer)) : path_resolve('<cmdline>');\n return path_resolve(path_dirname(base), specifier);\n }\n throw new TypeError(`cannot resolve '${specifier}': only relative and absolute paths are supported`);\n },\n load(id, attributes) {\n let source: string;\n try {\n source = readFileSync(id, 'utf8');\n } catch (e) {\n throw new TypeError(`cannot load module '${id}': ${(e as NodeJS.ErrnoException).code ?? (e as Error).message}`);\n }\n const type = attributes.type === 'json' ? 'json' : js_module_type_of(id);\n return { source, url: pathToFileURL(id).href, type };\n },\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"std.js","sourceRoot":"","sources":["../src/std.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EACe,cAAc,EAAE,WAAW,EAAE,eAAe,EAAE,YAAY,EAAE,eAAe,EAC9E,yBAAyB,EAAiB,gBAAgB,EAAE,oBAAoB,EAAE,eAAe,EAClH,0BAA0B,EAAE,YAAY,EAAE,kBAAkB,EAAE,OAAO,EAAE,iBAAiB,EACxF,OAAO,EAAE,mBAAmB,EAAiC,YAAY,EAAE,aAAa,EACxF,oBAAoB,EAA8C,iBAAiB,EAAE,YAAY,EAAE,eAAe,EAClH,YAAY,GACb,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAElE,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,YA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S,CAAC,UAAU,CAAC,GAAG,CAAC;gBAAE,OAAO,YAAY,CAAC,SAAS,CAAC,CAAC;YAC9D,IAAI,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,SAAS,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC9D,MAAM,IAAI,GAAG,QAAQ,KAAK,IAAI,CAAC,CAAC,CAAC,YAAY,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC;gBAC7F,OAAO,YAAY,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,SAAS,CAAC,CAAC;YACrD,CAAC;YACD,MAAM,IAAI,SAAS,CAAC,mBAAmB,SAAS,mDAAmD,CAAC,CAAC;QACvG,CAAC;QACD,IAAI,CAAC,EAAE,EAAE,UAAU;YACjB,IAAI,MAAc,CAAC;YACnB,IAAI,CAAC;gBACH,MAAM,GAAG,YAAY,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;YACpC,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACX,MAAM,IAAI,SAAS,CAAC,uBAAuB,EAAE,MAAO,CAA2B,CAAC,IAAI,IAAK,CAAW,CAAC,OAAO,EAAE,CAAC,CAAC;YAClH,CAAC;YACD,MAAM,IAAI,GAAG,UAAU,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAC;YACzE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,aAAa,CAAC,EAAE,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC;QACvD,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["/*\n * Minimal host bindings for the command line interpreter: port of a subset\n * of quickjs-libc.c (print, console, scriptArgs, std.*, os.*).\n */\nimport {\n JSContext, JSValue, JS_IsException, JS_ToString, JS_GetException, JS_NewObject, JS_NewCFunction, JS_NewCFunctionMagic,\n JSCFunctionEnum, JS_DefinePropertyValueStr, JS_PROP_C_W_E, JS_PROP_WRITABLE, JS_PROP_CONFIGURABLE, JS_NewArrayFrom,\n JS_SetPropertyFunctionList, JS_CFUNC_DEF, JS_CFUNC_MAGIC_DEF, JS_Call, JS_ThrowTypeError, JS_ThrowReferenceError,\n JS_Eval, JS_EVAL_TYPE_GLOBAL, JS_IsError, JS_GetPropertyStr, JS_ToFloat64, JS_IsFunction, JS_NewError,\n JS_ExecutePendingJob, JS_IsJobPending, JSRuntime, JS_IsUndefined, JS_NewObjectProto, JS_EXCEPTION, JS_GetAnyOpaque,\n JS_SetOpaque,\n} from './quickjs.ts';\nimport { JS_PrintValue, JS_PrintValueToString } from './print.ts';\nimport type { JSModuleLoader } from './module.ts';\nimport { js_module_type_of } from './module.ts';\nimport { readFileSync, writeFileSync } from 'node:fs';\nimport { resolve as path_resolve, dirname as path_dirname } from 'node:path';\nimport { pathToFileURL, fileURLToPath } from 'node:url';\n\nconst enc = new TextEncoder();\n\nfunction write_out(fd: number, s: string): void {\n if (fd === 2) process.stderr.write(s); else process.stdout.write(s);\n}\n\n/* print() and console.log(): strings are written as they are, other values\n with JS_PrintValue (QuickJS be06b3e) */\nfunction js_print_internal(ctx: JSContext, argv: JSValue[], fd: number): JSValue {\n let out = '';\n for (let i = 0; i < argv.length; i++) {\n if (i !== 0) out += ' ';\n const v = argv[i];\n if (typeof v === 'string') out += v;\n else JS_PrintValue(ctx, (_o, buf) => { out += buf; }, null, v, null);\n }\n write_out(fd, out + '\\n');\n return undefined;\n}\n\nfunction js_print(ctx: JSContext, this_val: JSValue, argv: JSValue[]): JSValue {\n return js_print_internal(ctx, argv, 1);\n}\n\nfunction js_console_log(ctx: JSContext, this_val: JSValue, argv: JSValue[], magic: number): JSValue {\n return js_print_internal(ctx, argv, magic);\n}\n\n/* std.evalScript(str) */\nfunction js_std_evalScript(ctx: JSContext, this_val: JSValue, argv: JSValue[]): JSValue {\n const str = JS_ToString(ctx, argv[0]);\n if (JS_IsException(str)) return str;\n return JS_Eval(ctx, str as string, '<evalScript>', JS_EVAL_TYPE_GLOBAL);\n}\n\nfunction js_std_loadFile(ctx: JSContext, this_val: JSValue, argv: JSValue[]): JSValue {\n const str = JS_ToString(ctx, argv[0]);\n if (JS_IsException(str)) return str;\n try {\n return readFileSync(str as string, 'utf8');\n } catch {\n return null;\n }\n}\n\nfunction js_std_writeFile(ctx: JSContext, this_val: JSValue, argv: JSValue[]): JSValue {\n const name = JS_ToString(ctx, argv[0]);\n if (JS_IsException(name)) return name;\n const data = JS_ToString(ctx, argv[1]);\n if (JS_IsException(data)) return data;\n writeFileSync(name as string, data as string);\n return undefined;\n}\n\nfunction js_std_exit(ctx: JSContext, this_val: JSValue, argv: JSValue[]): JSValue {\n const code = JS_ToFloat64(ctx, argv[0]);\n process.exit(JS_IsException(code) ? 1 : (code as number) | 0);\n}\n\nfunction js_std_gc(ctx: JSContext, this_val: JSValue, argv: JSValue[]): JSValue {\n return undefined;\n}\n\nfunction js_std_getenv(ctx: JSContext, this_val: JSValue, argv: JSValue[]): JSValue {\n const name = JS_ToString(ctx, argv[0]);\n if (JS_IsException(name)) return name;\n const v = process.env[name as string];\n return v === undefined ? undefined : v;\n}\n\n/* timers: os.setTimeout(func, delay) / os.clearTimeout(id) */\ninterface JSOSTimer { id: number; func: JSValue; timeout: number }\nconst os_timers: JSOSTimer[] = [];\nlet os_timer_id = 1;\n\nfunction js_os_setTimeout(ctx: JSContext, this_val: JSValue, argv: JSValue[]): JSValue {\n const func = argv[0];\n if (!JS_IsFunction(ctx, func)) return JS_ThrowTypeError(ctx, 'not a function');\n const delay = JS_ToFloat64(ctx, argv[1]);\n if (JS_IsException(delay)) return delay;\n const th: JSOSTimer = { id: os_timer_id++, func, timeout: Date.now() + Math.max(0, delay as number) };\n os_timers.push(th);\n return th.id;\n}\n\nfunction js_os_clearTimeout(ctx: JSContext, this_val: JSValue, argv: JSValue[]): JSValue {\n const id = JS_ToFloat64(ctx, argv[0]);\n if (JS_IsException(id)) return id;\n const i = os_timers.findIndex(t => t.id === id);\n if (i >= 0) os_timers.splice(i, 1);\n return undefined;\n}\n\nfunction js_os_now(ctx: JSContext, this_val: JSValue, argv: JSValue[]): JSValue {\n return performance.now();\n}\n\n/* std.open(filename, mode): minimal FILE object (in-memory buffer) */\nclass StdFile {\n data: string;\n pos = 0;\n constructor(public name: string, public mode: string, data: string) { this.data = data; }\n}\n\nfunction std_file_get(ctx: JSContext, this_val: JSValue): StdFile | null {\n const f = JS_GetAnyOpaque(this_val);\n if (f instanceof StdFile) return f;\n JS_ThrowTypeError(ctx, 'not a FILE object');\n return null;\n}\n\nfunction js_std_file_puts(ctx: JSContext, this_val: JSValue, argv: JSValue[]): JSValue {\n const f = std_file_get(ctx, this_val);\n if (!f) return JS_EXCEPTION;\n for (const a of argv) {\n const str = JS_ToString(ctx, a);\n if (JS_IsException(str)) return str;\n f.data += str as string;\n }\n return undefined;\n}\n\nfunction js_std_file_getline(ctx: JSContext, this_val: JSValue, argv: JSValue[]): JSValue {\n const f = std_file_get(ctx, this_val);\n if (!f) return JS_EXCEPTION;\n if (f.pos >= f.data.length) return null;\n let end = f.data.indexOf('\\n', f.pos);\n if (end < 0) end = f.data.length;\n const line = f.data.substring(f.pos, end);\n f.pos = end + 1;\n return line;\n}\n\nfunction js_std_file_readAsString(ctx: JSContext, this_val: JSValue, argv: JSValue[]): JSValue {\n const f = std_file_get(ctx, this_val);\n if (!f) return JS_EXCEPTION;\n const r = f.data.substring(f.pos);\n f.pos = f.data.length;\n return r;\n}\n\nfunction js_std_file_eof(ctx: JSContext, this_val: JSValue, argv: JSValue[]): JSValue {\n const f = std_file_get(ctx, this_val);\n if (!f) return JS_EXCEPTION;\n return f.pos >= f.data.length;\n}\n\nfunction js_std_file_close(ctx: JSContext, this_val: JSValue, argv: JSValue[]): JSValue {\n const f = std_file_get(ctx, this_val);\n if (!f) return JS_EXCEPTION;\n if (f.mode.includes('w') || f.mode.includes('a')) {\n try { writeFileSync(f.name, f.data); } catch { return -1; }\n }\n return 0;\n}\n\nlet std_file_proto: JSValue = undefined;\n\nfunction js_std_open(ctx: JSContext, this_val: JSValue, argv: JSValue[]): JSValue {\n const name = JS_ToString(ctx, argv[0]);\n if (JS_IsException(name)) return name;\n const mode = JS_ToString(ctx, argv[1]);\n if (JS_IsException(mode)) return mode;\n let data = '';\n if ((mode as string).includes('r') || (mode as string).includes('a')) {\n try { data = readFileSync(name as string, 'utf8'); } catch { if (!(mode as string).includes('a')) return null; }\n }\n if (std_file_proto === undefined) {\n std_file_proto = JS_NewObject(ctx);\n JS_SetPropertyFunctionList(ctx, std_file_proto, [\n JS_CFUNC_DEF('puts', 1, js_std_file_puts),\n JS_CFUNC_DEF('getline', 0, js_std_file_getline),\n JS_CFUNC_DEF('readAsString', 0, js_std_file_readAsString),\n JS_CFUNC_DEF('eof', 0, js_std_file_eof),\n JS_CFUNC_DEF('close', 0, js_std_file_close),\n ]);\n }\n const obj = JS_NewObjectProto(ctx, std_file_proto);\n JS_SetOpaque(obj, new StdFile(name as string, mode as string, data));\n return obj;\n}\n\nconst js_std_funcs = [\n JS_CFUNC_DEF('open', 2, js_std_open),\n JS_CFUNC_DEF('evalScript', 1, js_std_evalScript),\n JS_CFUNC_DEF('loadFile', 1, js_std_loadFile),\n JS_CFUNC_DEF('writeFile', 2, js_std_writeFile),\n JS_CFUNC_DEF('exit', 1, js_std_exit),\n JS_CFUNC_DEF('gc', 0, js_std_gc),\n JS_CFUNC_DEF('getenv', 1, js_std_getenv),\n];\n\nconst js_os_funcs = [\n JS_CFUNC_DEF('setTimeout', 2, js_os_setTimeout),\n JS_CFUNC_DEF('clearTimeout', 1, js_os_clearTimeout),\n JS_CFUNC_DEF('now', 0, js_os_now),\n];\n\nexport function js_std_add_helpers(ctx: JSContext, args: string[]): void {\n const global = ctx.global_obj;\n /* scriptArgs */\n JS_DefinePropertyValueStr(ctx, global, 'scriptArgs', JS_NewArrayFrom(ctx, args.slice()), JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE);\n JS_DefinePropertyValueStr(ctx, global, 'print', JS_NewCFunction(ctx, js_print, 'print', 1), JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE);\n const console = JS_NewObject(ctx);\n JS_SetPropertyFunctionList(ctx, console, [\n JS_CFUNC_MAGIC_DEF('log', 1, js_console_log, 1),\n JS_CFUNC_MAGIC_DEF('info', 1, js_console_log, 1),\n JS_CFUNC_MAGIC_DEF('debug', 1, js_console_log, 1),\n JS_CFUNC_MAGIC_DEF('warn', 1, js_console_log, 2),\n JS_CFUNC_MAGIC_DEF('error', 1, js_console_log, 2),\n ]);\n JS_DefinePropertyValueStr(ctx, global, 'console', console, JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE);\n const std = JS_NewObject(ctx);\n JS_SetPropertyFunctionList(ctx, std, js_std_funcs);\n JS_DefinePropertyValueStr(ctx, global, 'std', std, JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE);\n const os = JS_NewObject(ctx);\n JS_SetPropertyFunctionList(ctx, os, js_os_funcs);\n JS_DefinePropertyValueStr(ctx, os, 'platform', process.platform, JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE);\n JS_DefinePropertyValueStr(ctx, global, 'os', os, JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE);\n}\n\nexport function js_std_dump_error1(ctx: JSContext, exception_val: JSValue): void {\n process.stderr.write(JS_PrintValueToString(ctx, exception_val) + '\\n');\n}\n\nexport function js_std_dump_error(ctx: JSContext): void {\n js_std_dump_error1(ctx, JS_GetException(ctx));\n}\n\n/* Promise rejection tracker (QuickJS 3c39307): the unhandled rejections are\n recorded, a rejection handled later is removed, and the remaining ones\n are reported when the event loop is about to sleep or ends */\nconst rejected_promises = new Map<JSValue, JSValue>();\n\nexport function js_std_promise_rejection_tracker(ctx: JSContext, promise: JSValue, reason: JSValue, is_handled: boolean): void {\n if (!is_handled) {\n if (!rejected_promises.has(promise)) rejected_promises.set(promise, reason);\n } else {\n rejected_promises.delete(promise);\n }\n}\n\n/* report the pending unhandled rejections and exit (the promises in 'ignore'\n are reported by the caller) */\nfunction js_std_promise_rejection_check(ctx: JSContext, ignore: readonly JSValue[]): void {\n let n = 0;\n for (const [promise, reason] of rejected_promises) {\n if (ignore.includes(promise)) continue;\n process.stderr.write('Possibly unhandled promise rejection: ');\n js_std_dump_error1(ctx, reason);\n n++;\n }\n if (n > 0) process.exit(1);\n}\n\n/* main loop: run pending jobs and timers until none is left */\nexport async function js_std_loop(ctx: JSContext, ignore_rejections: readonly JSValue[] = []): Promise<void> {\n const rt = ctx.rt;\n for (;;) {\n /* execute the pending jobs */\n const pctx = { ctx: null as JSContext | null };\n for (;;) {\n const r = JS_ExecutePendingJob(rt, pctx);\n if (r <= 0) {\n if (r < 0 && pctx.ctx) js_std_dump_error(pctx.ctx);\n break;\n }\n }\n if (rt.host_promise_rejection_tracker !== null) js_std_promise_rejection_check(ctx, ignore_rejections);\n if (os_timers.length === 0) break;\n /* run the earliest timer */\n os_timers.sort((a, b) => a.timeout - b.timeout);\n const th = os_timers[0];\n const delay = th.timeout - Date.now();\n if (delay > 0) await new Promise(res => setTimeout(res, delay));\n os_timers.shift();\n const ret = JS_Call(ctx, th.func, undefined, []);\n if (JS_IsException(ret)) js_std_dump_error(ctx);\n }\n}\n\n/* The module loader of the command line interpreter: relative and absolute paths (and\n file: URLs) are resolved against the importing file and read from disk. Bare specifiers\n are not resolved: there is no package lookup. Ids are absolute paths; import.meta.url is\n their file: URL. .ts, .mts and .cts files are TypeScript. */\nexport function js_std_module_loader(): JSModuleLoader {\n const to_path = (s: string): string => s.startsWith('file:') ? fileURLToPath(s) : s;\n return {\n resolve(specifier, referrer) {\n if (specifier.startsWith('file:')) return fileURLToPath(specifier);\n if (specifier.startsWith('/')) return path_resolve(specifier);\n if (specifier.startsWith('./') || specifier.startsWith('../')) {\n const base = referrer !== null ? path_resolve(to_path(referrer)) : path_resolve('<cmdline>');\n return path_resolve(path_dirname(base), specifier);\n }\n throw new TypeError(`cannot resolve '${specifier}': only relative and absolute paths are supported`);\n },\n load(id, attributes) {\n let source: string;\n try {\n source = readFileSync(id, 'utf8');\n } catch (e) {\n throw new TypeError(`cannot load module '${id}': ${(e as NodeJS.ErrnoException).code ?? (e as Error).message}`);\n }\n const type = attributes.type === 'json' ? 'json' : js_module_type_of(id);\n return { source, url: pathToFileURL(id).href, type };\n },\n };\n}\n"]}
|
package/dist/values.d.ts
CHANGED
|
@@ -70,33 +70,37 @@ export declare const enum JSClassID {
|
|
|
70
70
|
UINT32_ARRAY = 27,
|
|
71
71
|
BIG_INT64_ARRAY = 28,
|
|
72
72
|
BIG_UINT64_ARRAY = 29,
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
73
|
+
FLOAT16_ARRAY = 30,
|
|
74
|
+
FLOAT32_ARRAY = 31,
|
|
75
|
+
FLOAT64_ARRAY = 32,
|
|
76
|
+
DATAVIEW = 33,
|
|
77
|
+
BIG_INT = 34,
|
|
78
|
+
MAP = 35,
|
|
79
|
+
SET = 36,
|
|
80
|
+
WEAKMAP = 37,
|
|
81
|
+
WEAKSET = 38,
|
|
82
|
+
MAP_ITERATOR = 39,
|
|
83
|
+
SET_ITERATOR = 40,
|
|
84
|
+
ARRAY_ITERATOR = 41,
|
|
85
|
+
STRING_ITERATOR = 42,
|
|
86
|
+
REGEXP_STRING_ITERATOR = 43,
|
|
87
|
+
GENERATOR = 44,
|
|
88
|
+
PROXY = 45,
|
|
89
|
+
PROMISE = 46,
|
|
90
|
+
PROMISE_RESOLVE_FUNCTION = 47,
|
|
91
|
+
PROMISE_REJECT_FUNCTION = 48,
|
|
92
|
+
ASYNC_FUNCTION = 49,
|
|
93
|
+
ASYNC_FUNCTION_RESOLVE = 50,
|
|
94
|
+
ASYNC_FUNCTION_REJECT = 51,
|
|
95
|
+
ASYNC_FROM_SYNC_ITERATOR = 52,
|
|
96
|
+
ASYNC_GENERATOR_FUNCTION = 53,
|
|
97
|
+
ASYNC_GENERATOR = 54,
|
|
98
|
+
WEAK_REF = 55,
|
|
99
|
+
FINALIZATION_REGISTRY = 56,
|
|
100
|
+
ITERATOR = 57,
|
|
101
|
+
ITERATOR_HELPER = 58,
|
|
102
|
+
ITERATOR_WRAP = 59,
|
|
103
|
+
INIT_COUNT = 60
|
|
100
104
|
}
|
|
101
105
|
export declare const JS_PROP_CONFIGURABLE: number;
|
|
102
106
|
export declare const JS_PROP_WRITABLE: number;
|
package/dist/values.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"values.js","sourceRoot":"","sources":["../src/values.ts"],"names":[],"mappings":"AA4BA,MAAM,OAAO,SAAS;IACD;IAAmB;IAAtC,YAAmB,GAAU,EAAS,CAAS;QAA5B,QAAG,GAAH,GAAG,CAAO;QAAS,MAAC,GAAD,CAAC,CAAQ;IAAG,CAAC;CACpD;AAED,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,SAAS,8BAAsB,CAAC,CAAC,CAAC;AACtE,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,SAAS,0BAAkB,CAAC,CAAC,CAAC;AAC9D,MAAM,CAAC,MAAM,YAAY,GAAG,SAAS,CAAC;AACtC,MAAM,CAAC,MAAM,OAAO,GAAG,IAAI,CAAC;AAC5B,MAAM,CAAC,MAAM,OAAO,GAAG,IAAI,CAAC;AAC5B,MAAM,CAAC,MAAM,QAAQ,GAAG,KAAK,CAAC;AAkB9B,6DAA6D;AAC7D,MAAM,gBAAgB,GAAgB,EAAE,CAAC;AAC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C;IACzB,0BAA0B,GAAG,CAAC,CAAC;IAC/B,UAAU,GAAuB,IAAI,CAAC;IACtC,OAAO,GAAY,SAAS,CAAC,CAAC,kCAAkC;IAChE,eAAe,GAAuB,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;IAC7D,kBAAkB,GAAG,KAAK,CAAC;IAC3B,cAAc,GAAY,SAAS,CAAC;IACpC,QAAQ,GAAY,SAAS,CAAC;IAC9B,SAAS,GAAY,SAAS,CAAC;IAC/B,aAAa,GAA8B,IAAI,CAAC,CAAC,yBAAyB;IAC1E,QAAQ,GAAY,SAAS,CAAC,CAAC,2CAA2C;IAC1E,YAAY,GAAG,KAAK,CAAC;IACrB,wEAAwE;IACxE,iBAAiB,GAAgC,IAAI,CAAC;IACtD,yDAAyD;IACzD,eAAe,GAAG,KAAK,CAAC;IACxB,KAAK,GAAQ,IAAI,CAAC,CAAC,eAAe;IAClC,YAAY,WAAmB,IAAI,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC,CAAC,CAAC;CACrE","sourcesContent":["/*\n * Value and object representation (host-values model, see docs/HOST_VALUES.md).\n *\n * Primitive JS values are the host primitives (undefined, null, boolean,\n * number, string, bigint, symbol). Guest objects are host objects whose\n * prototype chains are entirely guest-owned; engine metadata for the\n * objects that need it (class id, internal slots, bytecode) lives in a\n * WeakMap (JSRuntime.meta). The special QuickJS tags (uninitialized,\n * exception, catch offset) are JSSpecial instances that never escape to\n * guest code.\n */\nimport { JSAtom } from './atoms.ts';\n\nexport const enum JSTag {\n UNINITIALIZED = 0,\n INT = 1,\n BOOL = 2,\n NULL = 3,\n UNDEFINED = 4,\n CATCH_OFFSET = 5,\n EXCEPTION = 6,\n FLOAT64 = 7,\n BIG_INT = 8,\n STRING = 9,\n SYMBOL = 10,\n OBJECT = 11,\n}\n\nexport class JSSpecial {\n constructor(public tag: JSTag, public v: number) {}\n}\n\nexport const JS_UNINITIALIZED = new JSSpecial(JSTag.UNINITIALIZED, 0);\nexport const JS_EXCEPTION = new JSSpecial(JSTag.EXCEPTION, 0);\nexport const JS_UNDEFINED = undefined;\nexport const JS_NULL = null;\nexport const JS_TRUE = true;\nexport const JS_FALSE = false;\n\n/* a guest object is any host object (or function) */\nexport type JSObject = object;\n\nexport type JSValue =\n | undefined\n | null\n | boolean\n | number\n | string\n | bigint\n | symbol\n | JSObject\n | JSSpecial;\n\nexport type JSValueConst = JSValue;\n\n/* catch offsets are stored on the stack; cache small ones */\nconst catchOffsetCache: JSSpecial[] = [];\nexport function JS_NewCatchOffset(v: number): JSSpecial {\n let r = catchOffsetCache[v];\n if (r === undefined) {\n r = new JSSpecial(JSTag.CATCH_OFFSET, v);\n if (v < 1024) catchOffsetCache[v] = r;\n }\n return r;\n}\n\nexport function JS_VALUE_GET_TAG(v: JSValue): JSTag {\n switch (typeof v) {\n case 'undefined': return JSTag.UNDEFINED;\n case 'boolean': return JSTag.BOOL;\n case 'number': return Number.isInteger(v) && v >= -2147483648 && v <= 2147483647 && !(v === 0 && 1 / v < 0) ? JSTag.INT : JSTag.FLOAT64;\n case 'string': return JSTag.STRING;\n case 'bigint': return JSTag.BIG_INT;\n case 'symbol': return JSTag.SYMBOL;\n case 'function': return JSTag.OBJECT;\n case 'object':\n if (v === null) return JSTag.NULL;\n if (v instanceof JSSpecial) return v.tag;\n return JSTag.OBJECT;\n }\n return JSTag.UNDEFINED;\n}\n\nexport function JS_IsException(v: JSValue): v is JSSpecial { return v === JS_EXCEPTION; }\nexport function JS_IsUninitialized(v: JSValue): boolean { return v === JS_UNINITIALIZED; }\nexport function JS_IsUndefined(v: JSValue): v is undefined { return v === undefined; }\nexport function JS_IsNull(v: JSValue): v is null { return v === null; }\n/* true for guest objects (including functions); the internal sentinels are excluded */\nexport function JS_IsObject(v: JSValue): v is JSObject {\n const t = typeof v;\n if (t === 'object') return v !== null && !(v instanceof JSSpecial);\n return t === 'function';\n}\nexport function JS_IsString(v: JSValue): v is string { return typeof v === 'string'; }\nexport function JS_IsSymbol(v: JSValue): v is symbol { return typeof v === 'symbol'; }\nexport function JS_IsNumber(v: JSValue): v is number { return typeof v === 'number'; }\nexport function JS_IsBigInt(v: JSValue): v is bigint { return typeof v === 'bigint'; }\nexport function JS_IsBool(v: JSValue): v is boolean { return typeof v === 'boolean'; }\nexport function JS_IsCatchOffset(v: JSValue): v is JSSpecial {\n return v instanceof JSSpecial && v.tag === JSTag.CATCH_OFFSET;\n}\n\n/* class ids (same order as quickjs.c) */\nexport const enum JSClassID {\n OBJECT = 1,\n ARRAY,\n ERROR,\n NUMBER,\n STRING,\n BOOLEAN,\n SYMBOL,\n ARGUMENTS,\n MAPPED_ARGUMENTS,\n DATE,\n MODULE_NS,\n C_FUNCTION,\n BYTECODE_FUNCTION,\n BOUND_FUNCTION,\n C_FUNCTION_DATA,\n GENERATOR_FUNCTION,\n FOR_IN_ITERATOR,\n REGEXP,\n ARRAY_BUFFER,\n SHARED_ARRAY_BUFFER,\n UINT8C_ARRAY,\n INT8_ARRAY,\n UINT8_ARRAY,\n INT16_ARRAY,\n UINT16_ARRAY,\n INT32_ARRAY,\n UINT32_ARRAY,\n BIG_INT64_ARRAY,\n BIG_UINT64_ARRAY,\n FLOAT32_ARRAY,\n FLOAT64_ARRAY,\n DATAVIEW,\n BIG_INT,\n MAP,\n SET,\n WEAKMAP,\n WEAKSET,\n MAP_ITERATOR,\n SET_ITERATOR,\n ARRAY_ITERATOR,\n STRING_ITERATOR,\n REGEXP_STRING_ITERATOR,\n GENERATOR,\n PROXY,\n PROMISE,\n PROMISE_RESOLVE_FUNCTION,\n PROMISE_REJECT_FUNCTION,\n ASYNC_FUNCTION,\n ASYNC_FUNCTION_RESOLVE,\n ASYNC_FUNCTION_REJECT,\n ASYNC_FROM_SYNC_ITERATOR,\n ASYNC_GENERATOR_FUNCTION,\n ASYNC_GENERATOR,\n WEAK_REF,\n FINALIZATION_REGISTRY,\n INIT_COUNT,\n}\n\n/* property flags */\nexport const JS_PROP_CONFIGURABLE = 1 << 0;\nexport const JS_PROP_WRITABLE = 1 << 1;\nexport const JS_PROP_ENUMERABLE = 1 << 2;\nexport const JS_PROP_C_W_E = JS_PROP_CONFIGURABLE | JS_PROP_WRITABLE | JS_PROP_ENUMERABLE;\nexport const JS_PROP_LENGTH = 1 << 3; /* used internally in Arrays */\nexport const JS_PROP_TMASK = 3 << 4;\nexport const JS_PROP_NORMAL = 0 << 4;\nexport const JS_PROP_GETSET = 1 << 4;\nexport const JS_PROP_VARREF = 2 << 4; /* used internally */\nexport const JS_PROP_AUTOINIT = 3 << 4; /* used internally */\n\n/* flags for JS_DefineProperty */\nexport const JS_PROP_HAS_SHIFT = 8;\nexport const JS_PROP_HAS_CONFIGURABLE = 1 << 8;\nexport const JS_PROP_HAS_WRITABLE = 1 << 9;\nexport const JS_PROP_HAS_ENUMERABLE = 1 << 10;\nexport const JS_PROP_HAS_GET = 1 << 11;\nexport const JS_PROP_HAS_SET = 1 << 12;\nexport const JS_PROP_HAS_VALUE = 1 << 13;\n/* throw an exception if false would be returned (JS_DefineProperty/JS_SetProperty) */\nexport const JS_PROP_THROW = 1 << 14;\n/* throw an exception if false would be returned in strict mode */\nexport const JS_PROP_THROW_STRICT = 1 << 15;\nexport const JS_PROP_NO_ADD = 1 << 16; /* internal use */\nexport const JS_PROP_NO_EXOTIC = 1 << 17; /* internal use */\nexport const JS_PROP_DEFINE_PROPERTY = 1 << 18; /* internal use */\nexport const JS_PROP_REFLECT_DEFINE_PROPERTY = 1 << 19; /* internal use */\n\n/* JS_GetOwnPropertyNames flags */\nexport const JS_GPN_STRING_MASK = 1 << 0;\nexport const JS_GPN_SYMBOL_MASK = 1 << 1;\nexport const JS_GPN_PRIVATE_MASK = 1 << 2;\nexport const JS_GPN_ENUM_ONLY = 1 << 4;\nexport const JS_GPN_SET_ENUM = 1 << 5;\n\n/* JS_Eval flags */\nexport const JS_EVAL_TYPE_GLOBAL = 0 << 0;\nexport const JS_EVAL_TYPE_MODULE = 1 << 0;\nexport const JS_EVAL_TYPE_DIRECT = 2 << 0;\nexport const JS_EVAL_TYPE_INDIRECT = 3 << 0;\nexport const JS_EVAL_TYPE_MASK = 3 << 0;\nexport const JS_EVAL_FLAG_STRICT = 1 << 3;\nexport const JS_EVAL_FLAG_COMPILE_ONLY = 1 << 5;\nexport const JS_EVAL_FLAG_BACKTRACE_BARRIER = 1 << 6;\nexport const JS_EVAL_FLAG_ASYNC = 1 << 7;\n/* strip TypeScript's erasable syntax before compiling (Node's strip-only mode, see docs/TYPESCRIPT.md) */\nexport const JS_EVAL_FLAG_STRIP_TYPES = 1 << 8;\n/* compile JSX (see docs/JSX.md); with JS_EVAL_FLAG_STRIP_TYPES, TSX */\nexport const JS_EVAL_FLAG_JSX = 1 << 9;\n\n/* JS_CallInternal flags */\nexport const JS_CALL_FLAG_CONSTRUCTOR = 1 << 0;\nexport const JS_CALL_FLAG_COPY_ARGV = 1 << 1;\nexport const JS_CALL_FLAG_GENERATOR = 1 << 2;\n\nexport const JS_MODE_STRICT = 1 << 0;\nexport const JS_MODE_ASYNC = 1 << 2; /* async function */\nexport const JS_MODE_BACKTRACE_BARRIER = 1 << 3;\n\nexport const enum JSFunctionKind {\n NORMAL = 0,\n GENERATOR = 1 << 0,\n ASYNC = 1 << 1,\n ASYNC_GENERATOR = (1 << 0) | (1 << 1),\n}\n\nexport const enum JSVarKind {\n NORMAL,\n FUNCTION_DECL, /* lexical var with function declaration */\n NEW_FUNCTION_DECL, /* lexical var with async/generator function declaration */\n CATCH,\n FUNCTION_NAME, /* function expression name */\n PRIVATE_FIELD,\n PRIVATE_METHOD,\n PRIVATE_GETTER,\n PRIVATE_SETTER,\n PRIVATE_GETTER_SETTER,\n}\n\nexport const enum JSErrorEnum {\n EVAL_ERROR,\n RANGE_ERROR,\n REFERENCE_ERROR,\n SYNTAX_ERROR,\n TYPE_ERROR,\n URI_ERROR,\n INTERNAL_ERROR,\n AGGREGATE_ERROR,\n NATIVE_ERROR_COUNT,\n PLAIN_ERROR = NATIVE_ERROR_COUNT,\n}\n\nexport class JSVarDef {\n var_name: JSAtom;\n scope_level = 0;\n scope_next = 0;\n is_const = false;\n is_lexical = false;\n is_captured = false;\n is_static_private = false;\n var_kind: JSVarKind = JSVarKind.NORMAL;\n func_pool_idx = -1;\n constructor(var_name: JSAtom) { this.var_name = var_name; }\n}\n\nexport class JSClosureVar {\n is_local = false;\n is_arg = false;\n is_const = false;\n is_lexical = false;\n var_kind: JSVarKind = JSVarKind.NORMAL;\n var_idx = 0;\n var_name: JSAtom = 0;\n}\n\nexport class JSFunctionBytecode {\n js_mode = 0;\n has_prototype = false;\n has_simple_parameter_list = true;\n is_derived_class_constructor = false;\n need_home_object = false;\n func_kind: JSFunctionKind = JSFunctionKind.NORMAL;\n new_target_allowed = false;\n super_call_allowed = false;\n super_allowed = false;\n arguments_allowed = false;\n has_debug = false;\n is_direct_or_indirect_eval = false;\n byte_code_buf: Uint8Array = new Uint8Array(0);\n byte_code_len = 0;\n func_name: JSAtom = 0;\n vardefs: JSVarDef[] = []; /* arguments + local variables */\n closure_var: JSClosureVar[] = [];\n arg_count = 0;\n var_count = 0;\n defined_arg_count = 0;\n stack_size = 0;\n realm: any = null; /* JSContext */\n cpool: (JSValue | JSFunctionBytecode)[] = [];\n debug = { filename: 0 as JSAtom, source: null as string | null, pc2line: null as Uint8Array | null, source_len: 0 };\n /* compiled tier (src/jit.ts) */\n call_count = 0;\n no_jit = false; /* set when the compiler bailed on this function */\n compiled: any = null; /* JitCompiled (natural convention): see src/jit.ts */\n compiled_ctor: any = null; /* JitCompiled (explicit convention) for constructs through wrappers; false: the compiler bailed */\n /* factory of this function's retargetable wrappers (src/jit_runtime.ts), generated on its\n first closure: one copy of the wrapper code per function keeps the call site inside it\n monomorphic */\n wrapper_factory: any = null;\n /* lazily computed: the body reads `arguments` or a rest parameter (-1: unknown) */\n uses_args = -1;\n /* on-stack replacement (src/jit.ts): back-edges taken by interpreter frames, and the compiled\n OSR variants by loop header pc (null: the compiler bailed for that header) */\n loop_count = 0;\n osr: Map<number, any> | null = null;\n /* the module this function belongs to (its body or a function nested in it), or null */\n module: JSModuleDef | null = null;\n}\n\n/* A variable reference: aliases a stack slot while the frame is alive,\n then owns the value once the frame exits (detached). */\nexport class JSVarRef {\n is_detached = false;\n frame: JSStackFrame | null;\n is_arg: boolean;\n var_idx: number;\n value: JSValue = undefined; /* used when detached */\n constructor(frame: JSStackFrame | null, is_arg: boolean, var_idx: number) {\n this.frame = frame; this.is_arg = is_arg; this.var_idx = var_idx;\n }\n get(): JSValue {\n if (this.is_detached) return this.value;\n const f = this.frame!;\n return this.is_arg ? f.arg_buf[this.var_idx] : f.var_buf[this.var_idx];\n }\n set(v: JSValue): void {\n if (this.is_detached) { this.value = v; return; }\n const f = this.frame!;\n if (this.is_arg) f.arg_buf[this.var_idx] = v; else f.var_buf[this.var_idx] = v;\n }\n detach(): void {\n if (!this.is_detached) {\n this.value = this.get();\n this.is_detached = true;\n this.frame = null;\n }\n }\n}\n\n/* a detached variable reference holding 'value' (used by compiled functions\n for captured locals) */\nexport function new_var_ref_cell(value: JSValue): JSVarRef {\n const vr = new JSVarRef(null, false, 0);\n vr.is_detached = true;\n vr.value = value;\n return vr;\n}\n\n/* shared empty buffer: frames of C functions never write to their buffers,\n so a single frozen array avoids 4 allocations per call */\nexport const EMPTY_BUF: JSValue[] = Object.freeze([]) as unknown as JSValue[];\n\nexport const EMPTY_VAR_REFS: JSVarRef[] = Object.freeze([]) as unknown as JSVarRef[];\n\nexport class JSStackFrame {\n prev_frame: JSStackFrame | null = null;\n cur_func: JSValue = undefined; /* current function, JS_UNDEFINED if the frame is detached */\n arg_buf: JSValue[] = EMPTY_BUF;\n var_buf: JSValue[] = EMPTY_BUF;\n stack_buf: JSValue[] = EMPTY_BUF;\n sp = 0;\n cur_pc = 0;\n arg_count = 0;\n js_mode = 0;\n cur_sp = -1; /* only used in generators */\n var_refs: JSVarRef[] = EMPTY_VAR_REFS; /* var refs created in this frame (to detach on exit); replaced on first use */\n this_obj: JSValue = undefined;\n new_target: JSValue = undefined;\n /* the rest of this frame runs in compiled code (on-stack replacement): backtraces show the\n compiled frame instead of this one */\n osr = false;\n}\n\nexport const enum JSGeneratorState {\n SUSPENDED_START,\n SUSPENDED_YIELD,\n SUSPENDED_YIELD_STAR,\n EXECUTING,\n COMPLETED,\n}\n\nexport class JSAsyncFunctionState {\n this_val: JSValue = undefined;\n argc = 0;\n throw_flag = false;\n is_completed = false;\n frame: JSStackFrame = new JSStackFrame();\n func_obj: JSValue = undefined;\n /* for async functions */\n resolving_funcs: [JSValue, JSValue] = [undefined, undefined];\n promise: JSValue = undefined;\n}\n\nexport class JSGeneratorData {\n state: JSGeneratorState = JSGeneratorState.SUSPENDED_START;\n func_state: JSAsyncFunctionState | null = null;\n}\n\n/* bound function metadata (the object itself is a host bound function) */\nexport class JSBoundFunctionData {\n func_obj: JSObject;\n this_val: JSValue;\n argv: JSValue[];\n constructor(func_obj: JSObject, this_val: JSValue, argv: JSValue[]) {\n this.func_obj = func_obj; this.this_val = this_val; this.argv = argv;\n }\n}\n\nexport type JSCFunction = (ctx: any, this_val: JSValue, argv: JSValue[]) => JSValue;\nexport type JSCFunctionMagic = (ctx: any, this_val: JSValue, argv: JSValue[], magic: number) => JSValue;\nexport type JSCFunctionData = (ctx: any, this_val: JSValue, argv: JSValue[], magic: number, data: JSValue[]) => JSValue;\nexport type JSCFunctionConstructor = (ctx: any, new_target: JSValue, argv: JSValue[]) => JSValue;\nexport type JSCFunctionConstructorMagic = (ctx: any, new_target: JSValue, argv: JSValue[], magic: number) => JSValue;\n\nexport const enum JSCFunctionEnum {\n generic,\n generic_magic,\n constructor,\n constructor_magic,\n constructor_or_func,\n constructor_or_func_magic,\n f_f,\n f_f_f,\n getter,\n setter,\n getter_magic,\n setter_magic,\n iterator_next,\n}\n\nexport class JSCFunctionRecord {\n func: Function;\n length: number;\n cproto: JSCFunctionEnum;\n magic: number;\n constructor(func: Function, length: number, cproto: JSCFunctionEnum, magic: number) {\n this.func = func; this.length = length; this.cproto = cproto; this.magic = magic;\n }\n}\n\nexport class JSCFunctionDataRecord {\n func: JSCFunctionData;\n length: number;\n magic: number;\n data: JSValue[];\n constructor(func: JSCFunctionData, length: number, magic: number, data: JSValue[]) {\n this.func = func; this.length = length; this.magic = magic; this.data = data;\n }\n}\n\n/* for-in enumeration state: snapshot of the enumerable keys */\nexport class JSForInState {\n obj: JSValue = undefined;\n idx = 0;\n keys: (string | number)[] = [];\n own_count = 0; /* number of keys of 'obj' itself at the start of 'keys' */\n}\n\nexport class JSMapRecord {\n key: JSValue;\n value: JSValue;\n empty = false; /* true if the record was deleted */\n constructor(key: JSValue, value: JSValue) { this.key = key; this.value = value; }\n}\n\nexport class JSMapState {\n is_weak: boolean;\n /* records in insertion order; deleted records are marked empty and\n purged lazily when there are no active iterators */\n records: JSMapRecord[] = [];\n map = new Map<unknown, JSMapRecord>(); /* normalized key -> record */\n weak: WeakMap<object, JSMapRecord> | null = null;\n record_count = 0;\n iterator_count = 0;\n constructor(is_weak: boolean) {\n this.is_weak = is_weak;\n if (is_weak) this.weak = new WeakMap();\n }\n}\n\nexport class JSMapIteratorData {\n obj: JSValue;\n kind: number;\n idx = 0;\n constructor(obj: JSValue, kind: number) { this.obj = obj; this.kind = kind; }\n}\n\nexport class JSArrayIteratorData {\n obj: JSValue;\n kind: number;\n idx = 0;\n constructor(obj: JSValue, kind: number) { this.obj = obj; this.kind = kind; }\n}\n\nexport class JSRegExpStringIteratorData {\n iterating_regexp: JSValue;\n iterated_string: JSValue;\n global: boolean;\n unicode: boolean;\n done = false;\n constructor(re: JSValue, str: JSValue, global: boolean, unicode: boolean) {\n this.iterating_regexp = re; this.iterated_string = str; this.global = global; this.unicode = unicode;\n }\n}\n\nexport const enum JSPromiseState {\n PENDING,\n FULFILLED,\n REJECTED,\n}\n\nexport class JSPromiseReactionData {\n resolving_funcs: [JSValue, JSValue];\n handler: JSValue;\n constructor(resolving_funcs: [JSValue, JSValue], handler: JSValue) {\n this.resolving_funcs = resolving_funcs; this.handler = handler;\n }\n}\n\nexport class JSPromiseData {\n promise_state: JSPromiseState = JSPromiseState.PENDING;\n is_handled = false;\n promise_reactions: [JSPromiseReactionData[], JSPromiseReactionData[]] = [[], []];\n promise_result: JSValue = undefined;\n}\n\nexport class JSPromiseFunctionData {\n promise: JSValue;\n presolved: { already_resolved: boolean };\n constructor(promise: JSValue, presolved: { already_resolved: boolean }) {\n this.promise = promise; this.presolved = presolved;\n }\n}\n\nexport class JSProxyData {\n host_revoke: (() => void) | null = null;\n target: JSValue;\n handler: JSValue;\n is_func: boolean;\n is_revoked = false;\n constructor(target: JSValue, handler: JSValue, is_func: boolean) {\n this.target = target; this.handler = handler; this.is_func = is_func;\n }\n}\n\nexport class JSRegExp {\n pattern: string;\n flags: string;\n /* host regexp used as the matching engine */\n re: RegExp;\n constructor(pattern: string, flags: string, re: RegExp) {\n this.pattern = pattern; this.flags = flags; this.re = re;\n }\n}\n\n/* ArrayBuffer metadata: the guest object is the host ArrayBuffer itself */\nexport class JSArrayBuffer {\n buffer: ArrayBuffer | SharedArrayBuffer;\n data: Uint8Array; /* view over the whole buffer (empty when detached) */\n detached = false;\n shared: boolean;\n constructor(buffer: ArrayBuffer | SharedArrayBuffer, shared = false) {\n this.buffer = buffer;\n this.data = new Uint8Array(buffer as ArrayBuffer);\n this.shared = shared;\n }\n get byteLength(): number { return this.detached ? 0 : this.buffer.byteLength; }\n}\n\n/* typed array metadata: the guest object is the host typed array itself */\nexport class JSTypedArray {\n buffer: JSObject; /* guest ArrayBuffer object */\n offset: number;\n length: number; /* in bytes */\n track_rab = false;\n constructor(buffer: JSObject, offset: number, length: number) {\n this.buffer = buffer; this.offset = offset; this.length = length;\n }\n}\n\n/* function with closure variables */\nexport class JSFunctionData {\n function_bytecode: JSFunctionBytecode;\n var_refs: JSVarRef[];\n home_object: JSObject | null = null;\n /* compiled tier (see src/jit.ts and docs/JIT.md \"Tiering\"):\n compiled: the direct entry `(this, new_target, ...args)` of this closure, once compiled;\n priv: a private callable with the host convention and the host Function.prototype\n (never reachable from guest code): `priv.apply(this, args)` is the fast way for\n the engine and for retargetable wrappers to call the compiled body;\n mkpriv: creates `priv` on demand (closures created by compiled code);\n ctor: the explicit-convention body `(this | undefined, new_target, ...args)` used for\n construct calls through a retargetable wrapper (compiled on the first one). */\n compiled: Function | null = null;\n priv: Function | null = null;\n mkpriv: (() => Function) | null = null;\n ctor: Function | null = null;\n constructor(b: JSFunctionBytecode, var_refs: JSVarRef[]) {\n this.function_bytecode = b; this.var_refs = var_refs;\n }\n}\n\n/* engine metadata attached to guest objects that need it (JSRuntime.meta) */\nexport class JSObjectMeta {\n class_id: JSClassID;\n /* class specific data (the \"union\" of JSObject in quickjs.c) */\n u: any = null;\n /* bytecode function data */\n func: JSFunctionData | null = null;\n /* C function data */\n cfunc: JSCFunctionRecord | null = null;\n realm: any = null; /* JSContext of C functions */\n is_constructor = false;\n is_class = false;\n is_uncatchable_error = false;\n /* true once the QuickJS backtrace has been added to an error object */\n has_backtrace = false;\n constructor(class_id: JSClassID) { this.class_id = class_id; }\n}\n\nexport function JS_VALUE_GET_OBJ(v: JSValue): JSObject { return v as JSObject; }\nexport function JS_VALUE_GET_INT(v: JSValue): number { return v as number; }\nexport function JS_VALUE_GET_FLOAT64(v: JSValue): number { return v as number; }\nexport function JS_VALUE_GET_BOOL(v: JSValue): boolean { return v as boolean; }\nexport function JS_VALUE_GET_STRING(v: JSValue): string { return v as string; }\n\nexport function js_mkval_bool(v: boolean): JSValue { return v; }\n\n/* ---------------------------------------------------------------------\n Modules (quickjs.c JSModuleDef and its entries)\n --------------------------------------------------------------------- */\n\nexport const enum JSModuleStatus {\n UNLINKED,\n LINKING,\n LINKED,\n EVALUATING,\n EVALUATING_ASYNC,\n EVALUATED,\n}\n\n/* a module request: `from \"x\"` (with its import attributes) */\nexport class JSReqModuleEntry {\n module: JSModuleDef | null = null; /* set when the graph is loaded */\n constructor(public module_name: JSAtom, public attributes: Record<string, string> | null) {}\n}\n\nexport const enum JSExportType { LOCAL, INDIRECT }\n\nexport class JSExportEntry {\n export_type: JSExportType;\n /* LOCAL: closure variable index in the module function, and its reference once created */\n var_idx = -1;\n var_ref: JSVarRef | null = null;\n /* INDIRECT: the module request it comes from */\n req_module_idx = -1;\n /* LOCAL: the local name; INDIRECT: the imported name, '*' for `export * as ns from` */\n local_name: JSAtom;\n export_name: JSAtom;\n constructor(local_name: JSAtom, export_name: JSAtom, export_type: JSExportType) {\n this.local_name = local_name; this.export_name = export_name; this.export_type = export_type;\n }\n}\n\nexport class JSStarExportEntry {\n constructor(public req_module_idx: number) {}\n}\n\nexport class JSImportEntry {\n req_module_idx = -1;\n constructor(public var_idx: number, public is_star: boolean, public import_name: JSAtom) {}\n}\n\n/* what the module source is: JavaScript, JSON or host values provided by the embedder */\nexport const enum JSModuleKind { JS, JSON, HOST }\n\nexport class JSModuleDef {\n module_name: JSAtom; /* the normalized id */\n url: string | null = null; /* import.meta.url (defaults to the id) */\n kind: JSModuleKind = JSModuleKind.JS;\n req_module_entries: JSReqModuleEntry[] = [];\n export_entries: JSExportEntry[] = [];\n star_export_entries: JSStarExportEntry[] = [];\n import_entries: JSImportEntry[] = [];\n has_tla = false;\n status: JSModuleStatus = JSModuleStatus.UNLINKED;\n /* temporary, during linking and evaluation */\n dfs_index = 0;\n dfs_ancestor_index = 0;\n stack_prev: JSModuleDef | null = null;\n /* asynchronous evaluation (top-level await) */\n async_parent_modules: JSModuleDef[] = [];\n pending_async_dependencies = 0;\n async_evaluation = false;\n async_evaluation_timestamp = 0;\n cycle_root: JSModuleDef | null = null;\n promise: JSValue = undefined; /* capability of the evaluation */\n resolving_funcs: [JSValue, JSValue] = [undefined, undefined];\n eval_has_exception = false;\n eval_exception: JSValue = undefined;\n meta_obj: JSValue = undefined;\n module_ns: JSValue = undefined;\n func_bytecode: JSFunctionBytecode | null = null; /* JS: the module body */\n func_obj: JSValue = undefined; /* JS: the function object, once created */\n func_created = false;\n /* JSON and host modules: the value of each export, set at evaluation */\n synthetic_exports: Map<JSAtom, JSValue> | null = null;\n /* graph loading: true once every request has a module */\n requests_loaded = false;\n realm: any = null; /* JSContext */\n constructor(module_name: JSAtom) { this.module_name = module_name; }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"values.js","sourceRoot":"","sources":["../src/values.ts"],"names":[],"mappings":"AA4BA,MAAM,OAAO,SAAS;IACD;IAAmB;IAAtC,YAAmB,GAAU,EAAS,CAAS;QAA5B,QAAG,GAAH,GAAG,CAAO;QAAS,MAAC,GAAD,CAAC,CAAQ;IAAG,CAAC;CACpD;AAED,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,SAAS,8BAAsB,CAAC,CAAC,CAAC;AACtE,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,SAAS,0BAAkB,CAAC,CAAC,CAAC;AAC9D,MAAM,CAAC,MAAM,YAAY,GAAG,SAAS,CAAC;AACtC,MAAM,CAAC,MAAM,OAAO,GAAG,IAAI,CAAC;AAC5B,MAAM,CAAC,MAAM,OAAO,GAAG,IAAI,CAAC;AAC5B,MAAM,CAAC,MAAM,QAAQ,GAAG,KAAK,CAAC;AAkB9B,6DAA6D;AAC7D,MAAM,gBAAgB,GAAgB,EAAE,CAAC;AACzC,MAAM,UAAU,iBAAiB,CAAC,CAAS;IACzC,IAAI,CAAC,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAAC;IAC5B,IAAI,CAAC,KAAK,SAAS,EAAE,CAAC;QACpB,CAAC,GAAG,IAAI,SAAS,6BAAqB,CAAC,CAAC,CAAC;QACzC,IAAI,CAAC,GAAG,IAAI;YAAE,gBAAgB,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACxC,CAAC;IACD,OAAO,CAAC,CAAC;AACX,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,CAAU;IACzC,QAAQ,OAAO,CAAC,EAAE,CAAC;QACjB,KAAK,WAAW,CAAC,CAAC,+BAAuB;QACzC,KAAK,SAAS,CAAC,CAAC,0BAAkB;QAClC,KAAK,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ACzD,eAAe,GAAG,KAAK,CAAC;IACxB,KAAK,GAAQ,IAAI,CAAC,CAAC,eAAe;IAClC,YAAY,WAAmB,IAAI,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC,CAAC,CAAC;CACrE","sourcesContent":["/*\n * Value and object representation (host-values model, see docs/HOST_VALUES.md).\n *\n * Primitive JS values are the host primitives (undefined, null, boolean,\n * number, string, bigint, symbol). Guest objects are host objects whose\n * prototype chains are entirely guest-owned; engine metadata for the\n * objects that need it (class id, internal slots, bytecode) lives in a\n * WeakMap (JSRuntime.meta). The special QuickJS tags (uninitialized,\n * exception, catch offset) are JSSpecial instances that never escape to\n * guest code.\n */\nimport { JSAtom } from './atoms.ts';\n\nexport const enum JSTag {\n UNINITIALIZED = 0,\n INT = 1,\n BOOL = 2,\n NULL = 3,\n UNDEFINED = 4,\n CATCH_OFFSET = 5,\n EXCEPTION = 6,\n FLOAT64 = 7,\n BIG_INT = 8,\n STRING = 9,\n SYMBOL = 10,\n OBJECT = 11,\n}\n\nexport class JSSpecial {\n constructor(public tag: JSTag, public v: number) {}\n}\n\nexport const JS_UNINITIALIZED = new JSSpecial(JSTag.UNINITIALIZED, 0);\nexport const JS_EXCEPTION = new JSSpecial(JSTag.EXCEPTION, 0);\nexport const JS_UNDEFINED = undefined;\nexport const JS_NULL = null;\nexport const JS_TRUE = true;\nexport const JS_FALSE = false;\n\n/* a guest object is any host object (or function) */\nexport type JSObject = object;\n\nexport type JSValue =\n | undefined\n | null\n | boolean\n | number\n | string\n | bigint\n | symbol\n | JSObject\n | JSSpecial;\n\nexport type JSValueConst = JSValue;\n\n/* catch offsets are stored on the stack; cache small ones */\nconst catchOffsetCache: JSSpecial[] = [];\nexport function JS_NewCatchOffset(v: number): JSSpecial {\n let r = catchOffsetCache[v];\n if (r === undefined) {\n r = new JSSpecial(JSTag.CATCH_OFFSET, v);\n if (v < 1024) catchOffsetCache[v] = r;\n }\n return r;\n}\n\nexport function JS_VALUE_GET_TAG(v: JSValue): JSTag {\n switch (typeof v) {\n case 'undefined': return JSTag.UNDEFINED;\n case 'boolean': return JSTag.BOOL;\n case 'number': return Number.isInteger(v) && v >= -2147483648 && v <= 2147483647 && !(v === 0 && 1 / v < 0) ? JSTag.INT : JSTag.FLOAT64;\n case 'string': return JSTag.STRING;\n case 'bigint': return JSTag.BIG_INT;\n case 'symbol': return JSTag.SYMBOL;\n case 'function': return JSTag.OBJECT;\n case 'object':\n if (v === null) return JSTag.NULL;\n if (v instanceof JSSpecial) return v.tag;\n return JSTag.OBJECT;\n }\n return JSTag.UNDEFINED;\n}\n\nexport function JS_IsException(v: JSValue): v is JSSpecial { return v === JS_EXCEPTION; }\nexport function JS_IsUninitialized(v: JSValue): boolean { return v === JS_UNINITIALIZED; }\nexport function JS_IsUndefined(v: JSValue): v is undefined { return v === undefined; }\nexport function JS_IsNull(v: JSValue): v is null { return v === null; }\n/* true for guest objects (including functions); the internal sentinels are excluded */\nexport function JS_IsObject(v: JSValue): v is JSObject {\n const t = typeof v;\n if (t === 'object') return v !== null && !(v instanceof JSSpecial);\n return t === 'function';\n}\nexport function JS_IsString(v: JSValue): v is string { return typeof v === 'string'; }\nexport function JS_IsSymbol(v: JSValue): v is symbol { return typeof v === 'symbol'; }\nexport function JS_IsNumber(v: JSValue): v is number { return typeof v === 'number'; }\nexport function JS_IsBigInt(v: JSValue): v is bigint { return typeof v === 'bigint'; }\nexport function JS_IsBool(v: JSValue): v is boolean { return typeof v === 'boolean'; }\nexport function JS_IsCatchOffset(v: JSValue): v is JSSpecial {\n return v instanceof JSSpecial && v.tag === JSTag.CATCH_OFFSET;\n}\n\n/* class ids (same order as quickjs.c) */\nexport const enum JSClassID {\n OBJECT = 1,\n ARRAY,\n ERROR,\n NUMBER,\n STRING,\n BOOLEAN,\n SYMBOL,\n ARGUMENTS,\n MAPPED_ARGUMENTS,\n DATE,\n MODULE_NS,\n C_FUNCTION,\n BYTECODE_FUNCTION,\n BOUND_FUNCTION,\n C_FUNCTION_DATA,\n GENERATOR_FUNCTION,\n FOR_IN_ITERATOR,\n REGEXP,\n ARRAY_BUFFER,\n SHARED_ARRAY_BUFFER,\n UINT8C_ARRAY,\n INT8_ARRAY,\n UINT8_ARRAY,\n INT16_ARRAY,\n UINT16_ARRAY,\n INT32_ARRAY,\n UINT32_ARRAY,\n BIG_INT64_ARRAY,\n BIG_UINT64_ARRAY,\n FLOAT16_ARRAY,\n FLOAT32_ARRAY,\n FLOAT64_ARRAY,\n DATAVIEW,\n BIG_INT,\n MAP,\n SET,\n WEAKMAP,\n WEAKSET,\n MAP_ITERATOR,\n SET_ITERATOR,\n ARRAY_ITERATOR,\n STRING_ITERATOR,\n REGEXP_STRING_ITERATOR,\n GENERATOR,\n PROXY,\n PROMISE,\n PROMISE_RESOLVE_FUNCTION,\n PROMISE_REJECT_FUNCTION,\n ASYNC_FUNCTION,\n ASYNC_FUNCTION_RESOLVE,\n ASYNC_FUNCTION_REJECT,\n ASYNC_FROM_SYNC_ITERATOR,\n ASYNC_GENERATOR_FUNCTION,\n ASYNC_GENERATOR,\n WEAK_REF,\n FINALIZATION_REGISTRY,\n /* QuickJS 2026-06-04 (appended: the ids above keep their values) */\n ITERATOR,\n ITERATOR_HELPER,\n ITERATOR_WRAP,\n INIT_COUNT,\n}\n\n/* property flags */\nexport const JS_PROP_CONFIGURABLE = 1 << 0;\nexport const JS_PROP_WRITABLE = 1 << 1;\nexport const JS_PROP_ENUMERABLE = 1 << 2;\nexport const JS_PROP_C_W_E = JS_PROP_CONFIGURABLE | JS_PROP_WRITABLE | JS_PROP_ENUMERABLE;\nexport const JS_PROP_LENGTH = 1 << 3; /* used internally in Arrays */\nexport const JS_PROP_TMASK = 3 << 4;\nexport const JS_PROP_NORMAL = 0 << 4;\nexport const JS_PROP_GETSET = 1 << 4;\nexport const JS_PROP_VARREF = 2 << 4; /* used internally */\nexport const JS_PROP_AUTOINIT = 3 << 4; /* used internally */\n\n/* flags for JS_DefineProperty */\nexport const JS_PROP_HAS_SHIFT = 8;\nexport const JS_PROP_HAS_CONFIGURABLE = 1 << 8;\nexport const JS_PROP_HAS_WRITABLE = 1 << 9;\nexport const JS_PROP_HAS_ENUMERABLE = 1 << 10;\nexport const JS_PROP_HAS_GET = 1 << 11;\nexport const JS_PROP_HAS_SET = 1 << 12;\nexport const JS_PROP_HAS_VALUE = 1 << 13;\n/* throw an exception if false would be returned (JS_DefineProperty/JS_SetProperty) */\nexport const JS_PROP_THROW = 1 << 14;\n/* throw an exception if false would be returned in strict mode */\nexport const JS_PROP_THROW_STRICT = 1 << 15;\nexport const JS_PROP_NO_ADD = 1 << 16; /* internal use */\nexport const JS_PROP_NO_EXOTIC = 1 << 17; /* internal use */\nexport const JS_PROP_DEFINE_PROPERTY = 1 << 18; /* internal use */\nexport const JS_PROP_REFLECT_DEFINE_PROPERTY = 1 << 19; /* internal use */\n\n/* JS_GetOwnPropertyNames flags */\nexport const JS_GPN_STRING_MASK = 1 << 0;\nexport const JS_GPN_SYMBOL_MASK = 1 << 1;\nexport const JS_GPN_PRIVATE_MASK = 1 << 2;\nexport const JS_GPN_ENUM_ONLY = 1 << 4;\nexport const JS_GPN_SET_ENUM = 1 << 5;\n\n/* JS_Eval flags */\nexport const JS_EVAL_TYPE_GLOBAL = 0 << 0;\nexport const JS_EVAL_TYPE_MODULE = 1 << 0;\nexport const JS_EVAL_TYPE_DIRECT = 2 << 0;\nexport const JS_EVAL_TYPE_INDIRECT = 3 << 0;\nexport const JS_EVAL_TYPE_MASK = 3 << 0;\nexport const JS_EVAL_FLAG_STRICT = 1 << 3;\nexport const JS_EVAL_FLAG_COMPILE_ONLY = 1 << 5;\nexport const JS_EVAL_FLAG_BACKTRACE_BARRIER = 1 << 6;\nexport const JS_EVAL_FLAG_ASYNC = 1 << 7;\n/* strip TypeScript's erasable syntax before compiling (Node's strip-only mode, see docs/TYPESCRIPT.md) */\nexport const JS_EVAL_FLAG_STRIP_TYPES = 1 << 8;\n/* compile JSX (see docs/JSX.md); with JS_EVAL_FLAG_STRIP_TYPES, TSX */\nexport const JS_EVAL_FLAG_JSX = 1 << 9;\n\n/* JS_CallInternal flags */\nexport const JS_CALL_FLAG_CONSTRUCTOR = 1 << 0;\nexport const JS_CALL_FLAG_COPY_ARGV = 1 << 1;\nexport const JS_CALL_FLAG_GENERATOR = 1 << 2;\n\nexport const JS_MODE_STRICT = 1 << 0;\nexport const JS_MODE_ASYNC = 1 << 2; /* async function */\nexport const JS_MODE_BACKTRACE_BARRIER = 1 << 3;\n\nexport const enum JSFunctionKind {\n NORMAL = 0,\n GENERATOR = 1 << 0,\n ASYNC = 1 << 1,\n ASYNC_GENERATOR = (1 << 0) | (1 << 1),\n}\n\nexport const enum JSVarKind {\n NORMAL,\n FUNCTION_DECL, /* lexical var with function declaration */\n NEW_FUNCTION_DECL, /* lexical var with async/generator function declaration */\n CATCH,\n FUNCTION_NAME, /* function expression name */\n PRIVATE_FIELD,\n PRIVATE_METHOD,\n PRIVATE_GETTER,\n PRIVATE_SETTER,\n PRIVATE_GETTER_SETTER,\n}\n\nexport const enum JSErrorEnum {\n EVAL_ERROR,\n RANGE_ERROR,\n REFERENCE_ERROR,\n SYNTAX_ERROR,\n TYPE_ERROR,\n URI_ERROR,\n INTERNAL_ERROR,\n AGGREGATE_ERROR,\n NATIVE_ERROR_COUNT,\n PLAIN_ERROR = NATIVE_ERROR_COUNT,\n}\n\nexport class JSVarDef {\n var_name: JSAtom;\n scope_level = 0;\n scope_next = 0;\n is_const = false;\n is_lexical = false;\n is_captured = false;\n is_static_private = false;\n var_kind: JSVarKind = JSVarKind.NORMAL;\n func_pool_idx = -1;\n constructor(var_name: JSAtom) { this.var_name = var_name; }\n}\n\nexport class JSClosureVar {\n is_local = false;\n is_arg = false;\n is_const = false;\n is_lexical = false;\n var_kind: JSVarKind = JSVarKind.NORMAL;\n var_idx = 0;\n var_name: JSAtom = 0;\n}\n\nexport class JSFunctionBytecode {\n js_mode = 0;\n has_prototype = false;\n has_simple_parameter_list = true;\n is_derived_class_constructor = false;\n need_home_object = false;\n func_kind: JSFunctionKind = JSFunctionKind.NORMAL;\n new_target_allowed = false;\n super_call_allowed = false;\n super_allowed = false;\n arguments_allowed = false;\n has_debug = false;\n is_direct_or_indirect_eval = false;\n byte_code_buf: Uint8Array = new Uint8Array(0);\n byte_code_len = 0;\n func_name: JSAtom = 0;\n vardefs: JSVarDef[] = []; /* arguments + local variables */\n closure_var: JSClosureVar[] = [];\n arg_count = 0;\n var_count = 0;\n defined_arg_count = 0;\n stack_size = 0;\n realm: any = null; /* JSContext */\n cpool: (JSValue | JSFunctionBytecode)[] = [];\n debug = { filename: 0 as JSAtom, source: null as string | null, pc2line: null as Uint8Array | null, source_len: 0 };\n /* compiled tier (src/jit.ts) */\n call_count = 0;\n no_jit = false; /* set when the compiler bailed on this function */\n compiled: any = null; /* JitCompiled (natural convention): see src/jit.ts */\n compiled_ctor: any = null; /* JitCompiled (explicit convention) for constructs through wrappers; false: the compiler bailed */\n /* factory of this function's retargetable wrappers (src/jit_runtime.ts), generated on its\n first closure: one copy of the wrapper code per function keeps the call site inside it\n monomorphic */\n wrapper_factory: any = null;\n /* lazily computed: the body reads `arguments` or a rest parameter (-1: unknown) */\n uses_args = -1;\n /* on-stack replacement (src/jit.ts): back-edges taken by interpreter frames, and the compiled\n OSR variants by loop header pc (null: the compiler bailed for that header) */\n loop_count = 0;\n osr: Map<number, any> | null = null;\n /* the module this function belongs to (its body or a function nested in it), or null */\n module: JSModuleDef | null = null;\n}\n\n/* A variable reference: aliases a stack slot while the frame is alive,\n then owns the value once the frame exits (detached). */\nexport class JSVarRef {\n is_detached = false;\n frame: JSStackFrame | null;\n is_arg: boolean;\n var_idx: number;\n value: JSValue = undefined; /* used when detached */\n constructor(frame: JSStackFrame | null, is_arg: boolean, var_idx: number) {\n this.frame = frame; this.is_arg = is_arg; this.var_idx = var_idx;\n }\n get(): JSValue {\n if (this.is_detached) return this.value;\n const f = this.frame!;\n return this.is_arg ? f.arg_buf[this.var_idx] : f.var_buf[this.var_idx];\n }\n set(v: JSValue): void {\n if (this.is_detached) { this.value = v; return; }\n const f = this.frame!;\n if (this.is_arg) f.arg_buf[this.var_idx] = v; else f.var_buf[this.var_idx] = v;\n }\n detach(): void {\n if (!this.is_detached) {\n this.value = this.get();\n this.is_detached = true;\n this.frame = null;\n }\n }\n}\n\n/* a detached variable reference holding 'value' (used by compiled functions\n for captured locals) */\nexport function new_var_ref_cell(value: JSValue): JSVarRef {\n const vr = new JSVarRef(null, false, 0);\n vr.is_detached = true;\n vr.value = value;\n return vr;\n}\n\n/* shared empty buffer: frames of C functions never write to their buffers,\n so a single frozen array avoids 4 allocations per call */\nexport const EMPTY_BUF: JSValue[] = Object.freeze([]) as unknown as JSValue[];\n\nexport const EMPTY_VAR_REFS: JSVarRef[] = Object.freeze([]) as unknown as JSVarRef[];\n\nexport class JSStackFrame {\n prev_frame: JSStackFrame | null = null;\n cur_func: JSValue = undefined; /* current function, JS_UNDEFINED if the frame is detached */\n arg_buf: JSValue[] = EMPTY_BUF;\n var_buf: JSValue[] = EMPTY_BUF;\n stack_buf: JSValue[] = EMPTY_BUF;\n sp = 0;\n cur_pc = 0;\n arg_count = 0;\n js_mode = 0;\n cur_sp = -1; /* only used in generators */\n var_refs: JSVarRef[] = EMPTY_VAR_REFS; /* var refs created in this frame (to detach on exit); replaced on first use */\n this_obj: JSValue = undefined;\n new_target: JSValue = undefined;\n /* the rest of this frame runs in compiled code (on-stack replacement): backtraces show the\n compiled frame instead of this one */\n osr = false;\n}\n\nexport const enum JSGeneratorState {\n SUSPENDED_START,\n SUSPENDED_YIELD,\n SUSPENDED_YIELD_STAR,\n EXECUTING,\n COMPLETED,\n}\n\nexport class JSAsyncFunctionState {\n this_val: JSValue = undefined;\n argc = 0;\n throw_flag = false;\n is_completed = false;\n frame: JSStackFrame = new JSStackFrame();\n func_obj: JSValue = undefined;\n /* for async functions */\n resolving_funcs: [JSValue, JSValue] = [undefined, undefined];\n promise: JSValue = undefined;\n}\n\nexport class JSGeneratorData {\n state: JSGeneratorState = JSGeneratorState.SUSPENDED_START;\n func_state: JSAsyncFunctionState | null = null;\n}\n\n/* bound function metadata (the object itself is a host bound function) */\nexport class JSBoundFunctionData {\n func_obj: JSObject;\n this_val: JSValue;\n argv: JSValue[];\n constructor(func_obj: JSObject, this_val: JSValue, argv: JSValue[]) {\n this.func_obj = func_obj; this.this_val = this_val; this.argv = argv;\n }\n}\n\nexport type JSCFunction = (ctx: any, this_val: JSValue, argv: JSValue[]) => JSValue;\nexport type JSCFunctionMagic = (ctx: any, this_val: JSValue, argv: JSValue[], magic: number) => JSValue;\nexport type JSCFunctionData = (ctx: any, this_val: JSValue, argv: JSValue[], magic: number, data: JSValue[]) => JSValue;\nexport type JSCFunctionConstructor = (ctx: any, new_target: JSValue, argv: JSValue[]) => JSValue;\nexport type JSCFunctionConstructorMagic = (ctx: any, new_target: JSValue, argv: JSValue[], magic: number) => JSValue;\n\nexport const enum JSCFunctionEnum {\n generic,\n generic_magic,\n constructor,\n constructor_magic,\n constructor_or_func,\n constructor_or_func_magic,\n f_f,\n f_f_f,\n getter,\n setter,\n getter_magic,\n setter_magic,\n iterator_next,\n}\n\nexport class JSCFunctionRecord {\n func: Function;\n length: number;\n cproto: JSCFunctionEnum;\n magic: number;\n constructor(func: Function, length: number, cproto: JSCFunctionEnum, magic: number) {\n this.func = func; this.length = length; this.cproto = cproto; this.magic = magic;\n }\n}\n\nexport class JSCFunctionDataRecord {\n func: JSCFunctionData;\n length: number;\n magic: number;\n data: JSValue[];\n constructor(func: JSCFunctionData, length: number, magic: number, data: JSValue[]) {\n this.func = func; this.length = length; this.magic = magic; this.data = data;\n }\n}\n\n/* for-in enumeration state: snapshot of the enumerable keys */\nexport class JSForInState {\n obj: JSValue = undefined;\n idx = 0;\n keys: (string | number)[] = [];\n own_count = 0; /* number of keys of 'obj' itself at the start of 'keys' */\n}\n\nexport class JSMapRecord {\n key: JSValue;\n value: JSValue;\n empty = false; /* true if the record was deleted */\n constructor(key: JSValue, value: JSValue) { this.key = key; this.value = value; }\n}\n\nexport class JSMapState {\n is_weak: boolean;\n /* records in insertion order; deleted records are marked empty and\n purged lazily when there are no active iterators */\n records: JSMapRecord[] = [];\n map = new Map<unknown, JSMapRecord>(); /* normalized key -> record */\n weak: WeakMap<object, JSMapRecord> | null = null;\n record_count = 0;\n iterator_count = 0;\n constructor(is_weak: boolean) {\n this.is_weak = is_weak;\n if (is_weak) this.weak = new WeakMap();\n }\n}\n\nexport class JSMapIteratorData {\n obj: JSValue;\n kind: number;\n idx = 0;\n constructor(obj: JSValue, kind: number) { this.obj = obj; this.kind = kind; }\n}\n\nexport class JSArrayIteratorData {\n obj: JSValue;\n kind: number;\n idx = 0;\n constructor(obj: JSValue, kind: number) { this.obj = obj; this.kind = kind; }\n}\n\nexport class JSRegExpStringIteratorData {\n iterating_regexp: JSValue;\n iterated_string: JSValue;\n global: boolean;\n unicode: boolean;\n done = false;\n constructor(re: JSValue, str: JSValue, global: boolean, unicode: boolean) {\n this.iterating_regexp = re; this.iterated_string = str; this.global = global; this.unicode = unicode;\n }\n}\n\nexport const enum JSPromiseState {\n PENDING,\n FULFILLED,\n REJECTED,\n}\n\nexport class JSPromiseReactionData {\n resolving_funcs: [JSValue, JSValue];\n handler: JSValue;\n constructor(resolving_funcs: [JSValue, JSValue], handler: JSValue) {\n this.resolving_funcs = resolving_funcs; this.handler = handler;\n }\n}\n\nexport class JSPromiseData {\n promise_state: JSPromiseState = JSPromiseState.PENDING;\n is_handled = false;\n promise_reactions: [JSPromiseReactionData[], JSPromiseReactionData[]] = [[], []];\n promise_result: JSValue = undefined;\n}\n\nexport class JSPromiseFunctionData {\n promise: JSValue;\n presolved: { already_resolved: boolean };\n constructor(promise: JSValue, presolved: { already_resolved: boolean }) {\n this.promise = promise; this.presolved = presolved;\n }\n}\n\nexport class JSProxyData {\n host_revoke: (() => void) | null = null;\n target: JSValue;\n handler: JSValue;\n is_func: boolean;\n is_revoked = false;\n constructor(target: JSValue, handler: JSValue, is_func: boolean) {\n this.target = target; this.handler = handler; this.is_func = is_func;\n }\n}\n\nexport class JSRegExp {\n pattern: string;\n flags: string;\n /* host regexp used as the matching engine */\n re: RegExp;\n constructor(pattern: string, flags: string, re: RegExp) {\n this.pattern = pattern; this.flags = flags; this.re = re;\n }\n}\n\n/* ArrayBuffer metadata: the guest object is the host ArrayBuffer itself */\nexport class JSArrayBuffer {\n buffer: ArrayBuffer | SharedArrayBuffer;\n data: Uint8Array; /* view over the whole buffer (empty when detached) */\n detached = false;\n shared: boolean;\n constructor(buffer: ArrayBuffer | SharedArrayBuffer, shared = false) {\n this.buffer = buffer;\n this.data = new Uint8Array(buffer as ArrayBuffer);\n this.shared = shared;\n }\n get byteLength(): number { return this.detached ? 0 : this.buffer.byteLength; }\n}\n\n/* typed array metadata: the guest object is the host typed array itself */\nexport class JSTypedArray {\n buffer: JSObject; /* guest ArrayBuffer object */\n offset: number;\n length: number; /* in bytes */\n track_rab = false;\n constructor(buffer: JSObject, offset: number, length: number) {\n this.buffer = buffer; this.offset = offset; this.length = length;\n }\n}\n\n/* function with closure variables */\nexport class JSFunctionData {\n function_bytecode: JSFunctionBytecode;\n var_refs: JSVarRef[];\n home_object: JSObject | null = null;\n /* compiled tier (see src/jit.ts and docs/JIT.md \"Tiering\"):\n compiled: the direct entry `(this, new_target, ...args)` of this closure, once compiled;\n priv: a private callable with the host convention and the host Function.prototype\n (never reachable from guest code): `priv.apply(this, args)` is the fast way for\n the engine and for retargetable wrappers to call the compiled body;\n mkpriv: creates `priv` on demand (closures created by compiled code);\n ctor: the explicit-convention body `(this | undefined, new_target, ...args)` used for\n construct calls through a retargetable wrapper (compiled on the first one). */\n compiled: Function | null = null;\n priv: Function | null = null;\n mkpriv: (() => Function) | null = null;\n ctor: Function | null = null;\n constructor(b: JSFunctionBytecode, var_refs: JSVarRef[]) {\n this.function_bytecode = b; this.var_refs = var_refs;\n }\n}\n\n/* engine metadata attached to guest objects that need it (JSRuntime.meta) */\nexport class JSObjectMeta {\n class_id: JSClassID;\n /* class specific data (the \"union\" of JSObject in quickjs.c) */\n u: any = null;\n /* bytecode function data */\n func: JSFunctionData | null = null;\n /* C function data */\n cfunc: JSCFunctionRecord | null = null;\n realm: any = null; /* JSContext of C functions */\n is_constructor = false;\n is_class = false;\n is_uncatchable_error = false;\n /* true once the QuickJS backtrace has been added to an error object */\n has_backtrace = false;\n constructor(class_id: JSClassID) { this.class_id = class_id; }\n}\n\nexport function JS_VALUE_GET_OBJ(v: JSValue): JSObject { return v as JSObject; }\nexport function JS_VALUE_GET_INT(v: JSValue): number { return v as number; }\nexport function JS_VALUE_GET_FLOAT64(v: JSValue): number { return v as number; }\nexport function JS_VALUE_GET_BOOL(v: JSValue): boolean { return v as boolean; }\nexport function JS_VALUE_GET_STRING(v: JSValue): string { return v as string; }\n\nexport function js_mkval_bool(v: boolean): JSValue { return v; }\n\n/* ---------------------------------------------------------------------\n Modules (quickjs.c JSModuleDef and its entries)\n --------------------------------------------------------------------- */\n\nexport const enum JSModuleStatus {\n UNLINKED,\n LINKING,\n LINKED,\n EVALUATING,\n EVALUATING_ASYNC,\n EVALUATED,\n}\n\n/* a module request: `from \"x\"` (with its import attributes) */\nexport class JSReqModuleEntry {\n module: JSModuleDef | null = null; /* set when the graph is loaded */\n constructor(public module_name: JSAtom, public attributes: Record<string, string> | null) {}\n}\n\nexport const enum JSExportType { LOCAL, INDIRECT }\n\nexport class JSExportEntry {\n export_type: JSExportType;\n /* LOCAL: closure variable index in the module function, and its reference once created */\n var_idx = -1;\n var_ref: JSVarRef | null = null;\n /* INDIRECT: the module request it comes from */\n req_module_idx = -1;\n /* LOCAL: the local name; INDIRECT: the imported name, '*' for `export * as ns from` */\n local_name: JSAtom;\n export_name: JSAtom;\n constructor(local_name: JSAtom, export_name: JSAtom, export_type: JSExportType) {\n this.local_name = local_name; this.export_name = export_name; this.export_type = export_type;\n }\n}\n\nexport class JSStarExportEntry {\n constructor(public req_module_idx: number) {}\n}\n\nexport class JSImportEntry {\n req_module_idx = -1;\n constructor(public var_idx: number, public is_star: boolean, public import_name: JSAtom) {}\n}\n\n/* what the module source is: JavaScript, JSON or host values provided by the embedder */\nexport const enum JSModuleKind { JS, JSON, HOST }\n\nexport class JSModuleDef {\n module_name: JSAtom; /* the normalized id */\n url: string | null = null; /* import.meta.url (defaults to the id) */\n kind: JSModuleKind = JSModuleKind.JS;\n req_module_entries: JSReqModuleEntry[] = [];\n export_entries: JSExportEntry[] = [];\n star_export_entries: JSStarExportEntry[] = [];\n import_entries: JSImportEntry[] = [];\n has_tla = false;\n status: JSModuleStatus = JSModuleStatus.UNLINKED;\n /* temporary, during linking and evaluation */\n dfs_index = 0;\n dfs_ancestor_index = 0;\n stack_prev: JSModuleDef | null = null;\n /* asynchronous evaluation (top-level await) */\n async_parent_modules: JSModuleDef[] = [];\n pending_async_dependencies = 0;\n async_evaluation = false;\n async_evaluation_timestamp = 0;\n cycle_root: JSModuleDef | null = null;\n promise: JSValue = undefined; /* capability of the evaluation */\n resolving_funcs: [JSValue, JSValue] = [undefined, undefined];\n eval_has_exception = false;\n eval_exception: JSValue = undefined;\n meta_obj: JSValue = undefined;\n module_ns: JSValue = undefined;\n func_bytecode: JSFunctionBytecode | null = null; /* JS: the module body */\n func_obj: JSValue = undefined; /* JS: the function object, once created */\n func_created = false;\n /* JSON and host modules: the value of each export, set at evaluation */\n synthetic_exports: Map<JSAtom, JSValue> | null = null;\n /* graph loading: true once every request has a module */\n requests_loaded = false;\n realm: any = null; /* JSContext */\n constructor(module_name: JSAtom) { this.module_name = module_name; }\n}\n"]}
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const JSEPTION_VERSION = "0.0.
|
|
1
|
+
export declare const JSEPTION_VERSION = "0.0.6";
|
package/dist/version.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* The jseption package version, kept equal to package.json by the npm "version" script
|
|
2
2
|
(scripts/sync-version.mjs) and checked by tests/bytecode.test.ts. Serialized bytecode
|
|
3
3
|
records it and only loads in the same version. */
|
|
4
|
-
export const JSEPTION_VERSION = '0.0.
|
|
4
|
+
export const JSEPTION_VERSION = '0.0.6';
|
|
5
5
|
//# sourceMappingURL=version.js.map
|
package/dist/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA;;oDAEoD;AACpD,MAAM,CAAC,MAAM,gBAAgB,GAAG,OAAO,CAAC","sourcesContent":["/* The jseption package version, kept equal to package.json by the npm \"version\" script\n (scripts/sync-version.mjs) and checked by tests/bytecode.test.ts. Serialized bytecode\n records it and only loads in the same version. */\nexport const JSEPTION_VERSION = '0.0.
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA;;oDAEoD;AACpD,MAAM,CAAC,MAAM,gBAAgB,GAAG,OAAO,CAAC","sourcesContent":["/* The jseption package version, kept equal to package.json by the npm \"version\" script\n (scripts/sync-version.mjs) and checked by tests/bytecode.test.ts. Serialized bytecode\n records it and only loads in the same version. */\nexport const JSEPTION_VERSION = '0.0.6';\n"]}
|
package/package.json
CHANGED