Begin generating semantic reprs for records

This commit is contained in:
Ayaz Hafiz 2023-05-10 15:38:25 -05:00
parent 6714a6fd92
commit c06ffc434b
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58
4 changed files with 40 additions and 12 deletions

View file

@ -0,0 +1,24 @@
//! Semantic representations of memory layouts for the purposes of specialization.
/// A semantic representation of a memory layout.
/// Semantic representations describe the shape of a type a [Layout][super::Layout] is generated
/// for. Semantic representations disambiguate types that have the same runtime memory layout, but
/// different shapes.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub enum SemanticRepr<'a> {
None,
Record(SemaRecord<'a>),
}
impl<'a> SemanticRepr<'a> {
pub(super) const EMPTY_RECORD: Self = Self::Record(SemaRecord { fields: &[] });
pub(super) fn record(fields: &'a [&'a str]) -> Self {
Self::Record(SemaRecord { fields })
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct SemaRecord<'a> {
pub fields: &'a [&'a str],
}