| 1088 | } |
| 1089 | |
| 1090 | static JSValue js_evalScript(JSContext *ctx, JSValueConst this_val, |
| 1091 | int argc, JSValueConst *argv) |
| 1092 | { |
| 1093 | JSRuntime *rt = JS_GetRuntime(ctx); |
| 1094 | JSThreadState *ts = js_get_thread_state(rt); |
| 1095 | const char *str = NULL; |
| 1096 | size_t len; |
| 1097 | JSValue ret, obj; |
| 1098 | JSValueConst options_obj, arg; |
| 1099 | bool backtrace_barrier = false; |
| 1100 | bool eval_function = false; |
| 1101 | bool eval_module = false; |
| 1102 | bool compile_only = false; |
| 1103 | bool compile_module = false; |
| 1104 | bool is_async = false; |
| 1105 | int flags; |
| 1106 | |
| 1107 | if (argc >= 2) { |
| 1108 | options_obj = argv[1]; |
| 1109 | if (get_bool_option(ctx, &backtrace_barrier, options_obj, |
| 1110 | "backtrace_barrier")) |
| 1111 | return JS_EXCEPTION; |
| 1112 | if (get_bool_option(ctx, &eval_function, options_obj, |
| 1113 | "eval_function")) |
| 1114 | return JS_EXCEPTION; |
| 1115 | if (get_bool_option(ctx, &eval_module, options_obj, |
| 1116 | "eval_module")) |
| 1117 | return JS_EXCEPTION; |
| 1118 | if (get_bool_option(ctx, &compile_only, options_obj, |
| 1119 | "compile_only")) |
| 1120 | return JS_EXCEPTION; |
| 1121 | if (get_bool_option(ctx, &compile_module, options_obj, |
| 1122 | "compile_module")) |
| 1123 | return JS_EXCEPTION; |
| 1124 | if (get_bool_option(ctx, &is_async, options_obj, |
| 1125 | "async")) |
| 1126 | return JS_EXCEPTION; |
| 1127 | } |
| 1128 | |
| 1129 | if (eval_module) { |
| 1130 | arg = argv[0]; |
| 1131 | if (JS_VALUE_GET_TAG(arg) != JS_TAG_MODULE) |
| 1132 | return JS_ThrowTypeError(ctx, "not a module"); |
| 1133 | |
| 1134 | if (JS_ResolveModule(ctx, arg) < 0) |
| 1135 | return JS_EXCEPTION; |
| 1136 | |
| 1137 | if (js_module_set_import_meta(ctx, arg, false, false) < 0) |
| 1138 | return JS_EXCEPTION; |
| 1139 | |
| 1140 | return JS_EvalFunction(ctx, JS_DupValue(ctx, arg)); |
| 1141 | } |
| 1142 | |
| 1143 | if (!eval_function) { |
| 1144 | str = JS_ToCStringLen(ctx, &len, argv[0]); |
| 1145 | if (!str) |
| 1146 | return JS_EXCEPTION; |
| 1147 | } |
nothing calls this directly
no test coverage detected