feat: SCC analysis (WIP)

This commit is contained in:
2025-06-15 17:23:32 +08:00
parent 7b6db44207
commit b2d2490327
13 changed files with 842 additions and 352 deletions

View File

@@ -1,12 +1,9 @@
use std::rc::Rc;
use ecow::EcoVec;
use crate::engine::Engine;
use crate::env::VmEnv;
use crate::error::{Error, Result};
use crate::ir::{self, DynamicAttrPair};
use crate::ty::common::Const;
use crate::ir::{self, DynAttr}; use crate::ty::common::Const;
use crate::ty::internal::{AttrSet, EnvRef, List, ThunkRef, Value};
use crate::ty::public::Symbol;
@@ -32,7 +29,7 @@ impl Evaluate for ir::Attrs {
})
.collect::<Result<_>>()?,
);
for DynamicAttrPair(k, v) in self.dyns {
for DynAttr(k, v) in self.dyns {
let mut k = k.eval(engine, env)?;
k.force(engine)?.coerce_to_string();
attrs.push_attr(k.unwrap_string(), v.eval(engine, env)?);
@@ -315,6 +312,15 @@ impl Evaluate for ir::Thunk {
}
}
impl Evaluate for ir::MaybeThunk {
fn eval(self, engine: &mut Engine, env: &mut VmEnv) -> Result<Value> {
match self {
ir::MaybeThunk::Const(cnst) => cnst.eval(engine, env),
ir::MaybeThunk::Thunk(thunk) => thunk.eval(engine, env)
}
}
}
impl Evaluate for ir::Path {
fn eval(self, engine: &mut Engine, env: &mut VmEnv) -> Result<Value> {
todo!()