Add a todo for another assertion

This commit is contained in:
Sameer Rahmani 2021-08-22 11:09:30 +01:00
parent 36b95fe1e5
commit 6f218d8cab
2 changed files with 13 additions and 12 deletions

View File

@ -52,6 +52,7 @@ bool SereneContext::setCurrentNS(llvm::StringRef ns_name) {
};
std::shared_ptr<Namespace> SereneContext::getCurrentNS() {
// TODO: replace the assertion with a runtime check
assert(!this->current_ns.empty() && "Current namespace is not set");
if (namespaces.count(this->current_ns)) {

View File

@ -65,18 +65,6 @@ mlir::LogicalResult Namespace::setTree(exprs::Ast &t) {
return mlir::success();
}
std::shared_ptr<Namespace>
makeNamespace(SereneContext &ctx, llvm::StringRef name,
llvm::Optional<llvm::StringRef> filename, bool setCurrent) {
auto nsPtr = std::make_shared<Namespace>(ctx, name, filename);
ctx.insertNS(nsPtr);
if (setCurrent) {
if (!ctx.setCurrentNS(nsPtr->name)) {
throw std::runtime_error("Couldn't set the current NS");
}
}
return nsPtr;
};
uint Namespace::nextFnCounter() { return fn_counter++; };
@ -136,4 +124,16 @@ MaybeModule Namespace::compileToLLVM() {
Namespace::~Namespace(){};
std::shared_ptr<Namespace>
makeNamespace(SereneContext &ctx, llvm::StringRef name,
llvm::Optional<llvm::StringRef> filename, bool setCurrent) {
auto nsPtr = std::make_shared<Namespace>(ctx, name, filename);
ctx.insertNS(nsPtr);
if (setCurrent) {
if (!ctx.setCurrentNS(nsPtr->name)) {
throw std::runtime_error("Couldn't set the current NS");
}
}
return nsPtr;
};
} // namespace serene