Skip to content

Commit 22c8a64

Browse files
authored
Refactor VM header file for clarity and structure
Updated VM header file with new definitions and includes.
1 parent 15613da commit 22c8a64

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed

include/vm.h

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
1-
#ifndef PROX_VM_H
2-
#define PROX_VM_H
1+
#ifndef PROXPL_VM_H
2+
#define PROXPL_VM_H
33

44
#include "chunk.h"
55
#include "value.h"
6+
#include "table.h" // Agar table.h nahi hai to isse hata dein, but usually chahiye hota hai
7+
#include "object.h"
68

79
#define STACK_MAX 256
810

911
typedef struct {
10-
Chunk *chunk;
11-
u8 *ip; // Instruction Pointer
12+
Chunk* chunk;
13+
uint8_t* ip;
1214
Value stack[STACK_MAX];
13-
Value *stackTop;
15+
Value* stackTop;
16+
Obj* objects; // <--- YE MISSING THA (Bahut Zaroori)
17+
// Table strings; // Future ke liye
18+
// Table globals; // Future ke liye
1419
} VM;
1520

1621
typedef enum {
@@ -19,10 +24,17 @@ typedef enum {
1924
INTERPRET_RUNTIME_ERROR
2025
} InterpretResult;
2126

22-
void initVM(VM *vm);
23-
void freeVM(VM *vm);
24-
InterpretResult interpret(VM *vm, Chunk *chunk);
25-
void push(VM *vm, Value value);
26-
Value pop(VM *vm);
27+
// Global VM instance
28+
extern VM vm;
29+
30+
void initVM();
31+
void freeVM();
32+
InterpretResult interpret(Chunk* chunk);
33+
void push(Value value);
34+
Value pop();
35+
36+
// Native function definition (Needed for convert_native.c)
37+
void defineNative(VM* vm, const char* name, NativeFn function);
2738

2839
#endif
40+

0 commit comments

Comments
 (0)