File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ func main() {
2+ print("Test Print");
3+ }
4+ main();
Original file line number Diff line number Diff line change @@ -224,7 +224,11 @@ static void runFile(const char *path) {
224224 // --- Pipeline Step 3: Bytecode Gen & Execution ---
225225 // Use interpretAST to handle bytecode gen and execution properly using ObjFunction
226226 printf ("Executing...\n" );
227+ // Use interpretAST to handle bytecode gen and execution properly using ObjFunction
228+ printf ("Executing...\n" );
229+ printf ("DEBUG: Calling interpretAST from main...\n" );
227230 InterpretResult result = interpretAST (& vm , statements );
231+ printf ("DEBUG: Returned from interpretAST.\n" );
228232
229233 if (result != INTERPRET_OK ) {
230234 fprintf (stderr , "Execution Failed.\n" );
Original file line number Diff line number Diff line change @@ -120,7 +120,7 @@ static void concatenate(VM* pvm) {
120120
121121
122122static InterpretResult run (VM * vm ) {
123-
123+ printf ( "DEBUG: Entering run()\n" );
124124 CallFrame * frame = & vm -> frames [vm -> frameCount - 1 ];
125125
126126#define READ_BYTE () (*frame->ip++)
@@ -1081,6 +1081,14 @@ InterpretResult interpretAST(VM* pvm, StmtList* statements) {
10811081 return INTERPRET_COMPILE_ERROR ;
10821082 }
10831083
1084+ printf ("DEBUG: Generated bytecode. Function: %p\n" , function );
1085+ if (function -> chunk .code == NULL ) {
1086+ printf ("DEBUG: Chunk code is NULL!\n" );
1087+ } else {
1088+ printf ("DEBUG: Chunk code size: %d\n" , function -> chunk .count );
1089+ }
1090+
1091+
10841092 // Setup for execution
10851093 push (pvm , OBJ_VAL (function ));
10861094 ObjClosure * closure = newClosure (function );
@@ -1095,7 +1103,9 @@ InterpretResult interpretAST(VM* pvm, StmtList* statements) {
10951103 frame -> ip = function -> chunk .code ;
10961104 frame -> slots = pvm -> stack ;
10971105
1106+ printf ("DEBUG: Starting execution...\n" );
10981107 InterpretResult result = run (pvm );
1108+ printf ("DEBUG: Execution finished with result: %d\n" , result );
10991109
11001110 return result ;
11011111}
You can’t perform that action at this time.
0 commit comments