diff options
| author | 0x221E <0x221E@0xinfinity.dev> | 2026-04-12 16:24:06 +0200 |
|---|---|---|
| committer | 0x221E <0x221E@0xinfinity.dev> | 2026-04-12 16:24:06 +0200 |
| commit | 4946ca67cf04845737f0f7f70b5ed27bcfe9a18b (patch) | |
| tree | e0ce4c11f5b81828da7680143ea444003dd355b3 /src/symtab.h | |
Diffstat (limited to 'src/symtab.h')
| -rw-r--r-- | src/symtab.h | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/symtab.h b/src/symtab.h new file mode 100644 index 0000000..ca5a726 --- /dev/null +++ b/src/symtab.h @@ -0,0 +1,40 @@ +/** + * @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 |
