|
46 | 46 | extern const uint8_t qjsc_repl[]; |
47 | 47 | extern const uint32_t qjsc_repl_size; |
48 | 48 |
|
49 | | -static JSCFunctionListEntry argv0; |
| 49 | +static int qjs__argc; |
| 50 | +static char **qjs__argv; |
| 51 | + |
50 | 52 |
|
51 | 53 | static int eval_buf(JSContext *ctx, const void *buf, int buf_len, |
52 | 54 | const char *filename, int eval_flags) |
@@ -171,7 +173,13 @@ static JSContext *JS_NewCustomContext(JSRuntime *rt) |
171 | 173 |
|
172 | 174 | JSValue global = JS_GetGlobalObject(ctx); |
173 | 175 | JS_SetPropertyFunctionList(ctx, global, global_obj, countof(global_obj)); |
174 | | - JS_SetPropertyFunctionList(ctx, global, &argv0, 1); |
| 176 | + JSValue args = JS_NewArray(ctx); |
| 177 | + int i; |
| 178 | + for(i = 0; i < qjs__argc; i++) { |
| 179 | + JS_SetPropertyUint32(ctx, args, i, JS_NewString(ctx, qjs__argv[i])); |
| 180 | + } |
| 181 | + JS_SetPropertyStr(ctx, global, "__argv", args); |
| 182 | + JS_SetPropertyStr(ctx, global, "argv0", JS_NewString(ctx, qjs__argv[0])); |
175 | 183 | JSValue navigator_proto = JS_NewObject(ctx); |
176 | 184 | JS_SetPropertyFunctionList(ctx, navigator_proto, navigator_proto_funcs, countof(navigator_proto_funcs)); |
177 | 185 | JSValue navigator = JS_NewObjectProto(ctx, navigator_proto); |
@@ -354,8 +362,9 @@ int main(int argc, char **argv) |
354 | 362 | int64_t memory_limit = -1; |
355 | 363 | int64_t stack_size = -1; |
356 | 364 |
|
357 | | - argv0 = (JSCFunctionListEntry)JS_PROP_STRING_DEF("argv0", argv[0], |
358 | | - JS_PROP_C_W_E); |
| 365 | + /* save for later */ |
| 366 | + qjs__argc = argc; |
| 367 | + qjs__argv = argv; |
359 | 368 |
|
360 | 369 | dump_flags_str = getenv("QJS_DUMP_FLAGS"); |
361 | 370 | dump_flags = dump_flags_str ? strtol(dump_flags_str, NULL, 16) : 0; |
|
0 commit comments