Changed size_t to unsigned int

This commit is contained in:
2024-10-02 03:39:38 +10:00
parent 7b453bc35f
commit 71c065a6c4
19 changed files with 93 additions and 90 deletions

View File

@@ -174,29 +174,29 @@ int main(int argc, const char* argv[]) {
int size; int size;
unsigned char* source = readFile(cmd.infile, &size); unsigned char* source = readFile(cmd.infile, &size);
free(cmd.infile);
cmd.infile = NULL;
cmd.infileLength = 0;
//check the file //check the file
if (source == NULL) { if (source == NULL) {
if (size == 0) { if (size == 0) {
fprintf(stderr, TOY_CC_ERROR "ERROR: Could not parse an empty file, exiting\n" TOY_CC_RESET); fprintf(stderr, TOY_CC_ERROR "ERROR: Could not parse an empty file '%s', exiting\n" TOY_CC_RESET, cmd.infile);
return -1; return -1;
} }
else if (size == -1) { else if (size == -1) {
fprintf(stderr, TOY_CC_ERROR "ERROR: File not found, exiting\n" TOY_CC_RESET); fprintf(stderr, TOY_CC_ERROR "ERROR: File not found '%s', exiting\n" TOY_CC_RESET, cmd.infile);
return -1; return -1;
} }
else { else {
fprintf(stderr, TOY_CC_ERROR "ERROR: Unknown error while reading file, exiting\n" TOY_CC_RESET); fprintf(stderr, TOY_CC_ERROR "ERROR: Unknown error while reading file '%s', exiting\n" TOY_CC_RESET, cmd.infile);
return -1; return -1;
} }
} }
free(cmd.infile);
cmd.infile = NULL;
cmd.infileLength = 0;
Toy_Lexer lexer; Toy_Lexer lexer;
Toy_bindLexer(&lexer, (char*)source); Toy_bindLexer(&lexer, (char*)source);

View File

@@ -4,7 +4,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
Toy_Array* Toy_resizeArray(Toy_Array* paramArray, size_t capacity) { Toy_Array* Toy_resizeArray(Toy_Array* paramArray, unsigned int capacity) {
if (capacity == 0) { if (capacity == 0) {
free(paramArray); free(paramArray);
return NULL; return NULL;

View File

@@ -4,12 +4,12 @@
//standard generic array //standard generic array
typedef struct Toy_Array { //32 | 64 BITNESS typedef struct Toy_Array { //32 | 64 BITNESS
size_t capacity; //4 | 4 unsigned int capacity; //4 | 4
size_t count; //4 | 4 unsigned int count; //4 | 4
char data[]; //- | - char data[]; //- | -
} Toy_Array; //8 | 8 } Toy_Array; //8 | 8
TOY_API Toy_Array* Toy_resizeArray(Toy_Array* array, size_t capacity); TOY_API Toy_Array* Toy_resizeArray(Toy_Array* array, unsigned int capacity);
#define TOY_ALLOCATE_ARRAY(type, count) \ #define TOY_ALLOCATE_ARRAY(type, count) \
Toy_resizeArray(NULL, sizeof(type)*(count)) Toy_resizeArray(NULL, sizeof(type)*(count))

View File

@@ -5,7 +5,7 @@
#include <stdlib.h> #include <stdlib.h>
//buckets of fun //buckets of fun
Toy_Bucket* Toy_allocateBucket(size_t capacity) { Toy_Bucket* Toy_allocateBucket(unsigned int capacity) {
if (capacity == 0) { if (capacity == 0) {
fprintf(stderr, TOY_CC_ERROR "ERROR: Cannot allocate a 'Toy_Bucket' with zero capacity\n" TOY_CC_RESET); fprintf(stderr, TOY_CC_ERROR "ERROR: Cannot allocate a 'Toy_Bucket' with zero capacity\n" TOY_CC_RESET);
exit(1); exit(1);
@@ -26,7 +26,7 @@ Toy_Bucket* Toy_allocateBucket(size_t capacity) {
return bucket; return bucket;
} }
void* Toy_partitionBucket(Toy_Bucket** bucketHandle, size_t amount) { void* Toy_partitionBucket(Toy_Bucket** bucketHandle, unsigned int amount) {
if ((*bucketHandle) == NULL) { if ((*bucketHandle) == NULL) {
fprintf(stderr, TOY_CC_ERROR "ERROR: Expected a 'Toy_Bucket', received NULL\n" TOY_CC_RESET); fprintf(stderr, TOY_CC_ERROR "ERROR: Expected a 'Toy_Bucket', received NULL\n" TOY_CC_RESET);
exit(1); exit(1);

View File

@@ -11,12 +11,12 @@
//a custom allocator //a custom allocator
typedef struct Toy_Bucket { //32 | 64 BITNESS typedef struct Toy_Bucket { //32 | 64 BITNESS
struct Toy_Bucket* next; //4 | 8 struct Toy_Bucket* next; //4 | 8
size_t capacity; //4 | 4 unsigned int capacity; //4 | 4
size_t count; //4 | 4 unsigned int count; //4 | 4
char data[]; //- | - char data[]; //- | -
} Toy_Bucket; //12 | 16 } Toy_Bucket; //12 | 16
TOY_API Toy_Bucket* Toy_allocateBucket(size_t capacity); TOY_API Toy_Bucket* Toy_allocateBucket(unsigned int capacity);
TOY_API void* Toy_partitionBucket(Toy_Bucket** bucketHandle, size_t amount); TOY_API void* Toy_partitionBucket(Toy_Bucket** bucketHandle, unsigned int amount);
TOY_API void Toy_freeBucket(Toy_Bucket** bucketHandle); TOY_API void Toy_freeBucket(Toy_Bucket** bucketHandle);

View File

@@ -8,7 +8,7 @@
#include <string.h> #include <string.h>
//utils //utils
static void expand(Toy_Bytecode* bc, size_t amount) { static void expand(Toy_Bytecode* bc, unsigned int amount) {
if (bc->count + amount > bc->capacity) { if (bc->count + amount > bc->capacity) {
while (bc->count + amount > bc->capacity) { //expand as much as needed while (bc->count + amount > bc->capacity) { //expand as much as needed

View File

@@ -5,8 +5,8 @@
typedef struct Toy_Bytecode { typedef struct Toy_Bytecode {
unsigned char* ptr; unsigned char* ptr;
size_t capacity; unsigned int capacity;
size_t count; unsigned int count;
} Toy_Bytecode; } Toy_Bytecode;
TOY_API Toy_Bytecode Toy_compileBytecode(Toy_Ast* ast); TOY_API Toy_Bytecode Toy_compileBytecode(Toy_Ast* ast);

View File

@@ -205,7 +205,7 @@ static Toy_Token makeKeywordOrIdentifier(Toy_Lexer* lexer) {
//scan for a keyword //scan for a keyword
for (int i = 0; Toy_private_keywords[i].keyword; i++) { for (int i = 0; Toy_private_keywords[i].keyword; i++) {
//WONTFIX: could squeeze miniscule performance gain from this, but ROI isn't worth it //WONTFIX: could squeeze miniscule performance gain from this, but ROI isn't worth it
if (strlen(Toy_private_keywords[i].keyword) == (size_t)(lexer->current - lexer->start) && !strncmp(Toy_private_keywords[i].keyword, &lexer->source[lexer->start], lexer->current - lexer->start)) { if (strlen(Toy_private_keywords[i].keyword) == (lexer->current - lexer->start) && !strncmp(Toy_private_keywords[i].keyword, &lexer->source[lexer->start], lexer->current - lexer->start)) {
//make token (keyword) //make token (keyword)
Toy_Token token; Toy_Token token;
@@ -312,7 +312,7 @@ Toy_Token Toy_private_scanLexer(Toy_Lexer* lexer) {
} }
} }
static void trim(char** s, size_t* l) { //util static void trim(char** s, unsigned int* l) { //util
while( isspace(( (*((unsigned char**)(s)))[(*l) - 1] )) ) (*l)--; while( isspace(( (*((unsigned char**)(s)))[(*l) - 1] )) ) (*l)--;
while(**s && isspace( **(unsigned char**)(s)) ) { (*s)++; (*l)--; } while(**s && isspace( **(unsigned char**)(s)) ) { (*s)++; (*l)--; }
} }
@@ -344,7 +344,7 @@ void Toy_private_printToken(Toy_Token* token) {
printf("%s", keyword); printf("%s", keyword);
} else { } else {
char* str = (char*)token->lexeme; //strip const-ness for trimming char* str = (char*)token->lexeme; //strip const-ness for trimming
size_t length = token->length; unsigned int length = token->length;
trim(&str, &length); trim(&str, &length);
printf("%.*s", (int)length, str); printf("%.*s", (int)length, str);
} }

View File

@@ -5,17 +5,17 @@
//lexers are bound to a string of code //lexers are bound to a string of code
typedef struct { typedef struct {
size_t start; //start of the current token unsigned int start; //start of the current token
size_t current; //current position of the lexer unsigned int current; //current position of the lexer
size_t line; //track this for error handling unsigned int line; //track this for error handling
const char* source; const char* source;
} Toy_Lexer; } Toy_Lexer;
//tokens are intermediaries between lexers and parsers //tokens are intermediaries between lexers and parsers
typedef struct { typedef struct {
Toy_TokenType type; Toy_TokenType type;
size_t length; unsigned int length;
size_t line; unsigned int line;
const char* lexeme; const char* lexeme;
} Toy_Token; } Toy_Token;

View File

@@ -232,7 +232,7 @@ static Toy_AstFlag atomic(Toy_Bucket** bucket, Toy_Parser* parser, Toy_Ast** roo
//filter the '_' character //filter the '_' character
char buffer[parser->previous.length]; char buffer[parser->previous.length];
size_t i = 0, o = 0; unsigned int i = 0, o = 0;
do { do {
buffer[i] = parser->previous.lexeme[o]; buffer[i] = parser->previous.lexeme[o];
if (buffer[i] != '_') i++; if (buffer[i] != '_') i++;
@@ -249,7 +249,7 @@ static Toy_AstFlag atomic(Toy_Bucket** bucket, Toy_Parser* parser, Toy_Ast** roo
//filter the '_' character //filter the '_' character
char buffer[parser->previous.length]; char buffer[parser->previous.length];
size_t i = 0, o = 0; unsigned int i = 0, o = 0;
do { do {
buffer[i] = parser->previous.lexeme[o]; buffer[i] = parser->previous.lexeme[o];
if (buffer[i] != '_') i++; if (buffer[i] != '_') i++;

View File

@@ -9,7 +9,7 @@
#include <string.h> #include <string.h>
//utils //utils
static void expand(void** handle, size_t* capacity, size_t* count, size_t amount) { static void expand(void** handle, unsigned int* capacity, unsigned int* count, unsigned int amount) {
if ((*count) + amount > (*capacity)) { if ((*count) + amount > (*capacity)) {
while ((*count) + amount > (*capacity)) { while ((*count) + amount > (*capacity)) {
(*capacity) = (*capacity) < 8 ? 8 : (*capacity) * 2; (*capacity) = (*capacity) < 8 ? 8 : (*capacity) * 2;
@@ -23,12 +23,12 @@ static void expand(void** handle, size_t* capacity, size_t* count, size_t amount
} }
} }
static void emitByte(void** handle, size_t* capacity, size_t* count, unsigned char byte) { static void emitByte(void** handle, unsigned int* capacity, unsigned int* count, unsigned char byte) {
expand(handle, capacity, count, 1); expand(handle, capacity, count, 1);
((unsigned char*)(*handle))[(*count)++] = byte; ((unsigned char*)(*handle))[(*count)++] = byte;
} }
static void emitInt(void** handle, size_t* capacity, size_t* count, size_t bytes) { static void emitInt(void** handle, unsigned int* capacity, unsigned int* count, unsigned int bytes) {
char* ptr = (char*)&bytes; char* ptr = (char*)&bytes;
emitByte(handle, capacity, count, *(ptr++)); emitByte(handle, capacity, count, *(ptr++));
emitByte(handle, capacity, count, *(ptr++)); emitByte(handle, capacity, count, *(ptr++));
@@ -36,7 +36,7 @@ static void emitInt(void** handle, size_t* capacity, size_t* count, size_t bytes
emitByte(handle, capacity, count, *(ptr++)); emitByte(handle, capacity, count, *(ptr++));
} }
static void emitFloat(void** handle, size_t* capacity, size_t* count, float bytes) { static void emitFloat(void** handle, unsigned int* capacity, unsigned int* count, float bytes) {
char* ptr = (char*)&bytes; char* ptr = (char*)&bytes;
emitByte(handle, capacity, count, *(ptr++)); emitByte(handle, capacity, count, *(ptr++));
emitByte(handle, capacity, count, *(ptr++)); emitByte(handle, capacity, count, *(ptr++));
@@ -284,7 +284,7 @@ static void* writeRoutine(Toy_Routine* rt, Toy_Ast* ast) {
//write the header and combine the parts //write the header and combine the parts
void* buffer = NULL; void* buffer = NULL;
size_t capacity = 0, count = 0; unsigned int capacity = 0, count = 0;
// int paramAddr = 0, codeAddr = 0, jumpsAddr = 0, dataAddr = 0, subsAddr = 0; // int paramAddr = 0, codeAddr = 0, jumpsAddr = 0, dataAddr = 0, subsAddr = 0;
int codeAddr = 0; int codeAddr = 0;

View File

@@ -6,24 +6,24 @@
//internal structure that holds the individual parts of a compiled routine //internal structure that holds the individual parts of a compiled routine
typedef struct Toy_Routine { typedef struct Toy_Routine {
unsigned char* param; //c-string params in sequence (could be moved below the jump table?) unsigned char* param; //c-string params in sequence (could be moved below the jump table?)
size_t paramCapacity; unsigned int paramCapacity;
size_t paramCount; unsigned int paramCount;
unsigned char* code; //the instruction set unsigned char* code; //the instruction set
size_t codeCapacity; unsigned int codeCapacity;
size_t codeCount; unsigned int codeCount;
size_t* jumps; //each 'jump' is the starting address of an element within 'data' unsigned int* jumps; //each 'jump' is the starting address of an element within 'data'
size_t jumpsCapacity; unsigned int jumpsCapacity;
size_t jumpsCount; unsigned int jumpsCount;
unsigned char* data; //{type,val} tuples of data unsigned char* data; //{type,val} tuples of data
size_t dataCapacity; unsigned int dataCapacity;
size_t dataCount; unsigned int dataCount;
unsigned char* subs; //subroutines, recursively unsigned char* subs; //subroutines, recursively
size_t subsCapacity; unsigned int subsCapacity;
size_t subsCount; unsigned int subsCount;
} Toy_Routine; } Toy_Routine;
TOY_API void* Toy_compileRoutine(Toy_Ast* ast); TOY_API void* Toy_compileRoutine(Toy_Ast* ast);

View File

@@ -40,7 +40,7 @@ void Toy_pushStack(Toy_Stack** stack, Toy_Value value) {
(*stack)->capacity = (*stack)->capacity < MIN_CAPACITY ? MIN_CAPACITY : (*stack)->capacity * 2; (*stack)->capacity = (*stack)->capacity < MIN_CAPACITY ? MIN_CAPACITY : (*stack)->capacity * 2;
} }
size_t newCapacity = (*stack)->capacity; unsigned int newCapacity = (*stack)->capacity;
(*stack) = realloc((*stack), newCapacity * sizeof(Toy_Value) + sizeof(Toy_Stack)); (*stack) = realloc((*stack), newCapacity * sizeof(Toy_Value) + sizeof(Toy_Stack));
@@ -72,7 +72,7 @@ Toy_Value Toy_popStack(Toy_Stack** stack) {
//shrink if possible //shrink if possible
if ((*stack)->count > MIN_CAPACITY && (*stack)->count < (*stack)->capacity / 4) { if ((*stack)->count > MIN_CAPACITY && (*stack)->count < (*stack)->capacity / 4) {
(*stack)->capacity /= 2; (*stack)->capacity /= 2;
size_t newCapacity = (*stack)->capacity; unsigned int newCapacity = (*stack)->capacity;
(*stack) = realloc((*stack), (*stack)->capacity * sizeof(Toy_Value) + sizeof(Toy_Stack)); (*stack) = realloc((*stack), (*stack)->capacity * sizeof(Toy_Value) + sizeof(Toy_Stack));

View File

@@ -4,8 +4,8 @@
#include "toy_value.h" #include "toy_value.h"
typedef struct Toy_Stack { //32 | 64 BITNESS typedef struct Toy_Stack { //32 | 64 BITNESS
size_t capacity; //4 | 4 unsigned int capacity; //4 | 4
size_t count; //4 | 4 unsigned int count; //4 | 4
char data[]; //- | - char data[]; //- | -
} Toy_Stack; //8 | 8 } Toy_Stack; //8 | 8

View File

@@ -54,8 +54,8 @@ Toy_String* Toy_createStringLength(Toy_Bucket** bucket, const char* cstring, int
} }
Toy_String* Toy_copyString(Toy_Bucket** bucket, Toy_String* str) { Toy_String* Toy_copyString(Toy_Bucket** bucket, Toy_String* str) {
if (str->refCount <= 0) { if (str->refCount == 0) {
fprintf(stderr, TOY_CC_ERROR "ERROR: Can't copy a string with refcount below or equal to zero\n" TOY_CC_RESET); fprintf(stderr, TOY_CC_ERROR "ERROR: Can't copy a string with refcount of zero\n" TOY_CC_RESET);
exit(-1); exit(-1);
} }
incrementRefCount(str); incrementRefCount(str);
@@ -63,8 +63,8 @@ Toy_String* Toy_copyString(Toy_Bucket** bucket, Toy_String* str) {
} }
Toy_String* Toy_deepCopyString(Toy_Bucket** bucket, Toy_String* str) { Toy_String* Toy_deepCopyString(Toy_Bucket** bucket, Toy_String* str) {
if (str->refCount <= 0) { if (str->refCount == 0) {
fprintf(stderr, TOY_CC_ERROR "ERROR: Can't deep copy a string with refcount below or equal to zero\n" TOY_CC_RESET); fprintf(stderr, TOY_CC_ERROR "ERROR: Can't deep copy a string with refcount of zero\n" TOY_CC_RESET);
exit(-1); exit(-1);
} }
Toy_String* ret = (Toy_String*)Toy_partitionBucket(bucket, sizeof(Toy_String) + str->length + 1); //TODO: compensate for partitioning more space than bucket capacity Toy_String* ret = (Toy_String*)Toy_partitionBucket(bucket, sizeof(Toy_String) + str->length + 1); //TODO: compensate for partitioning more space than bucket capacity
@@ -80,8 +80,8 @@ Toy_String* Toy_deepCopyString(Toy_Bucket** bucket, Toy_String* str) {
} }
Toy_String* Toy_concatString(Toy_Bucket** bucket, Toy_String* left, Toy_String* right) { Toy_String* Toy_concatString(Toy_Bucket** bucket, Toy_String* left, Toy_String* right) {
if (left->refCount <= 0 || right->refCount <= 0) { if (left->refCount == 0 || right->refCount == 0) {
fprintf(stderr, TOY_CC_ERROR "ERROR: Can't concatenate a string with refcount below or equal to zero\n" TOY_CC_RESET); fprintf(stderr, TOY_CC_ERROR "ERROR: Can't concatenate a string with refcount of zero\n" TOY_CC_RESET);
exit(-1); exit(-1);
} }
@@ -112,8 +112,8 @@ int Toy_getStringRefCount(Toy_String* str) {
} }
char* Toy_getStringRawBuffer(Toy_String* str) { char* Toy_getStringRawBuffer(Toy_String* str) {
if (str->refCount <= 0) { if (str->refCount == 0) {
fprintf(stderr, TOY_CC_ERROR "ERROR: Can't get raw string buffer of a string with refcount below or equal to zero\n" TOY_CC_RESET); fprintf(stderr, TOY_CC_ERROR "ERROR: Can't get raw string buffer of a string with refcount of zero\n" TOY_CC_RESET);
exit(-1); exit(-1);
} }

View File

@@ -9,8 +9,8 @@ typedef struct Toy_String { //32 | 64 BITNESS
TOY_STRING_LEAF, TOY_STRING_LEAF,
} type; //4 | 4 } type; //4 | 4
int length; //4 | 4 unsigned int length; //4 | 4
int refCount; //4 | 4 unsigned int refCount; //4 | 4
int _padding; //4 | 4 int _padding; //4 | 4

View File

@@ -12,13 +12,16 @@
#define READ_BYTE(vm) \ #define READ_BYTE(vm) \
vm->routine[vm->routineCounter++] vm->routine[vm->routineCounter++]
#define READ_UNSIGNED_INT(vm) \
*((unsigned int*)(vm->routine + _read_postfix(&(vm->routineCounter), 4)))
#define READ_INT(vm) \ #define READ_INT(vm) \
*((int*)(vm->routine + _read_postfix(&(vm->routineCounter), 4))) *((int*)(vm->routine + _read_postfix(&(vm->routineCounter), 4)))
#define READ_FLOAT(vm) \ #define READ_FLOAT(vm) \
*((float*)(vm->routine + _read_postfix(&(vm->routineCounter), 4))) *((float*)(vm->routine + _read_postfix(&(vm->routineCounter), 4)))
static inline int _read_postfix(int* ptr, int amount) { static inline int _read_postfix(unsigned int* ptr, int amount) {
int ret = *ptr; int ret = *ptr;
*ptr += amount; *ptr += amount;
return ret; return ret;
@@ -277,7 +280,7 @@ static void process(Toy_VM* vm) {
} }
//exposed functions //exposed functions
void Toy_bindVM(Toy_VM* vm, unsigned char* bytecode, int bytecodeSize) { void Toy_bindVM(Toy_VM* vm, unsigned char* bytecode, unsigned int bytecodeSize) {
if (bytecode[0] != TOY_VERSION_MAJOR || bytecode[1] > TOY_VERSION_MINOR) { if (bytecode[0] != TOY_VERSION_MAJOR || bytecode[1] > TOY_VERSION_MINOR) {
fprintf(stderr, TOY_CC_ERROR "ERROR: Wrong bytecode version found: expected %d.%d.%d found %d.%d.%d, exiting\n" TOY_CC_RESET, TOY_VERSION_MAJOR, TOY_VERSION_MINOR, TOY_VERSION_PATCH, bytecode[0], bytecode[1], bytecode[2]); fprintf(stderr, TOY_CC_ERROR "ERROR: Wrong bytecode version found: expected %d.%d.%d found %d.%d.%d, exiting\n" TOY_CC_RESET, TOY_VERSION_MAJOR, TOY_VERSION_MINOR, TOY_VERSION_PATCH, bytecode[0], bytecode[1], bytecode[2]);
exit(-1); exit(-1);
@@ -311,29 +314,29 @@ void Toy_bindVMToRoutine(Toy_VM* vm, unsigned char* routine) {
vm->routine = routine; vm->routine = routine;
//read the header metadata //read the header metadata
vm->routineSize = READ_INT(vm); vm->routineSize = READ_UNSIGNED_INT(vm);
vm->paramCount = READ_INT(vm); vm->paramCount = READ_UNSIGNED_INT(vm);
vm->jumpsCount = READ_INT(vm); vm->jumpsCount = READ_UNSIGNED_INT(vm);
vm->dataCount = READ_INT(vm); vm->dataCount = READ_UNSIGNED_INT(vm);
vm->subsCount = READ_INT(vm); vm->subsCount = READ_UNSIGNED_INT(vm);
//read the header addresses //read the header addresses
if (vm->paramCount > 0) { if (vm->paramCount > 0) {
vm->paramAddr = READ_INT(vm); vm->paramAddr = READ_UNSIGNED_INT(vm);
} }
vm->codeAddr = READ_INT(vm); //required vm->codeAddr = READ_UNSIGNED_INT(vm); //required
if (vm->jumpsCount > 0) { if (vm->jumpsCount > 0) {
vm->jumpsAddr = READ_INT(vm); vm->jumpsAddr = READ_UNSIGNED_INT(vm);
} }
if (vm->dataCount > 0) { if (vm->dataCount > 0) {
vm->dataAddr = READ_INT(vm); vm->dataAddr = READ_UNSIGNED_INT(vm);
} }
if (vm->subsCount > 0) { if (vm->subsCount > 0) {
vm->subsAddr = READ_INT(vm); vm->subsAddr = READ_UNSIGNED_INT(vm);
} }
//preallocate the scope & stack //preallocate the scope & stack

View File

@@ -7,24 +7,24 @@
typedef struct Toy_VM { typedef struct Toy_VM {
//hold the raw bytecode //hold the raw bytecode
unsigned char* bc; unsigned char* bc;
int bcSize; unsigned int bcSize;
//raw instructions to be executed //raw instructions to be executed
unsigned char* routine; unsigned char* routine;
int routineSize; unsigned int routineSize;
int paramCount; unsigned int paramCount;
int jumpsCount; unsigned int jumpsCount;
int dataCount; unsigned int dataCount;
int subsCount; unsigned int subsCount;
int paramAddr; unsigned int paramAddr;
int codeAddr; unsigned int codeAddr;
int jumpsAddr; unsigned int jumpsAddr;
int dataAddr; unsigned int dataAddr;
int subsAddr; unsigned int subsAddr;
int routineCounter; unsigned int routineCounter;
//heap - block-level key/value pairs //heap - block-level key/value pairs
//TODO: needs string util for identifiers //TODO: needs string util for identifiers
@@ -33,7 +33,7 @@ typedef struct Toy_VM {
Toy_Stack* stack; Toy_Stack* stack;
} Toy_VM; } Toy_VM;
TOY_API void Toy_bindVM(Toy_VM* vm, unsigned char* bytecode, int bytecodeSize); //process the version data TOY_API void Toy_bindVM(Toy_VM* vm, unsigned char* bytecode, unsigned int bytecodeSize); //process the version data
TOY_API void Toy_bindVMToRoutine(Toy_VM* vm, unsigned char* routine); //process the routine only TOY_API void Toy_bindVMToRoutine(Toy_VM* vm, unsigned char* routine); //process the routine only
TOY_API void Toy_runVM(Toy_VM* vm); TOY_API void Toy_runVM(Toy_VM* vm);