wip
This commit is contained in:
@@ -271,10 +271,17 @@ pub enum BaseValue {
|
||||
Nil,
|
||||
Function(LoxFunction),
|
||||
NativeFunction(NativeFunction),
|
||||
Return {
|
||||
value: Box<BaseValue>,
|
||||
labels: Vec<String>,
|
||||
},
|
||||
}
|
||||
|
||||
struct ReturnValue {
|
||||
label: Vec<String>,
|
||||
value: BaseValue,
|
||||
}
|
||||
|
||||
impl ReturnValue {
|
||||
pub fn new(label: Vec<String>, value: BaseValue) -> Self {
|
||||
Self { label, value }
|
||||
}
|
||||
}
|
||||
|
||||
impl BaseValue {
|
||||
@@ -296,9 +303,6 @@ impl Display for BaseValue {
|
||||
BaseValue::Nil => write!(f, "nil"),
|
||||
BaseValue::Function(..) => write!(f, "<fn lox function>"),
|
||||
BaseValue::NativeFunction(..) => write!(f, "<native native function>"),
|
||||
BaseValue::Return { labels, .. } => {
|
||||
write!(f, "<return value [return:{}]>", labels.join(":"))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
use crate::frontend::source_registry::{SourceRegistry, SourceSlice};
|
||||
use std::fmt;
|
||||
use crate::{
|
||||
common::base_value::BaseValue,
|
||||
frontend::source_registry::{SourceRegistry, SourceSlice},
|
||||
};
|
||||
use std::{error::Error, fmt};
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum LoxError {
|
||||
@@ -397,7 +400,7 @@ impl fmt::Display for LoxError {
|
||||
}
|
||||
}
|
||||
|
||||
impl std::error::Error for LoxError {}
|
||||
impl Error for LoxError {}
|
||||
|
||||
pub type LoxResult<T> = Result<T, LoxError>;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user