bring in mcode
This commit is contained in:
@@ -552,10 +552,18 @@ int cell_init(int argc, char **argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* --mcode now uses the new compiler and dumps bytecode (same as --mach) */
|
||||
JS_DumpMach(ctx, ast_json, JS_NULL);
|
||||
char *mcode_json = JS_Mcode(ctx, ast_json);
|
||||
free(ast_json);
|
||||
|
||||
if (!mcode_json) {
|
||||
printf("Failed to generate MCODE\n");
|
||||
JS_FreeContext(ctx); JS_FreeRuntime(rt); free(allocated_script);
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf("%s\n", mcode_json);
|
||||
free(mcode_json);
|
||||
|
||||
JS_FreeContext(ctx);
|
||||
JS_FreeRuntime(rt);
|
||||
free(allocated_script);
|
||||
|
||||
1379
source/quickjs.c
1379
source/quickjs.c
File diff suppressed because it is too large
Load Diff
@@ -1239,6 +1239,10 @@ void JS_DumpMach (JSContext *ctx, const char *ast_json, JSValue env);
|
||||
Returns result of execution, or JS_EXCEPTION on error. */
|
||||
JSValue JS_RunMach (JSContext *ctx, const char *ast_json, JSValue env);
|
||||
|
||||
/* Compile AST JSON to MCODE JSON (string-based IR).
|
||||
Returns malloc'd JSON string, or NULL on error. Caller must free. */
|
||||
char *JS_Mcode (JSContext *ctx, const char *ast_json);
|
||||
|
||||
/* Parse and execute MCODE JSON directly via the MCODE interpreter.
|
||||
Returns result of execution, or JS_EXCEPTION on error. */
|
||||
JSValue JS_CallMcode (JSContext *ctx, const char *mcode_json);
|
||||
|
||||
Reference in New Issue
Block a user