helper for generating dec functions

This commit is contained in:
Folkert 2023-05-02 21:04:48 +02:00
parent 13e52844c7
commit f383ff14f8
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C
2 changed files with 28 additions and 0 deletions

View file

@ -1653,6 +1653,32 @@ impl<
) )
} }
fn gen_refcount_proc_dec(&mut self, layout: InLayout<'a>) -> Symbol {
let ident_ids = self
.interns
.all_ident_ids
.get_mut(&self.env.module_id)
.unwrap();
let (refcount_proc_name, _) = self.helper_proc_gen.gen_refcount_proc(
ident_ids,
self.layout_interner,
layout,
HelperOp::Dec,
);
let proc_layout = ProcLayout {
arguments: self.env().arena.alloc([layout]),
result: Layout::UNIT,
niche: roc_mono::layout::Niche::NONE,
};
self.helper_proc_symbols_mut()
.push((refcount_proc_name, proc_layout));
refcount_proc_name
}
fn build_higher_order_lowlevel( fn build_higher_order_lowlevel(
&mut self, &mut self,
dst: &Symbol, dst: &Symbol,

View file

@ -1609,6 +1609,8 @@ trait Backend<'a> {
ret_layout: InLayout<'a>, ret_layout: InLayout<'a>,
); );
fn gen_refcount_proc_dec(&mut self, layout: InLayout<'a>) -> Symbol;
/// build_list_with_capacity creates and returns a list with the given capacity. /// build_list_with_capacity creates and returns a list with the given capacity.
fn build_list_with_capacity( fn build_list_with_capacity(
&mut self, &mut self,