#ifndef UNDAR_COMPILER_H #define UNDAR_COMPILER_H #import "../../vm/common.h" typedef enum { GLOBAL, LOCAL } ScopeType; typedef enum { VOID, BOOL, I8, I16, I32, U8, U16, U32, F8, F16, F32, STR, PLEX, ARRAY, FUNCTION } SymbolType; typedef struct value_type_s ValueType; typedef struct function_def_s FunctionDef; typedef struct function_tab_s FunctionTable; typedef struct plex_def_s PlexDef; typedef struct plex_tab_s PlexTable; typedef struct array_def_s ArrayDef; typedef struct array_tab_s ArrayTable; typedef struct symbol_s Symbol; typedef struct symbol_tab_s SymbolTable; typedef struct names_tab_s NamesTable; typedef struct plex_fields_tab_s PlexFieldsTable; struct value_type_s { SymbolType type; u32 name; u32 size; u32 table_ref; // if it is a heap object }; struct function_def_s { u32 name; ValueType args[8]; u8 arg_count; ValueType return_type; }; struct plex_def_s { u32 name; u32 size; u32 field_ref_start; u32 field_count; }; struct array_def_s { ValueType type; u32 length; u32 logical_size; // length of the array u32 physical_size; // logical_size * type_size + fat pointer }; struct symbol_s { u32 name; ValueType type; ScopeType scope; union { u32 local; // register u32 global; // address } ref; }; struct plex_fields_tab_s { u32 *plex_refs; ValueType *fields; u32 count; u32 capacity; }; struct plex_tab_s { PlexDef *symbols; u32 count; u32 capacity; }; struct array_tab_s { ArrayDef *symbols; u32 count; u32 capacity; }; struct function_tab_s { FunctionDef *symbols; u32 count; u32 capacity; }; struct names_tab_s { char **names; u32 count; u32 capacity; }; struct symbol_tab_s { Symbol *symbols; u32 count; u32 capacity; }; #endif