pub struct EvalContext {Show 18 fields
pub module_cache: RefCell<BTreeMap<PathBuf, BTreeMap<String, Value>>>,
pub current_file: RefCell<Vec<PathBuf>>,
pub module_exports: RefCell<Vec<Option<Vec<String>>>>,
pub module_load_stack: RefCell<Vec<PathBuf>>,
pub call_stack: RefCell<Vec<CallFrame>>,
pub span_table: RefCell<HashMap<usize, Span>>,
pub eval_depth: Cell<usize>,
pub max_eval_depth: Cell<usize>,
pub eval_step_limit: Cell<usize>,
pub eval_steps: Cell<usize>,
pub eval_deadline: Cell<Option<Instant>>,
pub sandbox: Sandbox,
pub user_context: RefCell<Vec<BTreeMap<Value, Value>>>,
pub hidden_context: RefCell<Vec<BTreeMap<Value, Value>>>,
pub context_stacks: RefCell<BTreeMap<Value, Vec<Value>>>,
pub eval_fn: Cell<Option<EvalCallbackFn>>,
pub call_fn: Cell<Option<CallCallbackFn>>,
pub interactive: Cell<bool>,
}Fields§
§module_cache: RefCell<BTreeMap<PathBuf, BTreeMap<String, Value>>>§current_file: RefCell<Vec<PathBuf>>§module_exports: RefCell<Vec<Option<Vec<String>>>>§module_load_stack: RefCell<Vec<PathBuf>>§call_stack: RefCell<Vec<CallFrame>>§span_table: RefCell<HashMap<usize, Span>>§eval_depth: Cell<usize>§max_eval_depth: Cell<usize>§eval_step_limit: Cell<usize>§eval_steps: Cell<usize>§eval_deadline: Cell<Option<Instant>>Optional wall-clock deadline for evaluation. When set, both the tree-walker and the bytecode VM periodically check whether the current time has passed this instant and, if so, abort with an error. Used by the notebook engine to bound how long a single cell evaluation can run.
sandbox: Sandbox§user_context: RefCell<Vec<BTreeMap<Value, Value>>>§context_stacks: RefCell<BTreeMap<Value, Vec<Value>>>§eval_fn: Cell<Option<EvalCallbackFn>>§call_fn: Cell<Option<CallCallbackFn>>§interactive: Cell<bool>Implementations§
Source§impl EvalContext
impl EvalContext
pub fn new() -> Self
pub fn new_with_sandbox(sandbox: Sandbox) -> Self
pub fn push_file_path(&self, path: PathBuf)
pub fn pop_file_path(&self)
pub fn current_file_dir(&self) -> Option<PathBuf>
pub fn current_file_path(&self) -> Option<PathBuf>
pub fn get_cached_module( &self, path: &PathBuf, ) -> Option<BTreeMap<String, Value>>
pub fn cache_module(&self, path: PathBuf, exports: BTreeMap<String, Value>)
pub fn set_module_exports(&self, names: Vec<String>)
pub fn clear_module_exports(&self)
pub fn take_module_exports(&self) -> Option<Vec<String>>
pub fn begin_module_load(&self, path: &PathBuf) -> Result<(), SemaError>
pub fn end_module_load(&self, path: &PathBuf)
pub fn push_call_frame(&self, frame: CallFrame)
pub fn call_stack_depth(&self) -> usize
pub fn truncate_call_stack(&self, depth: usize)
pub fn capture_stack_trace(&self) -> StackTrace
pub fn merge_span_table(&self, spans: SpanMap)
pub fn lookup_span(&self, ptr: usize) -> Option<Span>
pub fn set_eval_step_limit(&self, limit: usize)
Sourcepub fn set_eval_deadline(&self, deadline: Option<Instant>)
pub fn set_eval_deadline(&self, deadline: Option<Instant>)
Set a wall-clock deadline after which evaluation should abort.
Passing None clears any existing deadline.
Sourcepub fn deadline_exceeded(&self) -> bool
pub fn deadline_exceeded(&self) -> bool
Returns true if a deadline is set and has been exceeded.
Sourcepub fn check_deadline(&self) -> Result<(), SemaError>
pub fn check_deadline(&self) -> Result<(), SemaError>
Returns an eval error if a deadline is set and exceeded; otherwise Ok(()).
Sourcepub fn check_loop_interrupt(&self) -> Result<(), SemaError>
pub fn check_loop_interrupt(&self) -> Result<(), SemaError>
Per-iteration loop/recursion guard, called by the VM at loop back-edges and frame transitions. Counts a step and aborts when:
- the step limit is exceeded (wasm-safe runaway-loop guard — the wall clock is unavailable in wasm, so the step counter is the guard there);
- the wall-clock deadline is exceeded (native);
- a cancellation has been requested (e.g. the playground Stop button).
The step compare runs every call (cheap); the clock read and the
cancellation thread-local read run only periodically to keep tight loops
fast. eval_steps is reset per top-level eval by the evaluator.