refactor: type

This commit is contained in:
2025-05-03 20:33:59 +08:00
parent 3f0cb2c2fa
commit 4a310ff317
23 changed files with 475 additions and 309 deletions

43
src/ty/public/mod.rs Normal file
View File

@@ -0,0 +1,43 @@
use std::fmt::{Debug, Formatter, Result as FmtResult};
use derive_more::{Constructor, IsVariant, Unwrap};
use rpds::{HashTrieMapSync, VectorSync};
use super::common::*;
mod cnst;
pub use cnst::Const;
#[derive(Constructor, Clone, PartialEq)]
pub struct AttrSet {
data: HashTrieMapSync<Symbol, Value>,
}
impl Debug for AttrSet {
fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult {
write!(f, "{{ ")?;
for (k, v) in self.data.iter() {
write!(f, "{k:?} = {v:?}; ")?;
}
write!(f, "}}")
}
}
#[derive(Constructor, Clone, Debug, PartialEq)]
pub struct List {
data: VectorSync<Value>,
}
#[derive(IsVariant, Unwrap, Clone, Debug, PartialEq)]
pub enum Value {
Const(Const),
AttrSet(AttrSet),
List(List),
Catchable(Catchable),
Thunk,
Func,
PrimOp,
PartialPrimOp,
}