feat: less clone, avoid evaluating not depended thunk

This commit is contained in:
2025-06-18 09:32:00 +08:00
parent 3e9f0a72a0
commit d875951c09
14 changed files with 409 additions and 192 deletions

View File

@@ -9,7 +9,7 @@ use crate::{
use super::{Dep, Func, Ir, LoadFunc, MaybeThunk, SccAnalyzer, SccNode, Thunk};
#[derive(Clone, Copy, Unwrap)]
#[derive(Clone, Copy, Unwrap, Debug)]
pub enum Index {
Thunk(usize),
Func(usize),
@@ -169,9 +169,11 @@ impl DowngradeContext {
}
pub fn new_dep(&mut self, this: Index, dep: Dep) -> Result<()> {
#[cfg(debug_assertions)]
println!("{this:?} => {dep:?}");
match this {
Index::Thunk(idx) => {
if dep == Dep::Thunk(idx) {
if dep == Dep::Thunk(idx) && !matches!(self.thunks[idx].0, Ir::List(_)) {
return Err(Error::DowngradeError(
"infinite recursion encountered".into(),
));