Add List.prepend implementation for generic64

This commit is contained in:
Ahmad Sattar 2023-01-28 22:46:35 +01:00
parent 6bc3ba6407
commit 7fc24d5720
No known key found for this signature in database
GPG key ID: DE5DDDB4ACC89D39
3 changed files with 110 additions and 2 deletions

View file

@ -757,6 +757,14 @@ trait Backend<'a> {
let element_layout = list_element_layout!(self.interner(), *ret_layout);
self.build_list_concat(sym, args, arg_layouts, element_layout, ret_layout)
}
LowLevel::ListPrepend => {
debug_assert_eq!(
2,
args.len(),
"ListPrepend: expected to have exactly two arguments"
);
self.build_list_prepend(sym, args, arg_layouts, ret_layout)
}
LowLevel::StrConcat => self.build_fn_call(
sym,
bitcode::STR_CONCAT.to_string(),
@ -1063,6 +1071,15 @@ trait Backend<'a> {
ret_layout: &InLayout<'a>,
);
/// build_list_prepend returns a new list with a given element prepended.
fn build_list_prepend(
&mut self,
dst: &Symbol,
args: &'a [Symbol],
arg_layouts: &[InLayout<'a>],
ret_layout: &InLayout<'a>,
);
/// build_refcount_getptr loads the pointer to the reference count of src into dst.
fn build_ptr_cast(&mut self, dst: &Symbol, src: &Symbol);