Files
Toy/source/toy_routine.h
Kayne Ruse 7be63c8ccc 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.
2024-12-12 18:23:44 +11:00

33 lines
892 B
C

#pragma once
#include "toy_common.h"
#include "toy_ast.h"
//internal structure that holds the individual parts of a compiled routine
typedef struct Toy_Routine {
unsigned char* param; //c-string params in sequence (could be moved below the jump table?)
unsigned int paramCapacity;
unsigned int paramCount;
unsigned char* code; //the instruction set
unsigned int codeCapacity;
unsigned int codeCount;
unsigned char* jumps; //each 'jump' is the starting address of an element within 'data'
unsigned int jumpsCapacity;
unsigned int jumpsCount;
unsigned char* data; //data for longer stuff
unsigned int dataCapacity;
unsigned int dataCount;
unsigned char* subs; //subroutines, recursively
unsigned int subsCapacity;
unsigned int subsCount;
bool panic; //any issues found at this point are compilation errors
} Toy_Routine;
TOY_API void* Toy_compileRoutine(Toy_Ast* ast);