pub struct Interp { /* private fields */ }Expand description
An interpreter session. Holds the program-wide callable and class tables, one
scope per file, and the mutable run state (recursion depth, current location).
A doge repl session reuses one Interp across snippets, so bindings persist.
Implementations§
Source§impl Interp
impl Interp
Sourcepub fn call_entry_function(&mut self, name: &str) -> DogeResult<Value>
pub fn call_entry_function(&mut self, name: &str) -> DogeResult<Value>
Call a top-level function of the entry file by name with no arguments,
returning its value or the (catchable) error it raised. The test runner
drives each discovered test-prefixed function through this, after
Interp::prepare has integrated the program.
Source§impl Interp
impl Interp
Sourcepub fn run(&mut self, program: Arc<Program>) -> DogeResult<()>
pub fn run(&mut self, program: Arc<Program>) -> DogeResult<()>
Integrate a loaded program and run its entry file to completion.
Sourcepub fn prepare(&mut self, program: Arc<Program>) -> DogeResult<()>
pub fn prepare(&mut self, program: Arc<Program>) -> DogeResult<()>
Integrate a loaded program without running its entry body — the setup the
test runner needs before it drives individual test-prefixed functions with
[call_entry_function]. A module constant initializer that failed during
integration surfaces here, just as it would when the entry runs.
Sourcepub fn error_site(&self) -> (usize, u32)
pub fn error_site(&self) -> (usize, u32)
The file id and line the interpreter last executed — the site of an uncaught error, for the caller to render a doge-flavored location.
Sourcepub fn new() -> Interp
pub fn new() -> Interp
A fresh session with only the runtime natives (builtins + stdlib) registered.
Sourcepub fn session_scope(&self) -> SessionScope
pub fn session_scope(&self) -> SessionScope
The session’s accumulated top-level scope, for seeding the checker of the next snippet. Built from live interpreter state so the checker and runtime never disagree about what is in scope.
Sourcepub fn eval_snippet(
&mut self,
path: &str,
script: &Script,
) -> DogeResult<Option<Value>>
pub fn eval_snippet( &mut self, path: &str, script: &Script, ) -> DogeResult<Option<Value>>
Evaluate one checked REPL snippet in the session: integrate its definitions,
run its statements, and return the value of a trailing bare expression for
the prompt to echo (None when the last statement is not a bare expression).