1#![doc = include_str!("../DOC.md")]
3
4#[cfg(all(feature = "llvm", feature = "cranelift"))]
5compile_error!("Features `llvm` and `cranelift` cannot be enabled at the same time");
6
7#[cfg(not(any(feature = "llvm", feature = "cranelift")))]
8compile_error!("You must enable exactly one of `llvm` or `cranelift` features");
9
10macro_rules! feature_item {
12 ($($item:item)*) => {
13 $(
14 #[cfg(any(
15 all(feature="llvm", not(feature="cranelift")),
16 all(feature="cranelift", not(feature="llvm"))
17 ))]
18 #[cfg(any(feature="llvm", feature="cranelift", doc))]
19 $item
20 )*
21 };
22}
23
24feature_item!(
25 use std::collections::HashMap;
26
27 mod error;
28 mod value;
29 mod target;
30 mod lasm_function;
31 mod compiler;
32 mod ast;
33 mod lexer;
34 mod parser;
35
36 pub use error::{LasmError, Location};
37 pub use value::Value;
38 pub use target::Target;
39 pub use lasm_function::LasmFunction;
40
41 pub fn compile(lasm: &str, target: Target) -> Result<LasmFunction, LasmError> {
50 compiler::compile(lasm, target)
51 }
52
53 pub fn call(
63 function: &LasmFunction,
64 variables: &mut HashMap<String, Value>,
65 ) -> Result<i32, LasmError> {
66 function.call(variables)
67 }
68
69 pub const VERSION: &str = env!("CARGO_PKG_VERSION");
71 pub const USES_LLVM: bool = cfg!(feature = "llvm");
73 pub const USES_CRANELIFT: bool = cfg!(feature = "cranelift");
75 pub const USES_DEBUG: bool = cfg!(feature = "dbg");
77);