man this is bad

This commit is contained in:
Paul Tagliamonte
2025-04-01 15:16:59 -04:00
parent 275c23f294
commit 14d8903acc
2 changed files with 38 additions and 4 deletions

View File

@ -739,7 +739,11 @@ impl ExecutorContext {
) -> Result<(EnvironmentRef, Option<ModelingSessionData>), KclErrorWithOutputs> { ) -> Result<(EnvironmentRef, Option<ModelingSessionData>), KclErrorWithOutputs> {
self.prepare_mem(exec_state).await.unwrap(); self.prepare_mem(exec_state).await.unwrap();
let universe = std::collections::HashMap::new(); // crate::walk::import_universe(&self).await.unwrap(); let mut universe = std::collections::HashMap::new();
crate::walk::import_universe(self, &program.ast, &mut universe)
.await
.unwrap();
for modules in crate::walk::import_graph(&universe).unwrap().into_iter() { for modules in crate::walk::import_graph(&universe).unwrap().into_iter() {
let mut set = JoinSet::new(); let mut set = JoinSet::new();

View File

@ -6,9 +6,10 @@ use std::{
use anyhow::Result; use anyhow::Result;
use crate::{ use crate::{
fs::FileSystem,
parsing::ast::types::{ImportPath, Node as AstNode, NodeRef, Program}, parsing::ast::types::{ImportPath, Node as AstNode, NodeRef, Program},
walk::{Node, Visitable}, walk::{Node, Visitable},
ExecutorContext, ExecutorContext, SourceRange,
}; };
/// Specific dependency between two modules. The 0th element of this tuple /// Specific dependency between two modules. The 0th element of this tuple
@ -126,8 +127,37 @@ pub(crate) fn import_dependencies(prog: NodeRef<Program>) -> Result<Vec<String>>
Ok(ret) Ok(ret)
} }
pub(crate) async fn import_universe(ctx: &ExecutorContext) -> Result<HashMap<String, Program>> { pub(crate) async fn import_universe<'prog>(
panic!("ASF"); ctx: &ExecutorContext,
prog: NodeRef<'prog, Program>,
out: &mut HashMap<String, AstNode<Program>>,
) -> Result<()> {
for module in import_dependencies(prog)? {
eprintln!("{:?}", module);
if out.contains_key(&module) {
continue;
}
// TODO: use open_module and find a way to pass attrs cleanly
let kcl = ctx
.fs
.read_to_string(
ctx.settings
.project_directory
.clone()
.unwrap_or("".into())
.join(&module),
SourceRange::default(),
)
.await?;
let program = crate::parsing::parse_str(&kcl, crate::ModuleId::default()).parse_errs_as_err()?;
out.insert(module.clone(), program.clone());
Box::pin(import_universe(ctx, &program, out)).await?;
}
Ok(())
} }
#[cfg(test)] #[cfg(test)]