clox/vm.h

34 lines
513 B
C
Raw Permalink Normal View History

2019-06-02 14:58:15 -05:00
#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;
int sp;
int capacity;
Value* stack;
Obj* objects;
Table strings;
Table globals;
} VM;
typedef enum {
INTERPRET_OK, INTERPRET_COMPILE_ERROR, INTERPRET_RUNTIME_ERROR
} InterpretResult;
extern VM vm;
void initVM();
void freeVM();
InterpretResult interpret(const char* source, bool repl);
void push(Value value);
Value pop();
#endif