load and evaluate a file */
| 490 | |
| 491 | /* load and evaluate a file */ |
| 492 | static JSValue js_loadScript(JSContext *ctx, JSValueConst this_val, |
| 493 | int argc, JSValueConst *argv) |
| 494 | { |
| 495 | uint8_t *buf; |
| 496 | const char *filename; |
| 497 | JSValue ret; |
| 498 | size_t buf_len; |
| 499 | |
| 500 | filename = JS_ToCString(ctx, argv[0]); |
| 501 | if (!filename) |
| 502 | return JS_EXCEPTION; |
| 503 | buf = js_load_file(ctx, &buf_len, filename); |
| 504 | if (!buf) { |
| 505 | JS_ThrowReferenceError(ctx, "could not load '%s'", filename); |
| 506 | JS_FreeCString(ctx, filename); |
| 507 | return JS_EXCEPTION; |
| 508 | } |
| 509 | ret = JS_Eval(ctx, (char *)buf, buf_len, filename, |
| 510 | JS_EVAL_TYPE_GLOBAL); |
| 511 | js_free(ctx, buf); |
| 512 | JS_FreeCString(ctx, filename); |
| 513 | return ret; |
| 514 | } |
| 515 | |
| 516 | static int get_bool_option(JSContext *ctx, bool *pbool, |
| 517 | JSValueConst obj, |
nothing calls this directly
no test coverage detected