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

@ -1528,7 +1528,7 @@ fn build_tag_field_value<'a, 'ctx, 'env>(
value: BasicValueEnum<'ctx>,
tag_field_layout: InLayout<'a>,
) -> BasicValueEnum<'ctx> {
if let Layout::RecursivePointer = layout_interner.get(tag_field_layout) {
if let Layout::RecursivePointer(_) = layout_interner.get(tag_field_layout) {
debug_assert!(value.is_pointer_value());
// we store recursive pointers as `i64*`
@ -2020,7 +2020,7 @@ fn lookup_at_index_ptr<'a, 'ctx, 'env>(
"load_at_index_ptr_old",
);
if let Some(Layout::RecursivePointer) = field_layouts
if let Some(Layout::RecursivePointer(_)) = field_layouts
.get(index as usize)
.map(|l| layout_interner.get(*l))
{
@ -2080,7 +2080,7 @@ fn lookup_at_index_ptr2<'a, 'ctx, 'env>(
"load_at_index_ptr",
);
if let Some(Layout::RecursivePointer) = field_layouts
if let Some(Layout::RecursivePointer(_)) = field_layouts
.get(index as usize)
.map(|l| layout_interner.get(*l))
{
@ -2481,7 +2481,10 @@ pub fn build_exp_stmt<'a, 'ctx, 'env>(
let mut stack = Vec::with_capacity_in(queue.len(), env.arena);
for (symbol, expr, layout) in queue {
debug_assert!(layout_interner.get(*layout) != Layout::RecursivePointer);
debug_assert!(!matches!(
layout_interner.get(*layout),
Layout::RecursivePointer(_)
));
let val = build_exp_expr(
env,
@ -6107,7 +6110,7 @@ pub(crate) enum WhenRecursive<'a> {
impl<'a> WhenRecursive<'a> {
pub fn unwrap_recursive_pointer(&self, layout: Layout<'a>) -> Layout<'a> {
match layout {
Layout::RecursivePointer => match self {
Layout::RecursivePointer(_) => match self {
WhenRecursive::Loop(lay) => Layout::Union(*lay),
WhenRecursive::Unreachable => {
internal_error!("cannot compare recursive pointers outside of a structure")