Skip to content

Commit

Permalink
feat: Symbols can now be overwritten in the scope
Browse files Browse the repository at this point in the history
  • Loading branch information
alinalihassan committed May 6, 2022
1 parent 09c0d70 commit bad0a28
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
5 changes: 2 additions & 3 deletions src/liblesma/Backend/Codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,15 @@ void Codegen::CompileModule(Span span, const std::string &filepath, bool isStd)

if (isJIT) {
// Link modules together
if (Linker::linkModules(*TheModule, std::move(codegen->TheModule)))
if (Linker::linkModules(*TheModule, std::move(codegen->TheModule), (1 << 0)))
throw CodegenError({}, "Error linking modules together");

// Add function to main module
Module::iterator it;
Module::iterator end = TheModule->end();
for (it = TheModule->begin(); it != end; ++it) {
auto name = std::string{(*it).getName()};
if (!Scope->lookup(name))
Scope->insertSymbol(name, (Value *) &(*it).getFunction(), (*it).getFunctionType());
Scope->insertSymbol(name, (Value *) &(*it).getFunction(), (*it).getFunctionType());
}

} else {
Expand Down
2 changes: 1 addition & 1 deletion src/liblesma/Symbol/SymbolTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ void SymbolTable::insertSymbol(const std::string &name, llvm::Value *value, llvm
}
void SymbolTable::insertSymbol(const std::string &name, llvm::Value *value, llvm::Type *type, bool mutable_) {
// bool isGlobal = getParent() == nullptr;
symbols.insert({name, new SymbolTableEntry(name, value, type, mutable_)});
symbols.insert_or_assign(name, new SymbolTableEntry(name, value, type, mutable_));
// If the symbol is a parameter, add it to the parameters list
// if (isParameter) paramNames.push_back(name);
}
Expand Down

0 comments on commit bad0a28

Please sign in to comment.