mirror of
https://github.com/DoneJS-Runtime/quickjs-done-nextgen.git
synced 2025-01-09 17:43:15 +00:00
Update qjs.c
This commit is contained in:
parent
23d4991413
commit
68e14c7e8e
1 changed files with 7 additions and 9 deletions
16
qjs.c
16
qjs.c
|
@ -624,7 +624,7 @@ start:
|
||||||
if (!empty_run) {
|
if (!empty_run) {
|
||||||
js_std_add_helpers(ctx, argc - optind, argv + optind);
|
js_std_add_helpers(ctx, argc - optind, argv + optind);
|
||||||
|
|
||||||
//POLYFILLS FOR QJS FILES BEGIN
|
//POLYFILLS
|
||||||
const char *pf = "globalThis.global = globalThis;\n"
|
const char *pf = "globalThis.global = globalThis;\n"
|
||||||
"global.console.error = console.log\n"
|
"global.console.error = console.log\n"
|
||||||
"global.console.warn = console.log\n"
|
"global.console.warn = console.log\n"
|
||||||
|
@ -652,20 +652,18 @@ start:
|
||||||
" console.error('std is not defined.');\n"
|
" console.error('std is not defined.');\n"
|
||||||
"}\n";
|
"}\n";
|
||||||
|
|
||||||
/* make 'std' and 'os' visible to non module code */
|
const stdAndOS *str =
|
||||||
if (load_std) {
|
|
||||||
const char *str =
|
|
||||||
"import * as bjson from 'qjs:bjson';\n"
|
"import * as bjson from 'qjs:bjson';\n"
|
||||||
"import * as std from 'qjs:std';\n"
|
"import * as std from 'qjs:std';\n"
|
||||||
"import * as os from 'qjs:os';\n"
|
"import * as os from 'qjs:os';\n"
|
||||||
"globalThis.bjson = bjson;\n"
|
"globalThis.bjson = bjson;\n"
|
||||||
"globalThis.std = std;\n"
|
"globalThis.std = std;\n"
|
||||||
"globalThis.os = os;\n";
|
"globalThis.os = os;\n";
|
||||||
eval_buf(ctx, str, strlen(str), "<input>", JS_EVAL_TYPE_MODULE);
|
|
||||||
eval_buf(ctx, pf, strlen(pf), "<input>", JS_EVAL_TYPE_MODULE);
|
|
||||||
} else {
|
/* make 'std' 'os' and polyfills visible to non module code */
|
||||||
eval_buf(ctx, pf, strlen(pf), "<input>", JS_EVAL_TYPE_MODULE);
|
eval_buf(ctx, stdAndOS, strlen(stdAndOS), "<input>", JS_EVAL_TYPE_MODULE);
|
||||||
}
|
eval_buf(ctx, pf, strlen(pf), "<input>", JS_EVAL_TYPE_MODULE);
|
||||||
|
|
||||||
for(i = 0; i < include_count; i++) {
|
for(i = 0; i < include_count; i++) {
|
||||||
if (eval_file(ctx, include_list[i], 0))
|
if (eval_file(ctx, include_list[i], 0))
|
||||||
|
|
Loading…
Reference in a new issue