mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 14:54:07 +10:00
Added -Wpointer-arith to CFLAGS, read more
I attempted to add '-Wpedantic' to CFLAGS, but it seems that my usage of the variable length arrays within unions is causing an error that can't be selectively disabled: error: invalid use of structure with flexible array member [-Werror=pedantic] This is the offending code: /source/toy_string.h#L9-L37 It seems that tagged unions, with VLAs within, is simply not allowed. Unfortunately, my whole string system depends on it. I'll have to find some way around it. I've also updated the debugging output in repl/main.c.
This commit is contained in:
2
makefile
2
makefile
@@ -1,6 +1,6 @@
|
|||||||
#compiler settings reference
|
#compiler settings reference
|
||||||
#CC=gcc
|
#CC=gcc
|
||||||
#CFLAGS+=-std=c17 -g -Wall -Werror -Wextra -Wformat=2
|
#CFLAGS+=-std=c17 -g -Wall -Werror -Wextra -Wpointer-arith -Wformat=2
|
||||||
#LIBS+=-lm
|
#LIBS+=-lm
|
||||||
#LDFLAGS+=
|
#LDFLAGS+=
|
||||||
|
|
||||||
|
|||||||
135
repl/main.c
135
repl/main.c
@@ -42,7 +42,7 @@ unsigned char* readFile(char* path, int* size) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//read the file
|
//read the file
|
||||||
if (fread(buffer, sizeof(unsigned char), *size, file) < *size) {
|
if (fread(buffer, sizeof(unsigned char), *size, file) < (unsigned int)(*size)) {
|
||||||
fclose(file);
|
fclose(file);
|
||||||
*size = -2; //singal a read error
|
*size = -2; //singal a read error
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -130,10 +130,12 @@ static void assertFailureAndContinueCallback(const char* msg) {
|
|||||||
|
|
||||||
static void noOpCallback(const char* msg) {
|
static void noOpCallback(const char* msg) {
|
||||||
//NO-OP
|
//NO-OP
|
||||||
|
(void)msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void silentExitCallback(const char* msg) {
|
static void silentExitCallback(const char* msg) {
|
||||||
//NO-OP
|
//NO-OP
|
||||||
|
(void)msg;
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -151,6 +153,7 @@ typedef struct CmdLine {
|
|||||||
} CmdLine;
|
} CmdLine;
|
||||||
|
|
||||||
void usageCmdLine(int argc, const char* argv[]) {
|
void usageCmdLine(int argc, const char* argv[]) {
|
||||||
|
(void)argc;
|
||||||
printf("Usage: %s [ -h | -v | -f source.toy ]\n\n", argv[0]);
|
printf("Usage: %s [ -h | -v | -f source.toy ]\n\n", argv[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -169,6 +172,8 @@ void helpCmdLine(int argc, const char* argv[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void versionCmdLine(int argc, const char* argv[]) {
|
void versionCmdLine(int argc, const char* argv[]) {
|
||||||
|
(void)argc;
|
||||||
|
(void)argv;
|
||||||
printf("The Toy Programming Language, Version %d.%d.%d %s\n\n", TOY_VERSION_MAJOR, TOY_VERSION_MINOR, TOY_VERSION_PATCH, TOY_VERSION_BUILD);
|
printf("The Toy Programming Language, Version %d.%d.%d %s\n\n", TOY_VERSION_MAJOR, TOY_VERSION_MINOR, TOY_VERSION_PATCH, TOY_VERSION_BUILD);
|
||||||
|
|
||||||
//copy/pasted from the license file - there's a way to include it directly, but it's too finnicky to bother
|
//copy/pasted from the license file - there's a way to include it directly, but it's too finnicky to bother
|
||||||
@@ -344,72 +349,37 @@ int repl(const char* filepath) {
|
|||||||
static void debugStackPrint(Toy_Stack* stack) {
|
static void debugStackPrint(Toy_Stack* stack) {
|
||||||
//DEBUG: if there's anything on the stack, print it
|
//DEBUG: if there's anything on the stack, print it
|
||||||
if (stack->count > 0) {
|
if (stack->count > 0) {
|
||||||
printf("Stack Dump\n-------------------------\ntype\tvalue\n");
|
Toy_Bucket* stringBucket = Toy_allocateBucket(TOY_BUCKET_IDEAL);
|
||||||
for (int i = 0; i < stack->count; i++) {
|
|
||||||
Toy_Value v = ((Toy_Value*)(stack + 1))[i];
|
|
||||||
|
|
||||||
|
printf("Stack Dump\n-------------------------\ntype\tvalue\n");
|
||||||
|
for (unsigned int i = 0; i < stack->count; i++) {
|
||||||
|
Toy_Value v = ((Toy_Value*)(stack + 1))[i]; //'stack + 1' is a naughty trick
|
||||||
|
|
||||||
|
//print type
|
||||||
printf("%s\t", Toy_private_getValueTypeAsCString(v.type));
|
printf("%s\t", Toy_private_getValueTypeAsCString(v.type));
|
||||||
|
|
||||||
v = Toy_unwrapValue(v);
|
//print value
|
||||||
|
Toy_String* string = Toy_stringifyValue(&stringBucket, Toy_unwrapValue(v));
|
||||||
switch(v.type) {
|
char* buffer = Toy_getStringRawBuffer(string);
|
||||||
case TOY_VALUE_NULL:
|
printf("%s", buffer);
|
||||||
printf("null");
|
free(buffer);
|
||||||
break;
|
Toy_freeString(string);
|
||||||
|
|
||||||
case TOY_VALUE_BOOLEAN:
|
|
||||||
printf("%s", TOY_VALUE_AS_BOOLEAN(v) ? "true" : "false");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case TOY_VALUE_INTEGER:
|
|
||||||
printf("%d", TOY_VALUE_AS_INTEGER(v));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case TOY_VALUE_FLOAT:
|
|
||||||
printf("%f", TOY_VALUE_AS_FLOAT(v));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case TOY_VALUE_STRING: {
|
|
||||||
Toy_String* str = TOY_VALUE_AS_STRING(v);
|
|
||||||
|
|
||||||
//print based on type
|
|
||||||
if (str->type == TOY_STRING_NODE) {
|
|
||||||
char* buffer = Toy_getStringRawBuffer(str);
|
|
||||||
printf("%s", buffer);
|
|
||||||
free(buffer);
|
|
||||||
}
|
|
||||||
else if (str->type == TOY_STRING_LEAF) {
|
|
||||||
printf("%s", str->as.leaf.data);
|
|
||||||
}
|
|
||||||
else if (str->type == TOY_STRING_NAME) {
|
|
||||||
printf("%s", str->as.name.data);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case TOY_VALUE_ARRAY:
|
|
||||||
case TOY_VALUE_TABLE:
|
|
||||||
case TOY_VALUE_FUNCTION:
|
|
||||||
case TOY_VALUE_OPAQUE:
|
|
||||||
case TOY_VALUE_TYPE:
|
|
||||||
case TOY_VALUE_ANY:
|
|
||||||
case TOY_VALUE_REFERENCE:
|
|
||||||
case TOY_VALUE_UNKNOWN:
|
|
||||||
printf("???");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Toy_freeBucket(&stringBucket);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void debugScopePrint(Toy_Scope* scope, int depth) {
|
static void debugScopePrint(Toy_Scope* scope, int depth) {
|
||||||
//DEBUG: if there's anything in the scope, print it
|
//DEBUG: if there's anything in the scope, print it
|
||||||
if (scope->table->count > 0) {
|
if (scope->table->count > 0) {
|
||||||
|
Toy_Bucket* stringBucket = Toy_allocateBucket(TOY_BUCKET_IDEAL);
|
||||||
|
|
||||||
printf("Scope %d Dump\n-------------------------\ntype\tname\tvalue\n", depth);
|
printf("Scope %d Dump\n-------------------------\ntype\tname\tvalue\n", depth);
|
||||||
for (int i = 0; i < scope->table->capacity; i++) {
|
for (unsigned int i = 0; i < scope->table->capacity; i++) {
|
||||||
if ( (TOY_VALUE_IS_STRING(scope->table->data[i].key) && TOY_VALUE_AS_STRING(scope->table->data[i].key)->type == TOY_STRING_NAME) == false) {
|
if ( (TOY_VALUE_IS_STRING(scope->table->data[i].key) && TOY_VALUE_AS_STRING(scope->table->data[i].key)->type == TOY_STRING_NAME) != true) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -418,58 +388,17 @@ static void debugScopePrint(Toy_Scope* scope, int depth) {
|
|||||||
|
|
||||||
printf("%s\t%s\t", Toy_private_getValueTypeAsCString(v.type), TOY_VALUE_AS_STRING(k)->as.name.data);
|
printf("%s\t%s\t", Toy_private_getValueTypeAsCString(v.type), TOY_VALUE_AS_STRING(k)->as.name.data);
|
||||||
|
|
||||||
k = Toy_unwrapValue(k);
|
//print value
|
||||||
v = Toy_unwrapValue(v);
|
Toy_String* string = Toy_stringifyValue(&stringBucket, Toy_unwrapValue(v));
|
||||||
|
char* buffer = Toy_getStringRawBuffer(string);
|
||||||
switch(v.type) {
|
printf("%s", buffer);
|
||||||
case TOY_VALUE_NULL:
|
free(buffer);
|
||||||
printf("null");
|
Toy_freeString(string);
|
||||||
break;
|
|
||||||
|
|
||||||
case TOY_VALUE_BOOLEAN:
|
|
||||||
printf("%s", TOY_VALUE_AS_BOOLEAN(v) ? "true" : "false");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case TOY_VALUE_INTEGER:
|
|
||||||
printf("%d", TOY_VALUE_AS_INTEGER(v));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case TOY_VALUE_FLOAT:
|
|
||||||
printf("%f", TOY_VALUE_AS_FLOAT(v));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case TOY_VALUE_STRING: {
|
|
||||||
Toy_String* str = TOY_VALUE_AS_STRING(v);
|
|
||||||
|
|
||||||
//print based on type
|
|
||||||
if (str->type == TOY_STRING_NODE) {
|
|
||||||
char* buffer = Toy_getStringRawBuffer(str);
|
|
||||||
printf("%s", buffer);
|
|
||||||
free(buffer);
|
|
||||||
}
|
|
||||||
else if (str->type == TOY_STRING_LEAF) {
|
|
||||||
printf("%s", str->as.leaf.data);
|
|
||||||
}
|
|
||||||
else if (str->type == TOY_STRING_NAME) {
|
|
||||||
printf("%s\nWarning: The above value is a name string", str->as.name.data);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case TOY_VALUE_ARRAY:
|
|
||||||
case TOY_VALUE_TABLE:
|
|
||||||
case TOY_VALUE_FUNCTION:
|
|
||||||
case TOY_VALUE_OPAQUE:
|
|
||||||
case TOY_VALUE_TYPE:
|
|
||||||
case TOY_VALUE_ANY:
|
|
||||||
case TOY_VALUE_REFERENCE:
|
|
||||||
case TOY_VALUE_UNKNOWN:
|
|
||||||
printf("???");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Toy_freeBucket(&stringBucket);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scope->next != NULL) {
|
if (scope->next != NULL) {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#compiler settings
|
#compiler settings
|
||||||
CC=gcc
|
CC=gcc
|
||||||
#CFLAGS+=-std=c17 -g -Wall -Werror -Wextra -Wformat=2
|
CFLAGS+=-std=c17 -g -Wall -Werror -Wextra -Wpointer-arith -Wformat=2
|
||||||
LIBS+=-lm -lToy
|
LIBS+=-lm -lToy
|
||||||
LDFLAGS+=-Wl,-rpath,'$$ORIGIN'
|
LDFLAGS+=-Wl,-rpath,'$$ORIGIN'
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#compiler settings
|
#compiler settings
|
||||||
CC=gcc
|
CC=gcc
|
||||||
CFLAGS+=-std=c17 -g -Wall -Werror -Wextra -Wformat=2
|
CFLAGS+=-std=c17 -g -Wall -Werror -Wextra -Wpointer-arith -Wformat=2
|
||||||
LIBS+=-lm
|
LIBS+=-lm
|
||||||
LDFLAGS+=
|
LDFLAGS+=
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
//utils
|
//utils
|
||||||
static void expand(void** handle, unsigned int* capacity, unsigned int* count, unsigned int amount) {
|
static void expand(unsigned char** 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;
|
||||||
@@ -24,12 +24,12 @@ static void expand(void** handle, unsigned int* capacity, unsigned int* count, u
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void emitByte(void** handle, unsigned int* capacity, unsigned int* count, unsigned char byte) {
|
static void emitByte(unsigned char** 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, unsigned int* capacity, unsigned int* count, unsigned int bytes) {
|
static void emitInt(unsigned char** 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++));
|
||||||
@@ -37,7 +37,7 @@ static void emitInt(void** handle, unsigned int* capacity, unsigned int* count,
|
|||||||
emitByte(handle, capacity, count, *(ptr++));
|
emitByte(handle, capacity, count, *(ptr++));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void emitFloat(void** handle, unsigned int* capacity, unsigned int* count, float bytes) {
|
static void emitFloat(unsigned char** 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++));
|
||||||
@@ -47,11 +47,11 @@ static void emitFloat(void** handle, unsigned int* capacity, unsigned int* count
|
|||||||
|
|
||||||
//write instructions based on the AST types
|
//write instructions based on the AST types
|
||||||
#define EMIT_BYTE(rt, part, byte) \
|
#define EMIT_BYTE(rt, part, byte) \
|
||||||
emitByte((void**)(&((*rt)->part)), &((*rt)->part##Capacity), &((*rt)->part##Count), byte)
|
emitByte((&((*rt)->part)), &((*rt)->part##Capacity), &((*rt)->part##Count), byte)
|
||||||
#define EMIT_INT(rt, part, bytes) \
|
#define EMIT_INT(rt, part, bytes) \
|
||||||
emitInt((void**)(&((*rt)->part)), &((*rt)->part##Capacity), &((*rt)->part##Count), bytes)
|
emitInt((&((*rt)->part)), &((*rt)->part##Capacity), &((*rt)->part##Count), bytes)
|
||||||
#define EMIT_FLOAT(rt, part, bytes) \
|
#define EMIT_FLOAT(rt, part, bytes) \
|
||||||
emitFloat((void**)(&((*rt)->part)), &((*rt)->part##Capacity), &((*rt)->part##Count), bytes)
|
emitFloat((&((*rt)->part)), &((*rt)->part##Capacity), &((*rt)->part##Count), bytes)
|
||||||
|
|
||||||
//skip bytes, but return the address
|
//skip bytes, but return the address
|
||||||
#define SKIP_BYTE(rt, part) (EMIT_BYTE(rt, part, 0), ((*rt)->part##Count - 1))
|
#define SKIP_BYTE(rt, part) (EMIT_BYTE(rt, part, 0), ((*rt)->part##Count - 1))
|
||||||
@@ -59,7 +59,7 @@ static void emitFloat(void** handle, unsigned int* capacity, unsigned int* count
|
|||||||
|
|
||||||
//overwrite a pre-existing position
|
//overwrite a pre-existing position
|
||||||
#define OVERWRITE_INT(rt, part, addr, bytes) \
|
#define OVERWRITE_INT(rt, part, addr, bytes) \
|
||||||
emitInt((void**)(&((*rt)->part)), &((*rt)->part##Capacity), &(addr), bytes);
|
emitInt((&((*rt)->part)), &((*rt)->part##Capacity), &(addr), bytes);
|
||||||
|
|
||||||
//simply get the address (always an integer)
|
//simply get the address (always an integer)
|
||||||
#define CURRENT_ADDRESS(rt, part) ((*rt)->part##Count)
|
#define CURRENT_ADDRESS(rt, part) ((*rt)->part##Count)
|
||||||
@@ -80,7 +80,7 @@ static unsigned int emitString(Toy_Routine** rt, Toy_String* str) {
|
|||||||
unsigned int startAddr = (*rt)->dataCount;
|
unsigned int startAddr = (*rt)->dataCount;
|
||||||
|
|
||||||
//move the string into the data section
|
//move the string into the data section
|
||||||
expand((void**)(&((*rt)->data)), &((*rt)->dataCapacity), &((*rt)->dataCount), length);
|
expand((&((*rt)->data)), &((*rt)->dataCapacity), &((*rt)->dataCount), length);
|
||||||
|
|
||||||
if (str->type == TOY_STRING_NODE) {
|
if (str->type == TOY_STRING_NODE) {
|
||||||
char* buffer = Toy_getStringRawBuffer(str);
|
char* buffer = Toy_getStringRawBuffer(str);
|
||||||
@@ -750,7 +750,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;
|
unsigned char* buffer = NULL;
|
||||||
unsigned int capacity = 0, count = 0;
|
unsigned int capacity = 0, count = 0;
|
||||||
// int paramAddr = 0, subsAddr = 0;
|
// int paramAddr = 0, subsAddr = 0;
|
||||||
int codeAddr = 0;
|
int codeAddr = 0;
|
||||||
@@ -766,23 +766,23 @@ static void* writeRoutine(Toy_Routine* rt, Toy_Ast* ast) {
|
|||||||
//generate blank spaces, cache their positions in the *Addr variables (for storing the start positions)
|
//generate blank spaces, cache their positions in the *Addr variables (for storing the start positions)
|
||||||
if (rt->paramCount > 0) {
|
if (rt->paramCount > 0) {
|
||||||
// paramAddr = count;
|
// paramAddr = count;
|
||||||
emitInt((void**)&buffer, &capacity, &count, 0); //params
|
emitInt(&buffer, &capacity, &count, 0); //params
|
||||||
}
|
}
|
||||||
if (rt->codeCount > 0) {
|
if (rt->codeCount > 0) {
|
||||||
codeAddr = count;
|
codeAddr = count;
|
||||||
emitInt((void**)&buffer, &capacity, &count, 0); //code
|
emitInt(&buffer, &capacity, &count, 0); //code
|
||||||
}
|
}
|
||||||
if (rt->jumpsCount > 0) {
|
if (rt->jumpsCount > 0) {
|
||||||
jumpsAddr = count;
|
jumpsAddr = count;
|
||||||
emitInt((void**)&buffer, &capacity, &count, 0); //jumps
|
emitInt(&buffer, &capacity, &count, 0); //jumps
|
||||||
}
|
}
|
||||||
if (rt->dataCount > 0) {
|
if (rt->dataCount > 0) {
|
||||||
dataAddr = count;
|
dataAddr = count;
|
||||||
emitInt((void**)&buffer, &capacity, &count, 0); //data
|
emitInt(&buffer, &capacity, &count, 0); //data
|
||||||
}
|
}
|
||||||
if (rt->subsCount > 0) {
|
if (rt->subsCount > 0) {
|
||||||
// subsAddr = count;
|
// subsAddr = count;
|
||||||
emitInt((void**)&buffer, &capacity, &count, 0); //subs
|
emitInt(&buffer, &capacity, &count, 0); //subs
|
||||||
}
|
}
|
||||||
|
|
||||||
//append various parts to the buffer
|
//append various parts to the buffer
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ typedef struct Toy_Routine {
|
|||||||
unsigned int codeCapacity;
|
unsigned int codeCapacity;
|
||||||
unsigned int codeCount;
|
unsigned int codeCount;
|
||||||
|
|
||||||
unsigned int* jumps; //each 'jump' is the starting address of an element within 'data'
|
unsigned char* jumps; //each 'jump' is the starting address of an element within 'data'
|
||||||
unsigned int jumpsCapacity;
|
unsigned int jumpsCapacity;
|
||||||
unsigned int jumpsCount;
|
unsigned int jumpsCount;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#compiler settings
|
#compiler settings
|
||||||
CC=gcc
|
CC=gcc
|
||||||
CFLAGS+=-std=c17 -g -Wall -Werror -Wextra -Wformat=2
|
CFLAGS+=-std=c17 -g -Wall -Werror -Wextra -Wpointer-arith -Wformat=2
|
||||||
LIBS+=-lm
|
LIBS+=-lm
|
||||||
LDFLAGS+=
|
LDFLAGS+=
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#compiler settings
|
#compiler settings
|
||||||
CC=gcc
|
CC=gcc
|
||||||
CFLAGS+=-std=c17 -g -Wall -Werror -Wextra -Wformat=2
|
CFLAGS+=-std=c17 -g -Wall -Werror -Wextra -Wpointer-arith -Wformat=2
|
||||||
LIBS+=-lm
|
LIBS+=-lm
|
||||||
LDFLAGS+=
|
LDFLAGS+=
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ int test_routine_expressions(Toy_Bucket** bucketHandle) {
|
|||||||
Toy_private_emitAstPass(bucketHandle, &ast);
|
Toy_private_emitAstPass(bucketHandle, &ast);
|
||||||
|
|
||||||
//run
|
//run
|
||||||
void* buffer = Toy_compileRoutine(ast);
|
unsigned char* buffer = Toy_compileRoutine(ast);
|
||||||
|
|
||||||
//check header
|
//check header
|
||||||
int* ptr = (int*)buffer;
|
int* ptr = (int*)buffer;
|
||||||
@@ -66,7 +66,7 @@ int test_routine_expressions(Toy_Bucket** bucketHandle) {
|
|||||||
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
||||||
|
|
||||||
//run
|
//run
|
||||||
void* buffer = Toy_compileRoutine(ast);
|
unsigned char* buffer = Toy_compileRoutine(ast);
|
||||||
|
|
||||||
//check header
|
//check header
|
||||||
int* ptr = (int*)buffer;
|
int* ptr = (int*)buffer;
|
||||||
@@ -114,7 +114,7 @@ int test_routine_expressions(Toy_Bucket** bucketHandle) {
|
|||||||
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
||||||
|
|
||||||
//run
|
//run
|
||||||
void* buffer = Toy_compileRoutine(ast);
|
unsigned char* buffer = Toy_compileRoutine(ast);
|
||||||
|
|
||||||
//check header
|
//check header
|
||||||
int* ptr = (int*)buffer;
|
int* ptr = (int*)buffer;
|
||||||
@@ -166,7 +166,7 @@ int test_routine_expressions(Toy_Bucket** bucketHandle) {
|
|||||||
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
||||||
|
|
||||||
//run
|
//run
|
||||||
void* buffer = Toy_compileRoutine(ast);
|
unsigned char* buffer = Toy_compileRoutine(ast);
|
||||||
|
|
||||||
//check header
|
//check header
|
||||||
int* ptr = (int*)buffer;
|
int* ptr = (int*)buffer;
|
||||||
@@ -218,7 +218,7 @@ int test_routine_expressions(Toy_Bucket** bucketHandle) {
|
|||||||
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
||||||
|
|
||||||
//run
|
//run
|
||||||
void* buffer = Toy_compileRoutine(ast);
|
unsigned char* buffer = Toy_compileRoutine(ast);
|
||||||
|
|
||||||
//check header
|
//check header
|
||||||
int* ptr = (int*)buffer;
|
int* ptr = (int*)buffer;
|
||||||
@@ -271,7 +271,7 @@ int test_routine_expressions(Toy_Bucket** bucketHandle) {
|
|||||||
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
||||||
|
|
||||||
//run
|
//run
|
||||||
void* buffer = Toy_compileRoutine(ast);
|
unsigned char* buffer = Toy_compileRoutine(ast);
|
||||||
|
|
||||||
//check header
|
//check header
|
||||||
int* ptr = (int*)buffer;
|
int* ptr = (int*)buffer;
|
||||||
@@ -324,7 +324,7 @@ int test_routine_expressions(Toy_Bucket** bucketHandle) {
|
|||||||
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
||||||
|
|
||||||
//run
|
//run
|
||||||
void* buffer = Toy_compileRoutine(ast);
|
unsigned char* buffer = Toy_compileRoutine(ast);
|
||||||
|
|
||||||
//check header
|
//check header
|
||||||
int* header = (int*)buffer;
|
int* header = (int*)buffer;
|
||||||
@@ -350,7 +350,7 @@ int test_routine_expressions(Toy_Bucket** bucketHandle) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* code = buffer + 32; //8 values in the header, each 4 bytes
|
unsigned char* code = buffer + 32; //8 values in the header, each 4 bytes
|
||||||
|
|
||||||
//check code
|
//check code
|
||||||
if (
|
if (
|
||||||
@@ -374,7 +374,7 @@ int test_routine_expressions(Toy_Bucket** bucketHandle) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* jumps = code + 12;
|
unsigned char* jumps = code + 12;
|
||||||
|
|
||||||
//check jumps
|
//check jumps
|
||||||
if (
|
if (
|
||||||
@@ -430,7 +430,7 @@ int test_routine_binary(Toy_Bucket** bucketHandle) {
|
|||||||
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
||||||
|
|
||||||
//run
|
//run
|
||||||
void* buffer = Toy_compileRoutine(ast);
|
unsigned char* buffer = Toy_compileRoutine(ast);
|
||||||
|
|
||||||
//check header
|
//check header
|
||||||
int* ptr = (int*)buffer;
|
int* ptr = (int*)buffer;
|
||||||
@@ -495,7 +495,7 @@ int test_routine_binary(Toy_Bucket** bucketHandle) {
|
|||||||
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
||||||
|
|
||||||
//run
|
//run
|
||||||
void* buffer = Toy_compileRoutine(ast);
|
unsigned char* buffer = Toy_compileRoutine(ast);
|
||||||
|
|
||||||
//check header
|
//check header
|
||||||
int* ptr = (int*)buffer;
|
int* ptr = (int*)buffer;
|
||||||
@@ -560,7 +560,7 @@ int test_routine_binary(Toy_Bucket** bucketHandle) {
|
|||||||
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
||||||
|
|
||||||
//run
|
//run
|
||||||
void* buffer = Toy_compileRoutine(ast);
|
unsigned char* buffer = Toy_compileRoutine(ast);
|
||||||
|
|
||||||
//check header
|
//check header
|
||||||
int* ptr = (int*)buffer;
|
int* ptr = (int*)buffer;
|
||||||
@@ -625,7 +625,7 @@ int test_routine_binary(Toy_Bucket** bucketHandle) {
|
|||||||
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
||||||
|
|
||||||
//run
|
//run
|
||||||
void* buffer = Toy_compileRoutine(ast);
|
unsigned char* buffer = Toy_compileRoutine(ast);
|
||||||
|
|
||||||
//check header
|
//check header
|
||||||
int* ptr = (int*)buffer;
|
int* ptr = (int*)buffer;
|
||||||
@@ -720,7 +720,7 @@ int test_routine_keywords(Toy_Bucket** bucketHandle) {
|
|||||||
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
||||||
|
|
||||||
//run
|
//run
|
||||||
void* buffer = Toy_compileRoutine(ast);
|
unsigned char* buffer = Toy_compileRoutine(ast);
|
||||||
|
|
||||||
//check header
|
//check header
|
||||||
int* ptr = (int*)buffer;
|
int* ptr = (int*)buffer;
|
||||||
@@ -778,7 +778,7 @@ int test_routine_keywords(Toy_Bucket** bucketHandle) {
|
|||||||
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
||||||
|
|
||||||
//run
|
//run
|
||||||
void* buffer = Toy_compileRoutine(ast);
|
unsigned char* buffer = Toy_compileRoutine(ast);
|
||||||
|
|
||||||
//check header
|
//check header
|
||||||
int* ptr = (int*)buffer;
|
int* ptr = (int*)buffer;
|
||||||
@@ -841,7 +841,7 @@ int test_routine_keywords(Toy_Bucket** bucketHandle) {
|
|||||||
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
||||||
|
|
||||||
//run
|
//run
|
||||||
void* buffer = Toy_compileRoutine(ast);
|
unsigned char* buffer = Toy_compileRoutine(ast);
|
||||||
|
|
||||||
//check header
|
//check header
|
||||||
int* ptr = (int*)buffer;
|
int* ptr = (int*)buffer;
|
||||||
@@ -931,7 +931,7 @@ int test_routine_keywords(Toy_Bucket** bucketHandle) {
|
|||||||
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
||||||
|
|
||||||
//run
|
//run
|
||||||
void* buffer = Toy_compileRoutine(ast);
|
unsigned char* buffer = Toy_compileRoutine(ast);
|
||||||
|
|
||||||
//check header
|
//check header
|
||||||
int* ptr = (int*)buffer;
|
int* ptr = (int*)buffer;
|
||||||
@@ -1045,7 +1045,7 @@ int test_routine_keywords(Toy_Bucket** bucketHandle) {
|
|||||||
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
||||||
|
|
||||||
//run
|
//run
|
||||||
void* buffer = Toy_compileRoutine(ast);
|
unsigned char* buffer = Toy_compileRoutine(ast);
|
||||||
|
|
||||||
//check header
|
//check header
|
||||||
int* ptr = (int*)buffer;
|
int* ptr = (int*)buffer;
|
||||||
@@ -1102,7 +1102,7 @@ int test_routine_keywords(Toy_Bucket** bucketHandle) {
|
|||||||
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
||||||
|
|
||||||
//run
|
//run
|
||||||
void* buffer = Toy_compileRoutine(ast);
|
unsigned char* buffer = Toy_compileRoutine(ast);
|
||||||
|
|
||||||
//check header
|
//check header
|
||||||
int* header = (int*)buffer;
|
int* header = (int*)buffer;
|
||||||
@@ -1128,7 +1128,7 @@ int test_routine_keywords(Toy_Bucket** bucketHandle) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* code = buffer + 32; //8 values in the header, each 4 bytes
|
unsigned char* code = buffer + 32; //8 values in the header, each 4 bytes
|
||||||
|
|
||||||
//check code
|
//check code
|
||||||
if (
|
if (
|
||||||
@@ -1161,7 +1161,7 @@ int test_routine_keywords(Toy_Bucket** bucketHandle) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* jumps = code + 20;
|
unsigned char* jumps = code + 20;
|
||||||
|
|
||||||
//check jumps
|
//check jumps
|
||||||
if (
|
if (
|
||||||
@@ -1209,7 +1209,7 @@ int test_routine_keywords(Toy_Bucket** bucketHandle) {
|
|||||||
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
||||||
|
|
||||||
//run
|
//run
|
||||||
void* buffer = Toy_compileRoutine(ast);
|
unsigned char* buffer = Toy_compileRoutine(ast);
|
||||||
|
|
||||||
//check header
|
//check header
|
||||||
int* header = (int*)buffer;
|
int* header = (int*)buffer;
|
||||||
@@ -1235,7 +1235,7 @@ int test_routine_keywords(Toy_Bucket** bucketHandle) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* code = buffer + 32; //8 values in the header, each 4 bytes
|
unsigned char* code = buffer + 32; //8 values in the header, each 4 bytes
|
||||||
|
|
||||||
//check code
|
//check code
|
||||||
if (
|
if (
|
||||||
@@ -1268,7 +1268,7 @@ int test_routine_keywords(Toy_Bucket** bucketHandle) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* jumps = code + 20;
|
unsigned char* jumps = code + 20;
|
||||||
|
|
||||||
//check jumps
|
//check jumps
|
||||||
if (
|
if (
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#compiler settings
|
#compiler settings
|
||||||
CC=gcc
|
CC=gcc
|
||||||
CFLAGS+=-std=c17 -g -Wall -Werror -Wextra -Wformat=2
|
CFLAGS+=-std=c17 -g -Wall -Werror -Wextra -Wpointer-arith -Wformat=2
|
||||||
LIBS+=-lm
|
LIBS+=-lm
|
||||||
LDFLAGS+=
|
LDFLAGS+=
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#compiler settings
|
#compiler settings
|
||||||
CC=gcc
|
CC=gcc
|
||||||
CFLAGS+=-std=c17 -g -Wall -Werror -Wextra -Wformat=2
|
CFLAGS+=-std=c17 -g -Wall -Werror -Wextra -Wpointer-arith -Wformat=2
|
||||||
LIBS+=-lm
|
LIBS+=-lm
|
||||||
LDFLAGS+=
|
LDFLAGS+=
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user