mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-23 03:52:27 +00:00
Begin support for looping-back recursive pointers to their source layouts
This commit is contained in:
parent
a30a4e36ed
commit
8750127111
17 changed files with 57 additions and 47 deletions
|
@ -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,
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue