start resetref

This commit is contained in:
J.Teeuwissen 2023-03-29 11:57:13 +02:00
parent 61efec6fe2
commit d4ed6f7778
No known key found for this signature in database
GPG key ID: DB5F7A1ED8D478AD
13 changed files with 214 additions and 18 deletions

View file

@ -31,6 +31,8 @@ pub enum HelperOp {
Dec,
DecRef(JoinPointId),
Reset,
// TODO update all usages
ResetRef,
Eq,
}
@ -272,7 +274,7 @@ impl<'a> CodeGenHelp<'a> {
let arg = self.replace_rec_ptr(ctx, layout_interner, layout);
match ctx.op {
Dec | DecRef(_) => (LAYOUT_UNIT, self.arena.alloc([arg])),
Reset => (layout, self.arena.alloc([layout])),
Reset | ResetRef => (layout, self.arena.alloc([layout])),
Inc => (LAYOUT_UNIT, self.arena.alloc([arg, self.layout_isize])),
Eq => (LAYOUT_BOOL, self.arena.alloc([arg, arg])),
}
@ -346,7 +348,7 @@ impl<'a> CodeGenHelp<'a> {
Symbol::ARG_1,
),
),
Reset => (
Reset | ResetRef => (
layout,
refcount::refcount_reset_proc_body(
self,
@ -370,7 +372,7 @@ impl<'a> CodeGenHelp<'a> {
let inc_amount = (self.layout_isize, ARG_2);
self.arena.alloc([roc_value, inc_amount])
}
Dec | DecRef(_) | Reset => self.arena.alloc([roc_value]),
Dec | DecRef(_) | Reset | ResetRef => self.arena.alloc([roc_value]),
Eq => self.arena.alloc([roc_value, (layout, ARG_2)]),
}
};
@ -421,6 +423,7 @@ impl<'a> CodeGenHelp<'a> {
niche: Niche::NONE,
},
HelperOp::DecRef(_) => unreachable!("No generated Proc for DecRef"),
HelperOp::ResetRef => unreachable!("No generated Proc for ResetRef"),
HelperOp::Eq => ProcLayout {
arguments: self.arena.alloc([layout, layout]),
result: LAYOUT_BOOL,