impl Buildable for HIRBuilder, Transpiler

This commit is contained in:
Shunsuke Shibayama 2022-12-12 00:21:27 +09:00
parent 87d13b8f09
commit e07b0dfa67
3 changed files with 40 additions and 4 deletions

View file

@ -6,7 +6,7 @@ use erg_common::Str;
use erg_parser::ast::{VarName, AST};
use erg_parser::build_ast::ASTBuilder;
use crate::artifact::{CompleteArtifact, IncompleteArtifact};
use crate::artifact::{Buildable, CompleteArtifact, IncompleteArtifact};
use crate::context::{Context, ContextProvider};
use crate::effectcheck::SideEffectChecker;
use crate::error::{CompileError, CompileErrors};
@ -72,6 +72,18 @@ impl Runnable for HIRBuilder {
}
}
impl Buildable for HIRBuilder {
fn build(&mut self, src: String, mode: &str) -> Result<CompleteArtifact, IncompleteArtifact> {
self.build(src, mode)
}
fn pop_context(&mut self) -> Option<Context> {
Some(self.pop_mod_ctx())
}
fn get_context(&self) -> Option<&Context> {
Some(&self.lowerer.ctx)
}
}
impl ContextProvider for HIRBuilder {
fn dir(&self) -> Vec<(&VarName, &VarInfo)> {
self.lowerer.dir()