fic/base/types.rs
1//! A type as written, its names resolved: what a declaration's annotation
2//! denotes before typing. `tast` lowers it to its `Ty`.
3
4use serde::Serialize;
5
6use crate::ast::PrimitiveType;
7
8use super::id::{ConstId, StructId};
9
10/// A type as written, its names resolved.
11#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
12pub enum TypeRef {
13 /// `int32`, `bool`, `Address`, ...
14 Prim(PrimitiveType),
15 /// A struct.
16 Struct(StructId),
17 /// `T[N]`.
18 Array {
19 /// Element type.
20 elem: Box<TypeRef>,
21 /// Element count.
22 len: ArrayLen,
23 },
24}
25
26/// An array's element count.
27#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize)]
28pub enum ArrayLen {
29 /// A literal count.
30 Lit(u64),
31 /// A system const.
32 Const(ConstId),
33}