33 lines
506 B
C
33 lines
506 B
C
#ifndef clox_vm_h
|
|
#define clox_vm_h
|
|
|
|
#include "chunk.h"
|
|
#include "table.h"
|
|
#include "value.h"
|
|
|
|
#define STACK_MAX 256
|
|
|
|
typedef struct {
|
|
Chunk* chunk;
|
|
uint8_t* ip;
|
|
Value stack[STACK_MAX];
|
|
Value* stackTop;
|
|
Table globals;
|
|
Table strings;
|
|
Obj* objects;
|
|
} VM;
|
|
typedef enum {
|
|
INTERPRET_OK,
|
|
INTERPRET_COMPILE_ERROR,
|
|
INTERPRET_RUNTIME_ERROR
|
|
} InterpretResult;
|
|
|
|
void initVM();
|
|
void freeVM();
|
|
InterpretResult interpret(const char* chunk);
|
|
extern VM vm;
|
|
void push(Value value);
|
|
Value pop();
|
|
|
|
#endif
|