math_jit/
error.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
use cranelift::module::ModuleError;
use cranelift_codegen::{settings::SetError, CodegenError};
use thiserror::Error;

#[derive(Error, Debug)]
pub enum JitError {
    #[error("expression cannot be parsed")]
    ParseError(#[from] meval::ParseError),
    #[error("RPN cannot be constructed")]
    RpnConstruction(#[from] meval::RPNError),
    #[error("unknown RPN token `{0}`")]
    ParseUnknownToken(String),
    #[error("unknown variable name `{0}`")]
    ParseUnknownVariable(String),
    #[error("unknown binary operation `{0}`")]
    ParseUnknownBinop(String),
    #[error("unknown unary operation `{0}`")]
    ParseUnknownUnop(String),
    #[error("unknown function call `{0}`")]
    ParseUnknownFunc(String),
    #[error("function not present in library `{0}`")]
    CompileUknownFunc(String),
    #[error("function `{0}` called with {1} args, expected {2}")]
    CompileFuncArgsMismatch(String, usize, usize),
    #[error("internal error `{0}`")]
    CompileInternal(&'static str),
    #[error("couldn't set cranelift setting: {0}")]
    CraneliftSetting(#[from] SetError),
    #[error("module operation failed: {0}")]
    CraneliftModule(#[from] ModuleError),
    #[error("host architecture not supported: {0}")]
    CraneliftHostUnsupported(&'static str),
    #[error("codegen error: {0}")]
    CraneliftCodegenError(#[from] CodegenError),
}