Skip to main content

Interpreter

Struct Interpreter 

Source
pub struct Interpreter<'a> {
    pub output: Vec<String>,
    pub current_site: Option<u32>,
    /* private fields */
}

Fields§

§output: Vec<String>

The program’s output lines. Public API consumed by ui_bridge.

§current_site: Option<u32>

The id of the last Stmt::Site marker this task passed through (Wave 3: “runtime failures carry a location”) — None before the first one, or outside any component’s action/handler (## Main/## Test’s own top-level statements carry no marker; their location already comes from Parser::stmt_spans). A runtime error renders with whichever site is current when it is raised; see Stmt::Site’s own doc comment for why “current site” alone is enough with no call stack. Public API consumed by ui_bridge/compile.rs, same as output above, once the failure-site table itself reaches them (FailureSite::render needs this id plus Parser::failure_sites()[id], not this crate’s to build alone yet).

Implementations§

Source§

impl<'a> Interpreter<'a>

Source

pub fn new(interner: &'a Interner) -> Self

Source

pub fn enable_test_mode(&mut self, budget: u64)

Arm test mode (the largo test runner): Expect records-and-continues and every statement counts against the deterministic op budget.

Source

pub fn set_tiers_noop(&mut self, on: bool)

Arm the --tiers all replay profile: test-only statements execute as no-ops (the interpreter twin of the VM’s compile_tiers), so the tier differential compares the COMPUTATION on two engines, one program.

Source

pub fn set_gen_seed(&mut self, seed: u64)

Seed the property-generation stream (the runner keys this by test identity so counterexamples are stable across runs).

Source

pub fn set_prove_mode(&mut self, on: bool)

Enable --prove — finite-domain properties run exhaustively (a proof).

Source

pub fn properties_proven(&self) -> u64

How many properties were PROVED by exhaustion this run.

Source

pub fn take_test_failures(&mut self) -> Vec<String>

Take the recorded expectation failures (empties the sink).

Source

pub fn test_ops(&self) -> u64

Statements executed under test mode — the deterministic op count.

Source

pub fn test_assertions(&self) -> u64

How many assertions (Expect/ForAll) this test executed. Zero = a VACUOUS test the runner must fail (G13).

Source

pub fn with_program_args(self, args: Vec<String>) -> Self

Supply the program arguments read by the args() system native. The vector is the full argv (index 0 is the program name), matching the compiled binary’s env::args().

Source

pub fn with_vfs(self, vfs: Arc<dyn Vfs>) -> Self

Phase 55: Set the VFS for file operations.

Source

pub fn with_kernel(self, ctx: Arc<Context>) -> Self

Phase 102: Set the kernel context for inductive type support.

When set, the interpreter can query the kernel for inductive types and constructors, enabling unified type system.

Source

pub fn with_policies(self, registry: PolicyRegistry) -> Self

Set the policy registry for security checks.

Source

pub fn with_type_registry(self, registry: &TypeRegistry) -> Self

Populate struct_defs from a TypeRegistry (DiscoveryPass results). This allows the interpreter to initialize default field values for structs created with new Point (no explicit fields).

Source

pub fn with_output_callback(self, callback: OutputCallback) -> Self

Set a callback for streaming output. The callback is called each time Show executes, with the output line.

Source

pub fn with_page(self, p: Rc<RefCell<dyn DrivenPage + 'a>>) -> Self

Drive this run’s page through p — the bytecode VM’s lowered page, or a real browser — instead of hosting the page’s lowered program here. The seam a host uses to run a ## Test’s statements ONCE and carry every driving verb (Click, Mount, Navigate, …) to whichever tier p fronts; every other statement (Let, Set, Expect, …) still runs here, against the interpreter’s own evaluator.

Source

pub fn with_statement_observer(self, f: Box<dyn FnMut(usize) + 'a>) -> Self

Observe each top-level statement of run/run_sync by index, right after it finishes.

Source

pub fn host_lowered_page( &mut self, program: &[Stmt<'a>], auto_mounted: Option<String>, ) -> Result<(), DriveError>

Host program as this run’s page, LOWERED, on this very interpreter: the page’s main (program) runs once and settles, and from then on every driving statement this interpreter meets is carried out on the page by the driver every lowered tier shares (crate::page_host::LoweredHost), with this interpreter as the engine it calls into — exactly as a browser drives the page’s module. auto_mounted names the ## Page component the program mounts by itself, if any. A failing main is the page’s failure; the page is hosted either way, as a browser can still call into a module whose main trapped.

Source

pub fn hosted_page_failure(&self) -> Option<String>

The first action failure the page hosted here (Interpreter::host_lowered_page) left unabsorbed by any handler — the page’s own failure to report.

Source

pub fn page_failure_site(&self) -> Option<u32>

Where the page’s first unabsorbed failure happened (its Stmt::Site), when the page is hosted here — the site a located error names, since the host’s call has since returned.

Source

pub fn take_page_failure(&mut self) -> Option<String>

The first action failure no handler absorbed, taken — whichever tier carried the page. A program that ran to the end reports it as its own failure: the page went on answering, and the failure still happened.

Source

pub fn hosted_page_refusal(&self) -> Option<(&Drive, &str)>

The first driving statement the page hosted here could not carry at all, and why — None while every statement has been carried (or answered with a failure of the page’s own).

Source

pub fn run_statements( &mut self, stmts: &[Stmt<'a>], ) -> Result<ControlFlow, String>

Run stmts as the next top-level statements of the program this interpreter is already running — no fresh program start: definitions stay registered, globals stay bound, a hosted page stays hosted — until one returns or breaks, and answer that flow. What a host that walks a test body one step at a time runs each step with.

Source

pub async fn run_statements_async( &mut self, stmts: &[Stmt<'a>], ) -> Result<ControlFlow, String>

Interpreter::run_statements on the async executor, for statements that need it.

Source

pub fn is_kernel_inductive(&self, name: &str) -> bool

Phase 102: Check if a name is a kernel inductive type.

Source

pub fn get_kernel_constructors(&self, name: &str) -> Vec<(String, usize)>

Phase 102: Get constructors for a kernel inductive type.

Returns a vector of (constructor_name, arity) pairs.

Source

pub async fn run(&mut self, stmts: &[Stmt<'a>]) -> Result<(), String>

Execute a program (list of statements), on the async executor.

Source

pub fn values_equal_pub( &self, left: &RuntimeValue, right: &RuntimeValue, ) -> bool

Source

pub fn global_bindings(&self) -> Vec<(String, String, String)>

The program’s global bindings after execution, as sorted (name, type, value) rows — the substrate for the REPL’s :vars inspection (see crate::repl::ReplSession::vars).

Source

pub fn run_sync(&mut self, stmts: &[Stmt<'a>]) -> Result<(), String>

Execute a program synchronously (no async/Future allocation). Use when needs_async(stmts) returns false.

Source

pub fn run_page_main(&mut self, program: &[Stmt<'a>]) -> Result<(), String>

Run the page’s own program once, as a browser runs a page module’s main: its definitions are registered and its top-level statements build the globals every later host call reads (crate::page_host::LoweredCalls). The page arrives in the world its host holds — the document and the storage earlier visits left, which loading a module never clears — so only the engine starts (Interpreter::begin_engine). Its statements are not observed — the page’s main is the page arriving, not a statement of whatever drives it. A failure is the page’s to report and leaves the interpreter callable, as a browser can still call into a module whose main trapped.

Trait Implementations§

Source§

impl<'a> LoweredCalls for Interpreter<'a>

The tree-walker as the engine a lowered page runs on (crate::page_host::LoweredPage’s host calls): the page’s main has run through Interpreter::run_page_main, and every call lands on the globals it built — the same model, the same failure contract and the same refusals as the bytecode VM’s crate::vm::session::Session. A call that fails unwinds every frame, scope and loop it opened and leaves the page callable.

Source§

fn reload(&mut self) -> Result<(), String>

The page’s main run again at the top level, over the globals it builds: every one of them starts over, and a binding the page’s main does not make — whatever drives the page bound for itself — is left exactly as it was.

Source§

fn call( &mut self, name: &str, args: Vec<RuntimeValue>, ) -> Result<RuntimeValue, String>

Source§

fn call_value( &mut self, callee: &RuntimeValue, args: Vec<RuntimeValue>, ) -> Result<RuntimeValue, String>

Source§

fn has(&self, name: &str) -> bool

Source§

fn lines(&self) -> &[String]

Every line the engine has shown, main and every call since, in order.
Source§

fn failure_site(&self) -> Option<u32>

The failure site (Stmt::Site) in force when the most recent failed call trapped — where in the page’s source it failed — for an engine that tracks one.
Source§

fn take_unhandled(&mut self) -> Option<(String, Option<u32>)>

A failure the page’s own code contained while it ran — a turn a driving verb the program runs on its own page took (crate::semantics::builtins::BuiltinId::DomDispatchEntry), whose failure door already heard it and no handler absorbed — with its failure site, for the host to hold as the page’s failure. None for an engine whose entries report through this host alone.

Auto Trait Implementations§

§

impl<'a> Freeze for Interpreter<'a>

§

impl<'a> !RefUnwindSafe for Interpreter<'a>

§

impl<'a> !Send for Interpreter<'a>

§

impl<'a> !Sync for Interpreter<'a>

§

impl<'a> Unpin for Interpreter<'a>

§

impl<'a> UnsafeUnpin for Interpreter<'a>

§

impl<'a> !UnwindSafe for Interpreter<'a>

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
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
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> Same for T

Source§

type Output = T

Should always be Self
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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,