Skip to main content

vibe/eval/
stack.rs

1//! Stack admission shared across expression evaluation and nested function calls.
2use super::*;
3
4impl<'a, H: Host> Engine<'a, H> {
5    /// Evaluate once; the source-session profile supplies a total expression
6    /// depth bound so independent call/path limits cannot multiply unchecked.
7    pub fn eval_expr(&mut self, expr: &Expr, env: &mut Env) -> Result<Value, Diagnostic> {
8        if self.expression_depth >= self.expression_depth_limit {
9            return Err(Diagnostic::new(
10                DiagCode::E400,
11                expr.span,
12                "source-session expression evaluation depth exceeded",
13            ));
14        }
15        self.expression_depth += 1;
16        let result = self.eval_expr_inner(expr, env);
17        self.expression_depth -= 1;
18        result
19    }
20}