Name a persistent region on the evaluation scope

This commit is contained in:
Dennis Kobert
2026-08-29 22:07:27 +00:00
parent 8fd2529e27
commit fe8ca88752

View File

@@ -816,6 +816,9 @@ pub struct EvalScope<'a> {
pointer_position: Option<DVec2>,
generations: &'a [(SourceId, u64)],
arena: &'a Arena,
/// The region no evaluation resets, borrowed for the whole evaluation so
/// the flush's `&mut` cannot land while a value promoted into it is live.
persistent: &'a Arena,
hash: u64,
}
@@ -827,12 +830,19 @@ impl<'a> EvalScope<'a> {
pointer_position,
generations,
arena,
persistent: arena,
hash: 0,
};
scope.hash = scope.compute_hash(|_| true);
scope
}
/// Names the region memo levels are promoted into. A scope that names none
/// promotes into its own arena, so its memos live exactly one generation.
pub fn with_persistent(&self, persistent: &'a Arena) -> EvalScope<'a> {
EvalScope { persistent, ..*self }
}
pub fn with_real_time(&self, real_time: Option<f64>) -> EvalScope<'a> {
let mut scope = EvalScope { real_time, ..*self };
scope.hash = scope.compute_hash(|_| true);
@@ -892,6 +902,10 @@ impl<'a> EvalScope<'a> {
pub fn arena(&self) -> &'a Arena {
self.arena
}
pub fn persistent(&self) -> &'a Arena {
self.persistent
}
}
pub trait ExtractArena {