diff --git a/repl/main.c b/repl/main.c index 66d6719..9f88889 100644 --- a/repl/main.c +++ b/repl/main.c @@ -332,7 +332,7 @@ int repl(const char* filepath) { continue; } - void* buffer = Toy_compileModule(ast); + unsigned char* buffer = Toy_compileModule(ast); Toy_Module module = Toy_parseModule(buffer); 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_Ast* ast = Toy_scanParser(&bucket, &parser); - void* buffer = Toy_compileModule(ast); + unsigned char* buffer = Toy_compileModule(ast); Toy_freeBucket(&bucket); free(source); diff --git a/source/toy_bucket.c b/source/toy_bucket.c index 630b8fe..9e03b51 100644 --- a/source/toy_bucket.c +++ b/source/toy_bucket.c @@ -24,7 +24,7 @@ Toy_Bucket* Toy_allocateBucket(unsigned int capacity) { 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 amount = (amount + 3) & ~3; diff --git a/source/toy_bucket.h b/source/toy_bucket.h index 1da9700..4b9be4d 100644 --- a/source/toy_bucket.h +++ b/source/toy_bucket.h @@ -13,11 +13,11 @@ typedef struct Toy_Bucket { //32 | 64 BITNESS struct Toy_Bucket* next; //4 | 8 unsigned int capacity; //4 | 4 unsigned int count; //4 | 4 - char data[]; //- | - + unsigned char data[]; //- | - } Toy_Bucket; //12 | 16 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); //standard capacity sizes diff --git a/source/toy_module_bundle.c b/source/toy_module_bundle.c index 9486839..3ecf36f 100644 --- a/source/toy_module_bundle.c +++ b/source/toy_module_bundle.c @@ -87,7 +87,7 @@ void Toy_appendModuleBundle(Toy_ModuleBundle* bundle, Toy_Ast* ast) { exit(-1); } - void* module = Toy_compileModule(ast); + unsigned char* module = Toy_compileModule(ast); //don't try writing an empty module if (module == NULL) { diff --git a/source/toy_module_compiler.c b/source/toy_module_compiler.c index f2522f0..e4be5ae 100644 --- a/source/toy_module_compiler.c +++ b/source/toy_module_compiler.c @@ -30,7 +30,7 @@ static bool checkForChaining(Toy_Ast* ptr) { } //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 (capacity == 0) { free(ptr); @@ -1035,7 +1035,7 @@ static unsigned int writeModuleCompilerCode(Toy_ModuleCompiler** mb, Toy_Ast* as return result; } -static void* writeModuleCompiler(Toy_ModuleCompiler* mb, Toy_Ast* ast) { +static unsigned char* writeModuleCompiler(Toy_ModuleCompiler* mb, Toy_Ast* ast) { //code writeModuleCompilerCode(&mb, ast); @@ -1122,7 +1122,7 @@ static void* writeModuleCompiler(Toy_ModuleCompiler* mb, Toy_Ast* ast) { } //exposed functions -void* Toy_compileModule(Toy_Ast* ast) { +unsigned char* Toy_compileModule(Toy_Ast* ast) { //setup Toy_ModuleCompiler compiler; @@ -1153,7 +1153,7 @@ void* Toy_compileModule(Toy_Ast* ast) { compiler.panic = false; //compile the ast to memory - void * buffer = writeModuleCompiler(&compiler, ast); + unsigned char* buffer = writeModuleCompiler(&compiler, ast); //cleanup Toy_private_resizeEscapeArray(compiler.breakEscapes, 0); diff --git a/source/toy_module_compiler.h b/source/toy_module_compiler.h index 66443f5..7b85289 100644 --- a/source/toy_module_compiler.h +++ b/source/toy_module_compiler.h @@ -24,7 +24,7 @@ typedef struct Toy_private_EscapeArray { #define TOY_ESCAPE_EXPANSION_RATE 4 #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 typedef struct Toy_ModuleCompiler { @@ -59,4 +59,4 @@ typedef struct Toy_ModuleCompiler { bool panic; } Toy_ModuleCompiler; -TOY_API void* Toy_compileModule(Toy_Ast* ast); +TOY_API unsigned char* Toy_compileModule(Toy_Ast* ast); diff --git a/source/toy_scope.c b/source/toy_scope.c index 7177375..77aa8f8 100644 --- a/source/toy_scope.c +++ b/source/toy_scope.c @@ -51,7 +51,7 @@ static Toy_TableEntry* lookupScope(Toy_Scope* scope, Toy_String* key, unsigned i //exposed functions 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->table = Toy_allocateTable(); @@ -73,7 +73,7 @@ Toy_Scope* Toy_popScope(Toy_Scope* scope) { Toy_Scope* Toy_deepCopyScope(Toy_Bucket** bucketHandle, Toy_Scope* scope) { //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->table = Toy_private_adjustTableCapacity(NULL, scope->table->capacity); diff --git a/tests/cases/test_module_compiler.c b/tests/cases/test_module_compiler.c index c84a11f..6fe0117 100644 --- a/tests/cases/test_module_compiler.c +++ b/tests/cases/test_module_compiler.c @@ -392,7 +392,7 @@ int test_compiler_expressions(Toy_Bucket** bucketHandle) { return -1; } - void* data = jumps + 4; + unsigned char* data = jumps + 4; //check data if ( @@ -1179,7 +1179,7 @@ int test_compiler_keywords(Toy_Bucket** bucketHandle) { return -1; } - void* data = jumps + 4; + unsigned char* data = jumps + 4; //check data if ( @@ -1286,7 +1286,7 @@ int test_compiler_keywords(Toy_Bucket** bucketHandle) { return -1; } - void* data = jumps + 4; + unsigned char* data = jumps + 4; //check data if (