mirror of
https://github.com/erg-lang/erg.git
synced 2025-09-28 12:14:43 +00:00
feat: add BuildRunnable::build_module
This commit is contained in:
parent
32a7780581
commit
60f82ba2c1
4 changed files with 21 additions and 1 deletions
|
@ -103,4 +103,9 @@ pub trait Buildable<T = HIR> {
|
|||
fn get_context(&self) -> Option<&ModuleContext>;
|
||||
}
|
||||
|
||||
pub trait BuildRunnable<T = HIR>: Buildable<T> + Runnable + 'static {}
|
||||
pub trait BuildRunnable<T = HIR>: Buildable<T> + Runnable + 'static {
|
||||
fn build_module(&mut self) -> Result<CompleteArtifact<T>, IncompleteArtifact<T>> {
|
||||
let src = self.cfg_mut().input.read();
|
||||
self.build(src, "exec")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -179,6 +179,11 @@ impl HIRBuilder {
|
|||
self.check(artifact.ast, mode)
|
||||
}
|
||||
|
||||
pub fn build_module(&mut self) -> Result<CompleteArtifact, IncompleteArtifact> {
|
||||
let src = self.cfg_mut().input.read();
|
||||
self.build(src, "exec")
|
||||
}
|
||||
|
||||
pub fn pop_mod_ctx(&mut self) -> Option<ModuleContext> {
|
||||
self.lowerer.pop_mod_ctx()
|
||||
}
|
||||
|
|
|
@ -239,6 +239,11 @@ impl Compiler {
|
|||
Ok(CompleteArtifact::new(codeobj, arti.warns))
|
||||
}
|
||||
|
||||
pub fn compile_module(&mut self) -> Result<CompleteArtifact<CodeObj>, ErrorArtifact> {
|
||||
let src = self.cfg.input.read();
|
||||
self.compile(src, "exec")
|
||||
}
|
||||
|
||||
pub fn eval_compile(
|
||||
&mut self,
|
||||
src: String,
|
||||
|
|
|
@ -223,6 +223,11 @@ impl Transpiler {
|
|||
Ok(CompleteArtifact::new(script, artifact.warns))
|
||||
}
|
||||
|
||||
pub fn transpile_module(&mut self) -> Result<CompleteArtifact<PyScript>, ErrorArtifact> {
|
||||
let src = self.cfg.input.read();
|
||||
self.transpile(src, "exec")
|
||||
}
|
||||
|
||||
fn build_link_desugar(
|
||||
&mut self,
|
||||
src: String,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue