Fix the unchecked Expected<T> in the context class
This commit is contained in:
parent
bf0e24d75e
commit
8dde04d6ce
|
@ -127,8 +127,7 @@ public:
|
|||
|
||||
/// Execute the given function \p f by setting the `currentNS`
|
||||
/// to the given \p nsName. It will restore the value of `currentNS`
|
||||
/// after \p f returned. It also passes the old value of `currentNS`
|
||||
/// to \p f.
|
||||
/// after \p f returned.
|
||||
template <typename T>
|
||||
T withCurrentNS(llvm::StringRef nsName, CurrentNSFn<T> f) {
|
||||
assert(!currentNS.empty() && "The currentNS is not initialized!");
|
||||
|
@ -215,8 +214,8 @@ public:
|
|||
auto maybeJIT = serene::jit::makeHalleyJIT(*ctx);
|
||||
|
||||
if (!maybeJIT) {
|
||||
// TODO: Raise an error here
|
||||
return nullptr;
|
||||
auto err = maybeJIT.takeError();
|
||||
panic(*ctx, err);
|
||||
}
|
||||
|
||||
ctx->jit.swap(*maybeJIT);
|
||||
|
@ -278,7 +277,10 @@ private:
|
|||
};
|
||||
|
||||
/// Creates a new context object. Contexts are used through out the compilation
|
||||
/// process to store the state
|
||||
/// process to store the state.
|
||||
///
|
||||
/// \p opts is an instance of \c Options that can be used to set options of
|
||||
/// of the compiler.
|
||||
SERENE_EXPORT std::unique_ptr<SereneContext>
|
||||
makeSereneContext(Options opts = Options());
|
||||
|
||||
|
|
|
@ -43,7 +43,6 @@ Namespace *SereneContext::getNS(llvm::StringRef nsName) {
|
|||
};
|
||||
|
||||
Namespace &SereneContext::getCurrentNS() {
|
||||
llvm::outs() << this->currentNS << "\n";
|
||||
if (this->currentNS.empty() || (namespaces.count(this->currentNS) == 0)) {
|
||||
panic(*this, llvm::formatv("getCurrentNS: Namespace '{0}' does not exist",
|
||||
this->currentNS)
|
||||
|
|
|
@ -185,7 +185,7 @@ std::unique_ptr<DiagnosticEngine> makeDiagnosticEngine(SereneContext &ctx) {
|
|||
void DiagnosticEngine::emit(const llvm::Error &err) {
|
||||
UNUSED(ctx);
|
||||
// TODO: create a diag and print it
|
||||
llvm::errs() << err << "\n";
|
||||
llvm::errs() << "[Error]: " << err << "\n";
|
||||
};
|
||||
|
||||
// void DiagnosticEngine::emit(const llvm::Error &errs) {
|
||||
|
|
|
@ -482,8 +482,12 @@ Namespace &Halley::getActiveNS() { return *activeNS; };
|
|||
llvm::Expected<std::unique_ptr<Halley>> makeHalleyJIT(SereneContext &ctx) {
|
||||
|
||||
llvm::orc::JITTargetMachineBuilder jtmb(ctx.getTargetTriple());
|
||||
auto maybeJIT = Halley::make(ctx, std::move(jtmb));
|
||||
if (!maybeJIT) {
|
||||
return maybeJIT.takeError();
|
||||
}
|
||||
|
||||
return Halley::make(ctx, std::move(jtmb));
|
||||
return maybeJIT;
|
||||
};
|
||||
} // namespace jit
|
||||
} // namespace serene
|
||||
|
|
Loading…
Reference in New Issue