WaFlesh-v1/crates/wafl-typesys/src/lib.rs
2023-05-25 09:14:02 +02:00

34 lines
694 B
Rust

use core::fmt;
use std::collections::BTreeMap;
use std::sync::Arc;
#[derive(Clone, Debug)]
pub enum Type {
Top,
Bot,
Primitive(PrimitiveType),
Union(Vec<Type>),
Inter(Vec<Type>),
Function(Box<(Type, Type)>),
Recursive(Arc<TypeVariable>, Box<Type>),
Variable(Arc<TypeVariable>),
Record(BTreeMap<String, Type>),
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum PrimitiveType {
Integer,
}
#[derive(Debug)]
pub struct TypeVariable {
pub name_hint: String,
pub hash_: u32,
}
impl fmt::Display for TypeVariable {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}:{:x}", self.name_hint, self.hash_)
}
}