mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 06:44:07 +10:00
replaced void* with unsigned char* everywhere
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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 (
|
||||
|
||||
Reference in New Issue
Block a user