parse.ce and tokenize.ce

This commit is contained in:
2026-02-09 11:56:09 -06:00
parent 45556c344d
commit 368511f666
6 changed files with 3002 additions and 19 deletions

View File

@@ -727,7 +727,6 @@ int cell_init(int argc, char **argv)
/* Check for --mach-run flag to compile and run through MACH VM */
if (argc >= 3 && strcmp(argv[1], "--mach-run") == 0) {
const char *filename = argv[2];
if (!find_cell_shop()) return 1;
size_t boot_size;
@@ -755,7 +754,7 @@ int cell_init(int argc, char **argv)
cJSON_Delete(boot_ast);
return 1;
}
JSContext *ctx = JS_NewContextWithHeapSize(rt, 256 * 1024);
JSContext *ctx = JS_NewContextWithHeapSize(rt, 16 * 1024 * 1024);
if (!ctx) {
printf("Failed to create JS context\n");
cJSON_Delete(boot_ast); JS_FreeRuntime(rt);
@@ -766,7 +765,12 @@ int cell_init(int argc, char **argv)
JSValue hidden_env = JS_NewObject(ctx);
JS_SetPropertyStr(ctx, hidden_env, "os", js_os_use(ctx));
JS_SetPropertyStr(ctx, hidden_env, "program", JS_NewString(ctx, filename));
JSValue args_arr = JS_NewArray(ctx);
for (int i = 2; i < argc; i++) {
JSValue str = JS_NewString(ctx, argv[i]);
JS_ArrayPush(ctx, &args_arr, str);
}
JS_SetPropertyStr(ctx, hidden_env, "args", args_arr);
hidden_env = JS_Stone(ctx, hidden_env);
JSValue result = JS_RunMachTree(ctx, boot_ast, hidden_env);
@@ -775,7 +779,9 @@ int cell_init(int argc, char **argv)
int exit_code = 0;
if (JS_IsException(result)) {
JSValue exc = JS_GetException(ctx);
const char *err_str = JS_ToCString(ctx, exc);
const char *err_str = NULL;
JSValue msg = JS_GetPropertyStr(ctx, exc, "message");
err_str = JS_ToCString(ctx, msg);
if (err_str) {
printf("Error: %s\n", err_str);
JS_FreeCString(ctx, err_str);
@@ -921,4 +927,4 @@ int uncaught_exception(JSContext *js, JSValue v)
JS_FreeValue(js, exp);
JS_FreeValue(js, v);
return 0;
}
}