use crate::ast;
use microcad_lang_base::{Id, Span};
#[derive(Debug, PartialEq)]
#[allow(missing_docs)]
pub enum Type {
Single(SingleType),
Array(ArrayType),
Tuple(TupleType),
}
impl Type {
pub fn span(&self) -> Span {
match self {
Type::Single(ty) => ty.span.clone(),
Type::Array(ty) => ty.span.clone(),
Type::Tuple(ty) => ty.span.clone(),
}
}
}
impl ast::Dummy for Type {
fn dummy(span: Span) -> Self {
Type::Single(SingleType {
span,
name: Id::default(),
})
}
}
#[derive(Debug, PartialEq)]
#[allow(missing_docs)]
pub struct SingleType {
pub span: Span,
pub name: Id,
}
#[derive(Debug, PartialEq)]
#[allow(missing_docs)]
pub struct ArrayType {
pub span: Span,
pub inner: Box<Type>,
}
#[derive(Debug, PartialEq)]
#[allow(missing_docs)]
pub struct TupleType {
pub span: Span,
pub inner: Vec<(Option<ast::Identifier>, Type)>,
}
#[derive(Debug, PartialEq, Hash, Eq)]
#[allow(missing_docs)]
pub struct Unit {
pub span: Span,
pub name: Id,
}