Support non-nullable-unwrapped recursive lambda sets

This commit is contained in:
Ayaz Hafiz 2022-08-09 15:17:16 -07:00
parent c1a7e7893b
commit 021cc6e506
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58
3 changed files with 64 additions and 7 deletions

View file

@ -898,7 +898,7 @@ impl<'a> LambdaSet<'a> {
let runtime_repr = self.runtime_representation();
debug_assert!(matches!(
runtime_repr,
Layout::Union(UnionLayout::Recursive(_))
Layout::Union(UnionLayout::Recursive(_) | UnionLayout::NullableUnwrapped { .. })
));
Layout::LambdaSet(*self)
} else {
@ -909,7 +909,7 @@ impl<'a> LambdaSet<'a> {
let runtime_repr = self.runtime_representation();
debug_assert!(matches!(
runtime_repr,
Layout::Union(UnionLayout::Recursive(_))
Layout::Union(UnionLayout::Recursive(_) | UnionLayout::NullableUnwrapped { .. })
));
Layout::LambdaSet(*self)
} else {
@ -964,15 +964,31 @@ impl<'a> LambdaSet<'a> {
union_layout: *union,
}
}
UnionLayout::NullableUnwrapped {
nullable_id: _,
other_fields: _,
} => {
let (index, (name, fields)) = self
.set
.iter()
.enumerate()
.find(|(_, (s, layouts))| comparator(*s, layouts))
.unwrap();
let closure_name = *name;
ClosureRepresentation::Union {
tag_id: index as TagIdIntType,
alphabetic_order_fields: fields,
closure_name,
union_layout: *union,
}
}
UnionLayout::NonNullableUnwrapped(_) => todo!("recursive closures"),
UnionLayout::NullableWrapped {
nullable_id: _,
other_tags: _,
} => todo!("recursive closures"),
UnionLayout::NullableUnwrapped {
nullable_id: _,
other_fields: _,
} => todo!("recursive closures"),
}
}
Layout::Struct { .. } => {
@ -1187,6 +1203,20 @@ impl<'a> LambdaSet<'a> {
Layout::Union(UnionLayout::Recursive(tag_arguments.into_bump_slice()))
}
NullableUnwrapped {
nullable_id,
nullable_name: _,
other_name,
other_fields,
} => {
debug_assert!(matches!(other_name, TagOrClosure::Closure(_)));
Layout::Union(UnionLayout::NullableUnwrapped {
nullable_id,
other_fields,
})
}
layout => panic!("handle recursive layout: {:?}", layout),
}
}