Expand description
Experimental Lehit language frontend and embeddable Cranelift JIT runtime.
§Quick start
Checked execution is the recommended host-facing mode because instrumented runtime failures are returned as structured errors instead of backend traps.
use lehit::runtime::{ExecutionMode, RuntimeBuilder};
let mut runtime = RuntimeBuilder::new()
.with_execution_mode(ExecutionMode::Checked)
.build()?;
runtime.load_script(
"app://entry.lt",
"as fn(argument: usize) -> i32
let values: [i32; 2] = [11, 22] return values[argument]",
)?;
let function = runtime.function("app://entry.lt", "")?.abi_function()?;
let mut call = function.abi_call_builder();
call.push_rust_value_argument(1usize)?;
assert_eq!(call.call()?.into_rust_value::<i32>()?, 22);
let mut call = function.abi_call_builder();
call.push_rust_value_argument(3usize)?;
assert!(matches!(
call.call(),
Err(lehit::runtime::AbiCallError::Execution(status))
if status == lehit::runtime::AbiCallStatus::BOUNDS_VIOLATION
));§Choosing an API
runtimeis the supported embedding and execution facade.rust_libandLehitRegistrationregister trusted native Rust code.parsing::parse_fileis the source-level frontend entry point.semanticexposes the experimental compiler passes and typed IR.core_libexposes the embeddedcore://source modules.guidescontains the long-form documentation rendered on docs.rs.
§Status and trust model
The project is pre-release and is not a sandbox. Checked execution only
covers failures explicitly instrumented by codegen; native pointers, custom
layouts, allocator callbacks, and aggregate byte validity remain trusted-host
responsibilities. Read guides::safety before using native integration.
Modules§
- core_
lib - Embedded
core://source modules. - guides
- Long-form guides rendered directly in docs.rs navigation. Long-form documentation rendered as part of the docs.rs navigation.
- parsing
- Source-level frontend: lexer, grammar, AST, spans, and parse diagnostics.
- prelude
- Common imports for host applications using the high-level runtime API.
- runtime
- High-level runtime facade for loading, executing, reloading, and diagnosing Lehit modules.
- rust_
lib - Declarative integration model for modules, types, and functions supplied by a Rust host.
- semantic
- Semantic frontend: declarations, modules, types, methods, body analysis, and typed IR.
Macros§
Derive Macros§
- Lehit
Registration - Derives native registration metadata for a concrete struct or enum.