Add bytecode VM backend (compile AST to bytecodes + stack-based VM)
New execution mode: ./run vm <file.j> compiles AST to bytecodes and runs them in a while/switch loop. Ints/floats live on the stack (no heap allocation), ~7.7x faster than the tree-walking interpreter. Implements: opcodes, compiler with backpatching (if/while), stack VM with arithmetic, comparisons, variables, strings, and print/println. Reorganizes backend into src/backend/eval/ and src/backend/bytecode/.
This commit is contained in:
@@ -335,6 +335,9 @@ void ast_print(ASTNode *node, const char *prefix, int is_last) {
|
||||
ast_print(node->data.while_loop.cond, new_prefix, 0);
|
||||
ast_print(node->data.while_loop.body, new_prefix, 1);
|
||||
break;
|
||||
case NODE_NOP:
|
||||
printf("NODE_NOOP\n");
|
||||
break;
|
||||
|
||||
case NODE_CALL:
|
||||
printf("NODE_CALL(\"%s\")\n", node->data.call.name);
|
||||
|
||||
Reference in New Issue
Block a user