Added errorOutput to interpreter, moved builtin functions to their own file

This commit is contained in:
2022-09-04 15:15:30 +01:00
parent 22af1edb1d
commit ae270008b0
7 changed files with 551 additions and 506 deletions

View File

@@ -1,7 +1,5 @@
#pragma once
#include "opcodes.h"
#include "literal.h"
#include "literal_array.h"
#include "literal_dictionary.h"
@@ -26,6 +24,7 @@ typedef struct Interpreter {
// LiteralDictionary exports; //TODO: read-write - interface with Toy from C
PrintFn printOutput;
PrintFn assertOutput;
PrintFn errorOutput;
bool panic;
} Interpreter;
@@ -42,5 +41,6 @@ void freeInterpreter(Interpreter* interpreter);
//utilities for the host program
void setInterpreterPrint(Interpreter* interpreter, PrintFn printOutput);
void setInterpreterAssert(Interpreter* interpreter, PrintFn assertOutput);
void setInterpreterError(Interpreter* interpreter, PrintFn errorOutput);
void runInterpreter(Interpreter* interpreter, unsigned char* bytecode, int length);