bug fixes and performance improvements

This commit is contained in:
2023-05-07 22:35:38 +01:00
parent f3ce910f66
commit a604e40bad
167 changed files with 5965 additions and 4229 deletions

27
src/interpreter/error.rs Normal file
View File

@@ -0,0 +1,27 @@
use std::fmt::Display;
use std::rc::Rc;
use crate::representations::interpreted::ExprInst;
use crate::foreign::ExternError;
/// Problems in the process of execution
#[derive(Clone)]
pub enum RuntimeError {
Extern(Rc<dyn ExternError>),
NonFunctionApplication(ExprInst),
}
impl From<Rc<dyn ExternError>> for RuntimeError {
fn from(value: Rc<dyn ExternError>) -> Self {
Self::Extern(value)
}
}
impl Display for RuntimeError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::Extern(e) => write!(f, "Error in external function: {e}"),
Self::NonFunctionApplication(loc) => write!(f, "Primitive applied as function at {loc:?}")
}
}
}