Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/code_generator/symbol_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,20 @@ void symbol_block_dtor(SymbolBlockRef* pself) {
safe_free(*pself);
}

SymbolTableRef symbol_table_ctor(void) {
SymbolTableRef symbol_table_ctor(StringRef name) {
const SymbolTableRef table = safe_malloc(struct SymbolTable);
table->module = LLVMModuleCreateWithName(string_data(name));
table->builder = LLVMCreateBuilder();
table->prefix = string_ctor("", NULL);
table->stack = VECTORFUNC(SymbolBlockRef, ctor)(NULL);
return table;
}

void symbol_table_dtor(SymbolTableRef* pself) {
assert(pself);
LLVMDisposeModule((*pself)->module);
LLVMDisposeBuilder((*pself)->builder);
string_dtor(&(*pself)->prefix);
{
const VECTORREF(SymbolBlockRef) vector = (*pself)->stack;
SymbolBlockRef* iter = VECTORFUNC(SymbolBlockRef, begin)(vector);
Expand Down
3 changes: 3 additions & 0 deletions src/code_generator/symbol_table_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ struct SymbolBlock {
DECLARE_VECTOR(SymbolBlockRef)

struct SymbolTable {
LLVMModuleRef module;
LLVMBuilderRef builder;
StringRef prefix;
VECTORREF(SymbolBlockRef) stack;
};

Expand Down