Files
Toy/source/interpreter.h
Kayne Ruse 6d5549fc8e Added scopes using '{}' symbols, read more
I've also added a new literal type called 'identifier'. This will be
used for variable names, and has a type mask embedded in it.
2022-08-08 15:02:12 +01:00

31 lines
832 B
C

#pragma once
#include "opcodes.h"
#include "literal_array.h"
#include "literal_dictionary.h"
#include "scope.h"
typedef void (*PrintFn)(const char*);
//the interpreter acts depending on the bytecode instructions
typedef struct Interpreter {
LiteralArray literalCache; //generally doesn't change after initialization
Scope* scope;
unsigned char* bytecode;
int length;
int count;
LiteralArray stack;
PrintFn printOutput;
PrintFn assertOutput;
} Interpreter;
void initInterpreter(Interpreter* interpreter, unsigned char* bytecode, int length);
void freeInterpreter(Interpreter* interpreter);
//utilities for the host program
void setInterpreterPrint(Interpreter* interpreter, PrintFn printOutput);
void setInterpreterAssert(Interpreter* interpreter, PrintFn assertOutput);
void runInterpreter(Interpreter* interpreter);