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>
impl<'a> Interpreter<'a>
pub fn new(interner: &'a Interner) -> Self
Sourcepub fn enable_test_mode(&mut self, budget: u64)
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.
Sourcepub fn set_tiers_noop(&mut self, on: bool)
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.
Sourcepub fn set_gen_seed(&mut self, seed: u64)
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).
Sourcepub fn set_prove_mode(&mut self, on: bool)
pub fn set_prove_mode(&mut self, on: bool)
Enable --prove — finite-domain properties run exhaustively (a proof).
Sourcepub fn properties_proven(&self) -> u64
pub fn properties_proven(&self) -> u64
How many properties were PROVED by exhaustion this run.
Sourcepub fn take_test_failures(&mut self) -> Vec<String>
pub fn take_test_failures(&mut self) -> Vec<String>
Take the recorded expectation failures (empties the sink).
Sourcepub fn test_ops(&self) -> u64
pub fn test_ops(&self) -> u64
Statements executed under test mode — the deterministic op count.
Sourcepub fn test_assertions(&self) -> u64
pub fn test_assertions(&self) -> u64
How many assertions (Expect/ForAll) this test executed. Zero = a
VACUOUS test the runner must fail (G13).
Sourcepub fn with_program_args(self, args: Vec<String>) -> Self
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().
Sourcepub fn with_kernel(self, ctx: Arc<Context>) -> Self
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.
Sourcepub fn with_policies(self, registry: PolicyRegistry) -> Self
pub fn with_policies(self, registry: PolicyRegistry) -> Self
Set the policy registry for security checks.
Sourcepub fn with_type_registry(self, registry: &TypeRegistry) -> Self
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).
Sourcepub fn with_output_callback(self, callback: OutputCallback) -> Self
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.
Sourcepub fn with_page(self, p: Rc<RefCell<dyn DrivenPage + 'a>>) -> Self
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.
Sourcepub fn with_statement_observer(self, f: Box<dyn FnMut(usize) + 'a>) -> Self
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.
Sourcepub fn host_lowered_page(
&mut self,
program: &[Stmt<'a>],
auto_mounted: Option<String>,
) -> Result<(), DriveError>
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.
Sourcepub fn hosted_page_failure(&self) -> Option<String>
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.
Sourcepub fn page_failure_site(&self) -> Option<u32>
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.
Sourcepub fn take_page_failure(&mut self) -> Option<String>
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.
Sourcepub fn hosted_page_refusal(&self) -> Option<(&Drive, &str)>
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).
Sourcepub fn run_statements(
&mut self,
stmts: &[Stmt<'a>],
) -> Result<ControlFlow, String>
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.
Sourcepub async fn run_statements_async(
&mut self,
stmts: &[Stmt<'a>],
) -> Result<ControlFlow, String>
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.
Sourcepub fn is_kernel_inductive(&self, name: &str) -> bool
pub fn is_kernel_inductive(&self, name: &str) -> bool
Phase 102: Check if a name is a kernel inductive type.
Sourcepub fn get_kernel_constructors(&self, name: &str) -> Vec<(String, usize)>
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.
Sourcepub async fn run(&mut self, stmts: &[Stmt<'a>]) -> Result<(), String>
pub async fn run(&mut self, stmts: &[Stmt<'a>]) -> Result<(), String>
Execute a program (list of statements), on the async executor.
pub fn values_equal_pub( &self, left: &RuntimeValue, right: &RuntimeValue, ) -> bool
Sourcepub fn global_bindings(&self) -> Vec<(String, String, String)>
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).
Sourcepub fn run_sync(&mut self, stmts: &[Stmt<'a>]) -> Result<(), String>
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.
Sourcepub fn run_page_main(&mut self, program: &[Stmt<'a>]) -> Result<(), String>
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.
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>
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.
fn call( &mut self, name: &str, args: Vec<RuntimeValue>, ) -> Result<RuntimeValue, String>
fn call_value( &mut self, callee: &RuntimeValue, args: Vec<RuntimeValue>, ) -> Result<RuntimeValue, String>
fn has(&self, name: &str) -> bool
Source§fn lines(&self) -> &[String]
fn lines(&self) -> &[String]
Source§fn failure_site(&self) -> Option<u32>
fn failure_site(&self) -> Option<u32>
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>)>
fn take_unhandled(&mut self) -> Option<(String, Option<u32>)>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.