/** * @file symtab.h * @description A basic symbol table implementation, dynamic expansion. * * @todo Implement hash map. */ #ifndef SYMTAB_H #define SYMTAB_H #include "sv.h" struct symbol_entry { uint64_t symtype; struct string_view name; uintptr_t loc; size_t len; }; struct symbol_table { struct symbol_entry *entries; size_t count; size_t cap; }; void symtab_init(struct symbol_table *symtab); void symtab_expand(struct symbol_table *symtab); void symtab_free(struct symbol_table *symtab); struct symlookup_result { struct symbol_entry *ent; size_t i; }; // Returns a pointer, should be on lookout, will reset on expansion. struct symlookup_result symtab_lookup(struct symbol_table *symtab, struct string_view ent); size_t symtab_append(struct symbol_table *symtab, struct symbol_entry syment); #endif