Skip to main content

candela_vm/
lib.rs

1//! `candela-vm` is the self-contained runtime core for candela.
2//!
3//! This crate is everything needed to load and run candela bytecode, and
4//! nothing else: the register VM ([`vm::execute`]), the bytecode instruction set
5//! ([`instr`]), the NaN-boxed value representation ([`data`]) and shared runtime
6//! types ([`rt`]), the garbage collector, the host/script value marshalling
7//! ([`embed`]), the runtime error/diagnostic machinery ([`errors`]), and the
8//! `.cdlb` artifact format ([`artifact`]).
9//!
10//! It depends on nothing from the compiler (`candela`) crate. Both the
11//! `candela-vm` binary and the full `candela` compiler binary link this one VM,
12//! so the executor is never duplicated.
13
14pub mod data;
15pub mod errors;
16pub mod instr;
17pub mod rt;
18
19#[path = "vm.rs"]
20pub mod vm;
21
22pub mod embed;
23
24// json parse/stringify over the runtime value graph, backing `std/json`.
25pub mod json;
26
27// The standard library's native functions, built in where no dynamic library
28// can be loaded.
29#[cfg(any(target_arch = "wasm32", test))]
30pub mod intrinsics;
31
32// The `.cdlb` bytecode artifact format plus the load/run API.
33pub mod artifact;
34
35// Loading and calling the machine code a `.cdlb` carries.
36pub mod native;
37
38// The garbage collector. Internal to the runtime; its state is reached through
39// `rt::Pools`.
40mod gc;
41
42// Routes program output and error reports to the process streams, or into a
43// buffer that an embedding host reads back.
44pub mod captured_output;
45
46// ---- public runtime API ----
47pub use errors::Diagnostic;
48pub use errors::ErrorCtx;
49pub use errors::RuntimeError;
50pub use errors::collect_diagnostic;
51
52pub use embed::FromHostValue;
53pub use embed::HostBindError;
54pub use embed::HostError;
55pub use embed::HostRegistry;
56pub use embed::HostType;
57pub use embed::IntoHostFn;
58pub use embed::IntoHostResult;
59pub use embed::IntoHostValue;
60pub use embed::Value;
61pub use embed::marshal_args;
62pub use embed::marshal_value;
63pub use embed::unmarshal_value;
64
65pub use artifact::CallError;
66pub use artifact::LoadError;
67pub use artifact::RuntimeProgram;
68pub use artifact::load_program;
69
70// What the collector has done, for a host that collects between frames.
71pub use gc::GcStats;
72pub use gc::PoolStats;
73
74// Where a `dylib` import looks for its library file.
75pub use rt::dylib_dirs;
76pub use rt::set_dylib_dirs;
77// How many leading command-line arguments `argv()` steps over.
78pub use rt::argv_skip;
79pub use rt::set_argv_skip;