Rename NonNullableUnwrapped to RecursiveSingleTag

This commit is contained in:
Richard Feldman 2022-08-07 16:55:47 -04:00
parent 23b8ff896a
commit 4e73899356
No known key found for this signature in database
GPG key ID: 7E4127D1E4241798
2 changed files with 17 additions and 11 deletions

View file

@ -245,7 +245,7 @@ fn add_type(target_info: TargetInfo, id: TypeId, types: &Types, impls: &mut Impl
types,
impls,
),
RocTagUnion::NonNullableUnwrapped { .. } => {
RocTagUnion::RecursiveSingleTag { .. } => {
todo!();
}
RocTagUnion::NonRecursiveSingleTag {
@ -1416,7 +1416,7 @@ fn type_name(id: TypeId, types: &Types) -> String {
| RocType::TagUnion(RocTagUnion::Enumeration { name, .. })
| RocType::TagUnion(RocTagUnion::NullableWrapped { name, .. })
| RocType::TagUnion(RocTagUnion::NullableUnwrapped { name, .. })
| RocType::TagUnion(RocTagUnion::NonNullableUnwrapped { name, .. }) => name.clone(),
| RocType::TagUnion(RocTagUnion::RecursiveSingleTag { name, .. }) => name.clone(),
RocType::RecursivePointer(content) => type_name(*content, types),
RocType::Function { name, .. } => name.clone(),
}
@ -2041,7 +2041,7 @@ fn cannot_derive_copy(roc_type: &RocType, types: &Types) -> bool {
| RocType::RocDict(_, _)
| RocType::RocSet(_)
| RocType::RocBox(_)
| RocType::TagUnion(RocTagUnion::NonNullableUnwrapped { .. })
| RocType::TagUnion(RocTagUnion::RecursiveSingleTag { .. })
| RocType::TagUnion(RocTagUnion::NullableUnwrapped { .. })
| RocType::TagUnion(RocTagUnion::NullableWrapped { .. })
| RocType::TagUnion(RocTagUnion::Recursive { .. })
@ -2124,7 +2124,9 @@ fn has_float_help(roc_type: &RocType, types: &Types, do_not_recurse: &[TypeId])
non_null_payload: content,
..
})
| RocType::TagUnion(RocTagUnion::NonNullableUnwrapped { content, .. })
| RocType::TagUnion(RocTagUnion::RecursiveSingleTag {
payload: content, ..
})
| RocType::RecursivePointer(content) => {
if do_not_recurse.contains(content) {
false

View file

@ -146,11 +146,11 @@ impl Types {
}
}
(
NonNullableUnwrapped {
content: content_a, ..
RecursiveSingleTag {
payload: content_a, ..
},
NonNullableUnwrapped {
content: content_b, ..
RecursiveSingleTag {
payload: content_b, ..
},
) => content_a == content_b,
(
@ -206,8 +206,8 @@ impl Types {
| (_, NonRecursive { .. })
| (Recursive { .. }, _)
| (_, Recursive { .. })
| (NonNullableUnwrapped { .. }, _)
| (_, NonNullableUnwrapped { .. })
| (RecursiveSingleTag { .. }, _)
| (_, RecursiveSingleTag { .. })
| (NullableUnwrapped { .. }, _)
| (_, NullableUnwrapped { .. }) => false,
}
@ -540,7 +540,11 @@ pub enum RocTagUnion {
/// A recursive tag union with just one constructor
/// Optimization: No need to store a tag ID (the payload is "unwrapped")
/// e.g. `RoseTree a : [Tree a (List (RoseTree a))]`
NonNullableUnwrapped { name: String, content: TypeId },
RecursiveSingleTag {
name: String,
tag_name: String,
payload: TypeId,
},
/// A recursive tag union that has an empty variant
/// Optimization: Represent the empty variant as null pointer => no memory usage & fast comparison