Skip to main content

ling_codegen/
lib.rs

1//! Code generation backends for Ling.
2
3pub mod bytecode;
4pub mod wasm;
5
6pub mod cranelift;
7
8#[cfg(feature = "llvm")]
9pub mod llvm;
10
11pub struct MirProgram {
12    pub mir: ling_mir::MirProgram,
13    pub name: String,
14}
15
16impl MirProgram {
17    pub fn new(mir: ling_mir::MirProgram, name: impl Into<String>) -> Self {
18        Self { mir, name: name.into() }
19    }
20}
21
22pub trait CodegenBackend {
23    fn emit(&mut self, mir: &MirProgram, out: &std::path::Path) -> anyhow::Result<()>;
24}
25
26pub use bytecode::{BytecodeBackend, Vm, VmProgram, compile_mir_program};
27pub use wasm::WasmBackend;