#![forbid(unsafe_code)]
pub mod arena;
pub mod candidate_codec;
mod compare;
pub mod compile;
pub mod convert;
pub mod debug;
pub mod eval;
pub mod frontier_codec;
pub mod generate;
pub mod handle;
pub mod heap;
pub mod int;
pub mod key;
mod member_index;
pub mod memo;
pub mod node;
pub mod opts;
pub mod owned_exchange;
pub mod plan;
pub mod print;
pub mod random;
pub mod stdlib;
pub mod store;
pub mod strings;
pub mod symmetry;
pub use compile::{Handoff, Role, compile};
pub use eval::Machine;
pub use generate::Sink;
pub use handle::Handle;
pub use heap::Heap;
pub use opts::Opts;
pub use plan::Plan;
pub use store::{Semantics, Store};
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum ErrorKind {
Unsupported,
Eval,
Internal,
Stop,
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct Error(Box<ErrorData>);
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct ErrorData {
pub kind: ErrorKind,
pub message: String,
pub tlc: Option<TlcClass>,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct TlcClass {
pub code: u32,
pub eval_exception: bool,
}
impl TlcClass {
pub const GENERAL: Self = Self {
code: 1000,
eval_exception: false,
};
#[must_use]
pub const fn eval_exception(code: u32) -> Self {
Self {
code,
eval_exception: true,
}
}
}
impl Error {
fn new(kind: ErrorKind, message: String) -> Self {
Self(Box::new(ErrorData {
kind,
message,
tlc: None,
}))
}
#[must_use]
pub fn unsupported(what: impl Into<String>) -> Self {
Self::new(ErrorKind::Unsupported, what.into())
}
#[must_use]
pub fn eval(what: impl Into<String>) -> Self {
Self::new(ErrorKind::Eval, what.into())
}
#[must_use]
pub fn eval_class(tlc: TlcClass, what: impl Into<String>) -> Self {
Self(Box::new(ErrorData {
kind: ErrorKind::Eval,
message: what.into(),
tlc: Some(tlc),
}))
}
#[must_use]
pub fn tlc(&self) -> Option<TlcClass> {
self.0.tlc
}
#[must_use]
pub fn internal(what: impl Into<String>) -> Self {
Self::new(ErrorKind::Internal, what.into())
}
#[must_use]
pub fn stop() -> Self {
Self::new(ErrorKind::Stop, String::new())
}
#[must_use]
pub fn kind(&self) -> ErrorKind {
self.0.kind
}
#[must_use]
pub fn message(&self) -> &str {
&self.0.message
}
#[must_use]
pub fn into_parts(self) -> (ErrorKind, String) {
(self.0.kind, self.0.message)
}
}
impl std::fmt::Display for Error {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(&self.0.message)
}
}
impl std::error::Error for Error {}