Skip to content

Commit 9d4dee2

Browse files
committed
feat: Implement core ProXPL interpreter including REPL, file execution, and virtual machine.
1 parent b4b72f3 commit 9d4dee2

3 files changed

Lines changed: 19 additions & 1 deletion

File tree

repro.prox

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
func main() {
2+
print("Test Print");
3+
}
4+
main();

src/main.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff 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");

src/runtime/vm.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ static void concatenate(VM* pvm) {
120120

121121

122122
static 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
}

0 commit comments

Comments
 (0)