Begin support for looping-back recursive pointers to their source layouts

This commit is contained in:
Ayaz Hafiz 2023-01-20 12:56:42 -06:00
parent a30a4e36ed
commit 8750127111
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58
17 changed files with 57 additions and 47 deletions

View file

@ -255,7 +255,10 @@ impl<'a> CodeGenHelp<'a> {
// debug_assert!(self.debug_recursion_depth < 100);
self.debug_recursion_depth += 1;
let layout = if matches!(layout_interner.get(called_layout), Layout::RecursivePointer) {
let layout = if matches!(
layout_interner.get(called_layout),
Layout::RecursivePointer(_)
) {
let union_layout = ctx.recursive_union.unwrap();
layout_interner.insert(Layout::Union(union_layout))
} else {
@ -494,7 +497,7 @@ impl<'a> CodeGenHelp<'a> {
}
// This line is the whole point of the function
Layout::RecursivePointer => Layout::Union(ctx.recursive_union.unwrap()),
Layout::RecursivePointer(_) => Layout::Union(ctx.recursive_union.unwrap()),
};
layout_interner.insert(layout)
}
@ -535,7 +538,7 @@ impl<'a> CodeGenHelp<'a> {
for fields in tags.iter() {
let found_index = fields
.iter()
.position(|f| matches!(layout_interner.get(*f), Layout::RecursivePointer));
.position(|f| matches!(layout_interner.get(*f), Layout::RecursivePointer(_)));
tailrec_indices.push(found_index);
can_use_tailrec |= found_index.is_some();
}
@ -586,7 +589,7 @@ fn layout_needs_helper_proc<'a>(
Layout::Union(UnionLayout::NonRecursive(tags)) => !tags.is_empty(),
Layout::Union(_) => true,
Layout::LambdaSet(_) => true,
Layout::RecursivePointer => false,
Layout::RecursivePointer(_) => false,
Layout::Boxed(_) => true,
}
}