remove last two master updates and remove proxy
This commit is contained in:
@@ -751,7 +751,6 @@ void script_startup(cell_rt *prt)
|
||||
JS_AddIntrinsicRegExp(js);
|
||||
JS_AddIntrinsicJSON(js);
|
||||
JS_AddIntrinsicMapSet(js);
|
||||
JS_AddIntrinsicProxy(js);
|
||||
|
||||
JS_SetContextOpaque(js, prt);
|
||||
prt->context = js;
|
||||
@@ -870,79 +869,6 @@ int main(int argc, char **argv)
|
||||
int profile_enabled = 0;
|
||||
int script_start = 1;
|
||||
|
||||
/* Check for --script flag - execute script directly without engine */
|
||||
if (argc > 2 && strcmp(argv[1], "--script") == 0) {
|
||||
/* Read and execute the script file */
|
||||
FILE *f = fopen(argv[2], "rb");
|
||||
if (!f) {
|
||||
perror("fopen");
|
||||
return 1;
|
||||
}
|
||||
|
||||
fseek(f, 0, SEEK_END);
|
||||
long size = ftell(f);
|
||||
if (size < 0) {
|
||||
perror("ftell");
|
||||
fclose(f);
|
||||
return 1;
|
||||
}
|
||||
|
||||
char *script = malloc(size + 1);
|
||||
if (!script) {
|
||||
perror("malloc");
|
||||
fclose(f);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rewind(f);
|
||||
if (fread(script, 1, size, f) != size) {
|
||||
perror("fread");
|
||||
free(script);
|
||||
fclose(f);
|
||||
return 1;
|
||||
}
|
||||
fclose(f);
|
||||
script[size] = '\0';
|
||||
|
||||
/* Create minimal JS runtime */
|
||||
JSRuntime *rt = JS_NewRuntime();
|
||||
JSContext *js = JS_NewContextRaw(rt);
|
||||
|
||||
/* Add basic intrinsics */
|
||||
JS_AddIntrinsicBaseObjects(js);
|
||||
JS_AddIntrinsicEval(js);
|
||||
JS_AddIntrinsicRegExp(js);
|
||||
JS_AddIntrinsicJSON(js);
|
||||
JS_AddIntrinsicMapSet(js);
|
||||
JS_AddIntrinsicProxy(js);
|
||||
|
||||
cell_rt *prt = malloc(sizeof(*prt));
|
||||
JS_SetContextOpaque(js, prt);
|
||||
|
||||
/* Load FFI functions */
|
||||
ffi_load(js);
|
||||
|
||||
/* Execute the script */
|
||||
JSValue result = JS_Eval(js, script, size, argv[2], 0);
|
||||
free(script);
|
||||
|
||||
/* Check for exceptions */
|
||||
if (JS_IsException(result)) {
|
||||
JSValue exp = JS_GetException(js);
|
||||
const char *str = JS_ToCString(js, exp);
|
||||
if (str) {
|
||||
fprintf(stderr, "Exception: %s\n", str);
|
||||
JS_FreeCString(js, str);
|
||||
}
|
||||
JS_FreeValue(js, exp);
|
||||
}
|
||||
|
||||
JS_FreeValue(js, result);
|
||||
JS_FreeContext(js);
|
||||
JS_FreeRuntime(rt);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Check for --profile flag */
|
||||
if (argc > 1 && strcmp(argv[1], "--profile") == 0) {
|
||||
profile_enabled = 1; script_start = 2;
|
||||
|
||||
Reference in New Issue
Block a user