Skip to main content

Interp

Struct Interp 

Source
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

Source

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

Source

pub fn run(&mut self, program: &Program) -> DogeResult<()>

Integrate a loaded program and run its entry file to completion.

Source

pub fn prepare(&mut self, program: &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.

Source

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.

Source

pub fn new() -> Interp

A fresh session with only the runtime natives (builtins + stdlib) registered.

Source

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.

Source

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).

Trait Implementations§

Source§

impl Default for Interp

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Interp

§

impl !Send for Interp

§

impl !Sync for Interp

§

impl !UnwindSafe for Interp

§

impl Freeze for Interp

§

impl Unpin for Interp

§

impl UnsafeUnpin for Interp

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.