contains_functions -> has_varying_stack_size

This commit is contained in:
Richard Feldman 2022-11-16 13:55:06 -05:00
parent f33d1ef947
commit 53ab17d0e9
No known key found for this signature in database
GPG key ID: F1F21AA5B1D9E43B
3 changed files with 12 additions and 8 deletions

View file

@ -2664,7 +2664,7 @@ impl<'a> Layout<'a> {
}
}
pub fn contains_function(self, arena: &Bump) -> bool {
pub fn has_varying_stack_size(self, arena: &Bump) -> bool {
let mut stack = Vec::new_in(arena);
stack.push(self);
@ -2676,11 +2676,12 @@ impl<'a> Layout<'a> {
| Builtin::Float(_)
| Builtin::Bool
| Builtin::Decimal
| Builtin::Str => { /* do nothing */ }
Builtin::List(element) => stack.push(*element),
| Builtin::Str
// If there's any layer of indirection (behind a pointer), then it doesn't vary!
| Builtin::List(_) => { /* do nothing */ }
},
// If there's any layer of indirection (behind a pointer), then it doesn't vary!
Layout::Struct { field_layouts, .. } => stack.extend(field_layouts),
Layout::Boxed(boxed) => stack.push(*boxed),
Layout::Union(tag_union) => match tag_union {
UnionLayout::NonRecursive(tags) | UnionLayout::Recursive(tags) => {
for tag in tags {
@ -2700,6 +2701,9 @@ impl<'a> Layout<'a> {
}
},
Layout::LambdaSet(_) => return true,
Layout::Boxed(_) => {
// If there's any layer of indirection (behind a pointer), then it doesn't vary!
}
Layout::RecursivePointer => {
/* do nothing, we've already generated for this type through the Union(_) */
}