intuicio_backend_vm/lib.rs
1//! A backend that runs script data as it is, without compiling it first.
2//!
3//! A backend turns the operations a frontend produced into a callable function
4//! body. This one keeps the operations and walks them one at a time, which
5//! makes it a virtual machine rather than a compiler.
6//!
7//! [`scope::VmScope`] is the interpreter, and it is also the
8//! `ScriptFunctionGenerator` for this backend, so a whole package installs with
9//! it:
10//!
11//! ```ignore
12//! package.install::<VmScope<MyExpression>>(&mut registry, None);
13//! ```
14//!
15//! The `None` is what the generator takes as input, which here is an optional
16//! debugger. See [`debugger`].
17//!
18//! # Suspending
19//!
20//! A script can stop in the middle with the `Suspend` operation.
21//! [`scope::VmScope::run_until_suspended`] gives control back at that point, and
22//! [`scope::VmScopeFuture`] wraps the same stepping in a [`Future`], so a script
23//! can act as a coroutine.
24//!
25//! [`Future`]: std::future::Future
26pub mod debugger;
27pub mod scope;
28
29use intuicio_core::{IntuicioVersion, crate_version};
30
31/// Returns the version of this crate, for plugins to check against.
32pub fn backend_vm_version() -> IntuicioVersion {
33 crate_version!()
34}