WIP: support cyclic modules

This commit is contained in:
Shunsuke Shibayama 2023-06-28 00:38:41 +09:00
parent f43b683eda
commit 3e137da0a1
12 changed files with 204 additions and 21 deletions

View file

@ -8,12 +8,13 @@ use erg_parser::ast::{VarName, AST};
use erg_parser::build_ast::ASTBuilder;
use crate::artifact::{BuildRunnable, Buildable, CompleteArtifact, IncompleteArtifact};
use crate::context::{Context, ContextProvider, ModuleContext};
use crate::context::{Context, ContextKind, ContextProvider, ModuleContext};
use crate::effectcheck::SideEffectChecker;
use crate::error::{CompileError, CompileErrors, LowerWarnings};
use crate::lower::ASTLowerer;
use crate::module::SharedCompilerResource;
use crate::ownercheck::OwnershipChecker;
use crate::ty::VisibilityModifier;
use crate::varinfo::VarInfo;
/// Summarize lowering, side-effect checking, and ownership checking
@ -134,6 +135,19 @@ impl HIRBuilder {
}
}
pub fn new_with_ctx(mut mod_ctx: ModuleContext) -> Self {
mod_ctx.context.grow(
"<module>",
ContextKind::Module,
VisibilityModifier::Private,
None,
);
Self {
ownership_checker: OwnershipChecker::new(mod_ctx.get_top_cfg()),
lowerer: ASTLowerer::new_with_ctx(mod_ctx),
}
}
pub fn check(&mut self, ast: AST, mode: &str) -> Result<CompleteArtifact, IncompleteArtifact> {
let mut artifact = self.lowerer.lower(ast, mode)?;
let effect_checker = SideEffectChecker::new(self.cfg().clone());