mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-27 13:59:08 +00:00
Begin generating semantic reprs for records
This commit is contained in:
parent
6714a6fd92
commit
c06ffc434b
4 changed files with 40 additions and 12 deletions
|
@ -127,7 +127,7 @@ impl<'a> Layout<'a> {
|
|||
field_layouts: &[],
|
||||
field_order_hash: FieldOrderHash::ZERO_FIELD_HASH,
|
||||
},
|
||||
semantic: SemanticRepr::None,
|
||||
semantic: SemanticRepr::EMPTY_RECORD,
|
||||
};
|
||||
|
||||
pub const fn float_width(w: FloatWidth) -> InLayout<'static> {
|
||||
|
|
24
crates/compiler/mono/src/layout/semantic.rs
Normal file
24
crates/compiler/mono/src/layout/semantic.rs
Normal 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],
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue