make polyfills aio
Some checks are pending
ci / Linux (Ubuntu) (push) Waiting to run
ci / linux-asan (push) Waiting to run
ci / linux-msan (push) Waiting to run
ci / linux-ubsan (push) Waiting to run
ci / macOS (push) Waiting to run
ci / macos-asan (push) Waiting to run
ci / macos-ubsan (push) Waiting to run
ci / freebsd (push) Waiting to run
ci / qemu-alpine (arm32v6) (push) Waiting to run
ci / qemu-alpine (arm32v7) (push) Waiting to run
ci / qemu-alpine (arm64v8) (push) Waiting to run
ci / qemu-alpine (i386) (push) Waiting to run
ci / qemu-alpine (s390x) (push) Waiting to run

This commit is contained in:
The Ghost of FOSS' Past 2024-10-24 15:56:39 -05:00
parent d838e9cc47
commit 807be22562

29
qjs.c
View file

@ -497,28 +497,21 @@ int main(int argc, char **argv)
} }
//POLYFILLS BEGIN //POLYFILLS BEGIN
const char *pf = "async function require(x) {\n"
////Require and Global
const char *reqPF = "async function require(x) {\n"
" const y = await import(x);" // use dynamic import. " const y = await import(x);" // use dynamic import.
" return y;\n" " return y;\n"
"}\n" "}\n"
"globalThis.require = require;\n" "globalThis.require = require;\n"
"globalThis.global = globalThis;\n"; "globalThis.global = globalThis;\n"
eval_buf(ctx, reqPF, strlen(reqPF), "<input>", JS_EVAL_TYPE_MODULE); "globalThis.setTimeout = os.setTimeout\n"
"globalThis.clearTimeout = os.clearTimeout\n"
"globalThis.sleep = os.sleep\n"
const char *timeoutPF = "globalThis.setTimeout = globalThis.os.setTimeout\n" "globalThis.urlGet = std.urlGet\n"
"globalThis.clearTimeout = globalThis.os.clearTimeout\n" "globalThis.loadFile = std.loadFile\n"
"globalThis.sleep = globalThis.os.sleep"; "globalThis.printf = std.printf\n"
eval_buf(ctx, timeoutPF, strlen(timeoutPF), "<input>", JS_EVAL_TYPE_MODULE); "globalThis.evalFile = std.loadScript\n"
"globalThis.getURL = std.urlGet";
const char *stdGlobals = "globalThis.urlGet = globalThis.std.urlGet\n" eval_buf(ctx, pf, strlen(pf), "<input>", JS_EVAL_TYPE_MODULE);
"globalThis.loadFile = globalThis.std.loadFile\n"
"globalThis.printf = globalThis.std.printf\n"
"globalThis.evalFile = globalThis.std.loadScript\n"
"globalThis.getURL = globalThis.std.urlGet";
eval_buf(ctx, stdGlobals, strlen(stdGlobals), "<input>", JS_EVAL_TYPE_MODULE);
for(i = 0; i < include_count; i++) { for(i = 0; i < include_count; i++) {