diff --git a/libserene/include/serene/context.h b/libserene/include/serene/context.h index 5eda08d..4c5908f 100644 --- a/libserene/include/serene/context.h +++ b/libserene/include/serene/context.h @@ -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 T withCurrentNS(llvm::StringRef nsName, CurrentNSFn 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 makeSereneContext(Options opts = Options()); diff --git a/libserene/lib/context.cpp b/libserene/lib/context.cpp index 7c856fc..771ffd9 100644 --- a/libserene/lib/context.cpp +++ b/libserene/lib/context.cpp @@ -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) diff --git a/libserene/lib/diagnostics.cpp b/libserene/lib/diagnostics.cpp index 0716da6..1384d46 100644 --- a/libserene/lib/diagnostics.cpp +++ b/libserene/lib/diagnostics.cpp @@ -185,7 +185,7 @@ std::unique_ptr 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) { diff --git a/libserene/lib/jit/halley.cpp b/libserene/lib/jit/halley.cpp index c4578d1..1b70784 100644 --- a/libserene/lib/jit/halley.cpp +++ b/libserene/lib/jit/halley.cpp @@ -482,8 +482,12 @@ Namespace &Halley::getActiveNS() { return *activeNS; }; llvm::Expected> 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