+typesys crate
This commit is contained in:
parent
5a3254004f
commit
5672942c6b
4
Cargo.lock
generated
4
Cargo.lock
generated
|
@ -161,6 +161,10 @@ dependencies = [
|
|||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wafl-typesys"
|
||||
version = "0.1.0"
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.45.0"
|
||||
|
|
8
crates/wafl-typesys/Cargo.toml
Normal file
8
crates/wafl-typesys/Cargo.toml
Normal file
|
@ -0,0 +1,8 @@
|
|||
[package]
|
||||
name = "wafl-typesys"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
33
crates/wafl-typesys/src/lib.rs
Normal file
33
crates/wafl-typesys/src/lib.rs
Normal file
|
@ -0,0 +1,33 @@
|
|||
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_)
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue