fusevm/lib.rs
1//! fusevm — Language-agnostic bytecode VM with fused superinstructions.
2//!
3//! Any language frontend can compile to fusevm opcodes and get:
4//! - Fused superinstructions for hot loops (AccumSumLoop, etc.)
5//! - Extension opcode dispatch for language-specific ops
6//! - Stack-based execution with slot-indexed fast paths
7//! - Cranelift JIT compilation for eligible chunks
8//!
9//! ## Architecture
10//!
11//! ```text
12//! stryke source ──→ stryke compiler ──┐
13//! awkrs source ──→ awkrs compiler ├──→ fusevm::Op ──→ VM::run()
14//! zshrs source ──→ shell compiler ──┘
15//! ```
16//!
17//! ## Usage
18//!
19//! ```rust
20//! use fusevm::{Op, ChunkBuilder, VM, VMResult, Value};
21//!
22//! let mut b = ChunkBuilder::new();
23//! b.emit(Op::LoadInt(40), 1);
24//! b.emit(Op::LoadInt(2), 1);
25//! b.emit(Op::Add, 1);
26//!
27//! let mut vm = VM::new(b.build());
28//! match vm.run() {
29//! VMResult::Ok(val) => println!("result: {}", val.to_str()),
30//! VMResult::Error(e) => eprintln!("error: {}", e),
31//! VMResult::Halted => {}
32//! }
33//! ```
34
35pub mod chunk;
36pub mod jit;
37pub mod op;
38pub mod shell_builtins;
39pub mod value;
40pub mod vm;
41
42pub use chunk::{Chunk, ChunkBuilder};
43pub use jit::{JitCompiler, JitExtension, NativeCode};
44pub use op::Op;
45pub use value::Value;
46pub use vm::{Frame, VMResult, VM};