mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 14:54:07 +10:00
replaced void* with unsigned char* everywhere
This commit is contained in:
@@ -332,7 +332,7 @@ int repl(const char* filepath) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* buffer = Toy_compileModule(ast);
|
unsigned char* buffer = Toy_compileModule(ast);
|
||||||
Toy_Module module = Toy_parseModule(buffer);
|
Toy_Module module = Toy_parseModule(buffer);
|
||||||
Toy_bindVM(&vm, &module, runCount++ > 0);
|
Toy_bindVM(&vm, &module, runCount++ > 0);
|
||||||
|
|
||||||
@@ -481,7 +481,7 @@ int main(int argc, const char* argv[]) {
|
|||||||
|
|
||||||
Toy_Bucket* bucket = Toy_allocateBucket(TOY_BUCKET_IDEAL);
|
Toy_Bucket* bucket = Toy_allocateBucket(TOY_BUCKET_IDEAL);
|
||||||
Toy_Ast* ast = Toy_scanParser(&bucket, &parser);
|
Toy_Ast* ast = Toy_scanParser(&bucket, &parser);
|
||||||
void* buffer = Toy_compileModule(ast);
|
unsigned char* buffer = Toy_compileModule(ast);
|
||||||
Toy_freeBucket(&bucket);
|
Toy_freeBucket(&bucket);
|
||||||
free(source);
|
free(source);
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ Toy_Bucket* Toy_allocateBucket(unsigned int capacity) {
|
|||||||
return bucket;
|
return bucket;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* Toy_partitionBucket(Toy_Bucket** bucketHandle, unsigned int amount) {
|
unsigned char* Toy_partitionBucket(Toy_Bucket** bucketHandle, unsigned int amount) {
|
||||||
|
|
||||||
//BUGFIX: the endpoint must be aligned to the word size, otherwise you'll get a bus error from moving pointers
|
//BUGFIX: the endpoint must be aligned to the word size, otherwise you'll get a bus error from moving pointers
|
||||||
amount = (amount + 3) & ~3;
|
amount = (amount + 3) & ~3;
|
||||||
|
|||||||
@@ -13,11 +13,11 @@ typedef struct Toy_Bucket { //32 | 64 BITNESS
|
|||||||
struct Toy_Bucket* next; //4 | 8
|
struct Toy_Bucket* next; //4 | 8
|
||||||
unsigned int capacity; //4 | 4
|
unsigned int capacity; //4 | 4
|
||||||
unsigned int count; //4 | 4
|
unsigned int count; //4 | 4
|
||||||
char data[]; //- | -
|
unsigned char data[]; //- | -
|
||||||
} Toy_Bucket; //12 | 16
|
} Toy_Bucket; //12 | 16
|
||||||
|
|
||||||
TOY_API Toy_Bucket* Toy_allocateBucket(unsigned int capacity);
|
TOY_API Toy_Bucket* Toy_allocateBucket(unsigned int capacity);
|
||||||
TOY_API void* Toy_partitionBucket(Toy_Bucket** bucketHandle, unsigned int amount);
|
TOY_API unsigned char* Toy_partitionBucket(Toy_Bucket** bucketHandle, unsigned int amount);
|
||||||
TOY_API void Toy_freeBucket(Toy_Bucket** bucketHandle);
|
TOY_API void Toy_freeBucket(Toy_Bucket** bucketHandle);
|
||||||
|
|
||||||
//standard capacity sizes
|
//standard capacity sizes
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ void Toy_appendModuleBundle(Toy_ModuleBundle* bundle, Toy_Ast* ast) {
|
|||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void* module = Toy_compileModule(ast);
|
unsigned char* module = Toy_compileModule(ast);
|
||||||
|
|
||||||
//don't try writing an empty module
|
//don't try writing an empty module
|
||||||
if (module == NULL) {
|
if (module == NULL) {
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ static bool checkForChaining(Toy_Ast* ptr) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//escapes
|
//escapes
|
||||||
void* Toy_private_resizeEscapeArray(Toy_private_EscapeArray* ptr, unsigned int capacity) {
|
Toy_private_EscapeArray* Toy_private_resizeEscapeArray(Toy_private_EscapeArray* ptr, unsigned int capacity) {
|
||||||
//if you're freeing everything, just return
|
//if you're freeing everything, just return
|
||||||
if (capacity == 0) {
|
if (capacity == 0) {
|
||||||
free(ptr);
|
free(ptr);
|
||||||
@@ -1035,7 +1035,7 @@ static unsigned int writeModuleCompilerCode(Toy_ModuleCompiler** mb, Toy_Ast* as
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void* writeModuleCompiler(Toy_ModuleCompiler* mb, Toy_Ast* ast) {
|
static unsigned char* writeModuleCompiler(Toy_ModuleCompiler* mb, Toy_Ast* ast) {
|
||||||
//code
|
//code
|
||||||
writeModuleCompilerCode(&mb, ast);
|
writeModuleCompilerCode(&mb, ast);
|
||||||
|
|
||||||
@@ -1122,7 +1122,7 @@ static void* writeModuleCompiler(Toy_ModuleCompiler* mb, Toy_Ast* ast) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//exposed functions
|
//exposed functions
|
||||||
void* Toy_compileModule(Toy_Ast* ast) {
|
unsigned char* Toy_compileModule(Toy_Ast* ast) {
|
||||||
//setup
|
//setup
|
||||||
Toy_ModuleCompiler compiler;
|
Toy_ModuleCompiler compiler;
|
||||||
|
|
||||||
@@ -1153,7 +1153,7 @@ void* Toy_compileModule(Toy_Ast* ast) {
|
|||||||
compiler.panic = false;
|
compiler.panic = false;
|
||||||
|
|
||||||
//compile the ast to memory
|
//compile the ast to memory
|
||||||
void * buffer = writeModuleCompiler(&compiler, ast);
|
unsigned char* buffer = writeModuleCompiler(&compiler, ast);
|
||||||
|
|
||||||
//cleanup
|
//cleanup
|
||||||
Toy_private_resizeEscapeArray(compiler.breakEscapes, 0);
|
Toy_private_resizeEscapeArray(compiler.breakEscapes, 0);
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ typedef struct Toy_private_EscapeArray {
|
|||||||
#define TOY_ESCAPE_EXPANSION_RATE 4
|
#define TOY_ESCAPE_EXPANSION_RATE 4
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
TOY_API void* Toy_private_resizeEscapeArray(Toy_private_EscapeArray* ptr, unsigned int capacity);
|
TOY_API Toy_private_EscapeArray* Toy_private_resizeEscapeArray(Toy_private_EscapeArray* ptr, unsigned int capacity);
|
||||||
|
|
||||||
//structure for holding the module as it is built
|
//structure for holding the module as it is built
|
||||||
typedef struct Toy_ModuleCompiler {
|
typedef struct Toy_ModuleCompiler {
|
||||||
@@ -59,4 +59,4 @@ typedef struct Toy_ModuleCompiler {
|
|||||||
bool panic;
|
bool panic;
|
||||||
} Toy_ModuleCompiler;
|
} Toy_ModuleCompiler;
|
||||||
|
|
||||||
TOY_API void* Toy_compileModule(Toy_Ast* ast);
|
TOY_API unsigned char* Toy_compileModule(Toy_Ast* ast);
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ static Toy_TableEntry* lookupScope(Toy_Scope* scope, Toy_String* key, unsigned i
|
|||||||
|
|
||||||
//exposed functions
|
//exposed functions
|
||||||
Toy_Scope* Toy_pushScope(Toy_Bucket** bucketHandle, Toy_Scope* scope) {
|
Toy_Scope* Toy_pushScope(Toy_Bucket** bucketHandle, Toy_Scope* scope) {
|
||||||
Toy_Scope* newScope = Toy_partitionBucket(bucketHandle, sizeof(Toy_Scope));
|
Toy_Scope* newScope = (Toy_Scope*)Toy_partitionBucket(bucketHandle, sizeof(Toy_Scope));
|
||||||
|
|
||||||
newScope->next = scope;
|
newScope->next = scope;
|
||||||
newScope->table = Toy_allocateTable();
|
newScope->table = Toy_allocateTable();
|
||||||
@@ -73,7 +73,7 @@ Toy_Scope* Toy_popScope(Toy_Scope* scope) {
|
|||||||
|
|
||||||
Toy_Scope* Toy_deepCopyScope(Toy_Bucket** bucketHandle, Toy_Scope* scope) {
|
Toy_Scope* Toy_deepCopyScope(Toy_Bucket** bucketHandle, Toy_Scope* scope) {
|
||||||
//copy/pasted from pushScope, so I can allocate the table manually
|
//copy/pasted from pushScope, so I can allocate the table manually
|
||||||
Toy_Scope* newScope = Toy_partitionBucket(bucketHandle, sizeof(Toy_Scope));
|
Toy_Scope* newScope = (Toy_Scope*)Toy_partitionBucket(bucketHandle, sizeof(Toy_Scope));
|
||||||
|
|
||||||
newScope->next = scope->next;
|
newScope->next = scope->next;
|
||||||
newScope->table = Toy_private_adjustTableCapacity(NULL, scope->table->capacity);
|
newScope->table = Toy_private_adjustTableCapacity(NULL, scope->table->capacity);
|
||||||
|
|||||||
@@ -392,7 +392,7 @@ int test_compiler_expressions(Toy_Bucket** bucketHandle) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* data = jumps + 4;
|
unsigned char* data = jumps + 4;
|
||||||
|
|
||||||
//check data
|
//check data
|
||||||
if (
|
if (
|
||||||
@@ -1179,7 +1179,7 @@ int test_compiler_keywords(Toy_Bucket** bucketHandle) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* data = jumps + 4;
|
unsigned char* data = jumps + 4;
|
||||||
|
|
||||||
//check data
|
//check data
|
||||||
if (
|
if (
|
||||||
@@ -1286,7 +1286,7 @@ int test_compiler_keywords(Toy_Bucket** bucketHandle) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* data = jumps + 4;
|
unsigned char* data = jumps + 4;
|
||||||
|
|
||||||
//check data
|
//check data
|
||||||
if (
|
if (
|
||||||
|
|||||||
Reference in New Issue
Block a user