add adts to type system
This commit is contained in:
parent
c0be718bbc
commit
86e3bf4d32
|
@ -25,10 +25,8 @@ enum TypeKind {
|
|||
ElabType(ElabKind),
|
||||
/// Signal/Wire of generic width
|
||||
Logic(ElabData),
|
||||
/// UInt of generic width
|
||||
UInt(ElabData),
|
||||
/// Callable
|
||||
Callable(FnSig),
|
||||
/// User-defined ADT
|
||||
Adt(Adt),
|
||||
/// A type that was not given and needs to be inferred
|
||||
Infer,
|
||||
/// A reference to a type variable as DeBruijn index
|
||||
|
@ -37,9 +35,13 @@ enum TypeKind {
|
|||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct FnSig {
|
||||
params: Vec<Type>,
|
||||
ret: Type,
|
||||
pub enum Adt {
|
||||
Struct(Struct),
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Struct {
|
||||
members: Vec<Type>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
|
@ -182,8 +184,7 @@ impl TypingContext {
|
|||
ElabValueData::Bytes(_) => None,
|
||||
},
|
||||
},
|
||||
TypeKind::UInt(_) => todo!(),
|
||||
TypeKind::Callable(_) => None,
|
||||
TypeKind::Adt(_) => todo!("calculate struct width"),
|
||||
TypeKind::Infer => None,
|
||||
TypeKind::TypeVar(_, _) => None,
|
||||
}
|
||||
|
@ -214,8 +215,7 @@ impl TypingContext {
|
|||
None
|
||||
}
|
||||
}
|
||||
TypeKind::UInt(_) => todo!(),
|
||||
TypeKind::Callable(_sig) => todo!("callable generic params"),
|
||||
TypeKind::Adt(_) => todo!("can not parameterize struct"),
|
||||
// need to know what the type is to parameterize it
|
||||
TypeKind::Infer | &TypeKind::TypeVar(_, _) => None,
|
||||
}
|
||||
|
@ -248,8 +248,7 @@ impl TypingContext {
|
|||
TypeKind::Logic(data) => {
|
||||
matches!(data.value, ElabValue::Concrete(_))
|
||||
}
|
||||
TypeKind::UInt(_) => todo!(),
|
||||
TypeKind::Callable(_) => todo!(),
|
||||
TypeKind::Adt(_) => todo!("adt fully typed"),
|
||||
TypeKind::Infer => false,
|
||||
TypeKind::TypeVar(dbi, _tvar) => {
|
||||
// if the DeBruijn index is 0, there is no further information to gain
|
||||
|
@ -283,9 +282,8 @@ impl TypingContext {
|
|||
self.pretty_value(&mut width, val)?;
|
||||
write!(w, "Logic<{}>", width)
|
||||
}
|
||||
TypeKind::Adt(_) => write!(w, "Struct{{...}}"),
|
||||
TypeKind::Infer => write!(w, "?"),
|
||||
TypeKind::UInt(_) => todo!("print uint"),
|
||||
TypeKind::Callable(_sig) => todo!("print callable"),
|
||||
TypeKind::TypeVar(_, tvar) => write!(w, "T{}", tvar),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue