mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-17 15:54:07 +10:00
Added assert keyword, with re-routable print and assert outputs
This commit is contained in:
@@ -4,17 +4,24 @@
|
||||
|
||||
#include "literal_array.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
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user