chore: add HIRBuilder::build_linked_module

This commit is contained in:
Shunsuke Shibayama 2023-07-29 12:01:55 +09:00
parent 23df312cc6
commit dfe62e5173
2 changed files with 11 additions and 3 deletions

View file

@ -11,6 +11,7 @@ use crate::artifact::{BuildRunnable, Buildable, CompleteArtifact, IncompleteArti
use crate::context::{Context, ContextKind, ContextProvider, ModuleContext};
use crate::effectcheck::SideEffectChecker;
use crate::error::{CompileError, CompileErrors, LowerWarnings};
use crate::link_hir::HIRLinker;
use crate::lower::ASTLowerer;
use crate::module::SharedCompilerResource;
use crate::ownercheck::OwnershipChecker;
@ -184,6 +185,13 @@ impl HIRBuilder {
self.build(src, "exec")
}
pub fn build_linked_module(&mut self) -> Result<CompleteArtifact, IncompleteArtifact> {
let artifact = self.build_module()?;
let linker = HIRLinker::new(self.cfg(), self.lowerer.module.context.mod_cache());
let hir = linker.link(artifact.object);
Ok(CompleteArtifact::new(hir, artifact.warns))
}
pub fn pop_mod_ctx(&mut self) -> Option<ModuleContext> {
self.lowerer.pop_mod_ctx()
}