mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 14:54:07 +10:00
I've also added some support for compiler errors in general, but these will get expanded on later. I've also quickly added a valgrind option to the tests and found a few leaks. I'll deal with these later. Summary of changes: * Clarified the lifetime of the bytecode in memory * Erroneous routines exit without compiling * Empty VMs don't run * Added a check for malformed assignments * Renamed "routine" to "module" within the VM * VM no longer tries to free the bytecode - must be done manually * Started experimenting with valgrind, not yet ready
33 lines
891 B
C
33 lines
891 B
C
#pragma once
|
|
|
|
#include "toy_common.h"
|
|
#include "toy_ast.h"
|
|
|
|
//internal structure that holds the individual parts of a compiled routine
|
|
typedef struct Toy_Routine {
|
|
unsigned char* param; //c-string params in sequence (could be moved below the jump table?)
|
|
unsigned int paramCapacity;
|
|
unsigned int paramCount;
|
|
|
|
unsigned char* code; //the instruction set
|
|
unsigned int codeCapacity;
|
|
unsigned int codeCount;
|
|
|
|
unsigned int* jumps; //each 'jump' is the starting address of an element within 'data'
|
|
unsigned int jumpsCapacity;
|
|
unsigned int jumpsCount;
|
|
|
|
unsigned char* data; //data for longer stuff
|
|
unsigned int dataCapacity;
|
|
unsigned int dataCount;
|
|
|
|
unsigned char* subs; //subroutines, recursively
|
|
unsigned int subsCapacity;
|
|
unsigned int subsCount;
|
|
|
|
bool panic; //any issues found at this point are compilation errors
|
|
} Toy_Routine;
|
|
|
|
TOY_API void* Toy_compileRoutine(Toy_Ast* ast);
|
|
|