clox/vm.h

29 lines
425 B
C
Raw Normal View History

#ifndef _VM_H
#define _VM_H
#include "chunk.h"
#define MAX_STACK 256
typedef struct {
Chunk* chunk;
uint8_t* ip;
Value stack[MAX_STACK];
Value* sp;
} VM;
typedef enum {
INTERPRET_OK,
INTERPRET_COMPILE_ERROR,
INTERPRET_RUNTIME_ERROR
} InterpretResult;
void initVM( VM* vm );
void freeVM( VM* vm );
InterpretResult interpret( VM* vm, const char* src );
void push( VM* vm, Value val );
Value pop( VM* vm );
#endif