1use cranelift::module::ModuleError;
2use cranelift_codegen::{settings::SetError, CodegenError};
3use thiserror::Error;
4
5#[derive(Error, Debug)]
6pub enum JitError {
7 #[error("expression cannot be parsed")]
8 ParseError(#[from] meval::ParseError),
9 #[error("RPN cannot be constructed")]
10 RpnConstruction(#[from] meval::RPNError),
11 #[error("unknown RPN token `{0}`")]
12 ParseUnknownToken(String),
13 #[error("unknown variable name `{0}`")]
14 ParseUnknownVariable(String),
15 #[error("unknown binary operation `{0}`")]
16 ParseUnknownBinop(String),
17 #[error("unknown unary operation `{0}`")]
18 ParseUnknownUnop(String),
19 #[error("unknown function call `{0}`")]
20 ParseUnknownFunc(String),
21 #[error("function not present in library `{0}`")]
22 CompileUknownFunc(String),
23 #[error("function `{0}` called with {1} args, expected {2}")]
24 CompileFuncArgsMismatch(String, usize, usize),
25 #[error("internal error `{0}`")]
26 CompileInternal(&'static str),
27 #[error("couldn't set cranelift setting: {0}")]
28 CraneliftSetting(#[from] SetError),
29 #[error("module operation failed: {0}")]
30 CraneliftModule(#[from] ModuleError),
31 #[error("host architecture not supported: {0}")]
32 CraneliftHostUnsupported(&'static str),
33 #[error("codegen error: {0}")]
34 CraneliftCodegenError(#[from] CodegenError),
35}