Backup commit

My backspace key started ghosting. Nothing works atm.
This commit is contained in:
2024-01-27 14:50:33 +00:00
parent f77e4fd90a
commit a8887227e5
236 changed files with 10946 additions and 8977 deletions

View File

@@ -1,37 +1,33 @@
use std::fmt::{Debug, Display};
use std::sync::Arc;
use crate::foreign::ExternError;
use crate::{Location, Sym};
use crate::foreign::error::ExternError;
use crate::location::CodeLocation;
use crate::name::Sym;
use super::run::Interrupted;
/// Problems in the process of execution
#[derive(Debug, Clone)]
pub enum RuntimeError {
pub enum RunError {
/// A Rust function encountered an error
Extern(Arc<dyn ExternError>),
/// Primitive applied as function
NonFunctionApplication(Location),
/// Symbol not in context
MissingSymbol(Sym, Location),
MissingSymbol(Sym, CodeLocation),
/// Ran out of gas
Interrupted(Interrupted)
}
impl From<Arc<dyn ExternError>> for RuntimeError {
impl From<Arc<dyn ExternError>> for RunError {
fn from(value: Arc<dyn ExternError>) -> Self { Self::Extern(value) }
}
impl Display for RuntimeError {
impl Display for RunError {
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(location) => {
write!(f, "Primitive applied as function at {}", location)
},
Self::MissingSymbol(sym, loc) => {
write!(
f,
"{}, called at {loc} is not loaded",
sym.extern_vec().join("::")
)
write!(f, "{sym}, called at {loc} is not loaded")
},
}
}