mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 21:39:07 +00:00
add List.clone
This commit is contained in:
parent
ebfcd71e8d
commit
f1ffc36efe
14 changed files with 147 additions and 4 deletions
|
@ -2809,6 +2809,55 @@ impl<
|
|||
self.storage_manager.list_len(&mut self.buf, dst, list);
|
||||
}
|
||||
|
||||
fn build_list_clone(
|
||||
&mut self,
|
||||
dst: Symbol,
|
||||
input_list: Symbol,
|
||||
elem_layout: InLayout<'a>,
|
||||
ret_layout: InLayout<'a>,
|
||||
) {
|
||||
// List alignment argument (u32).
|
||||
self.load_layout_alignment(ret_layout, Symbol::DEV_TMP);
|
||||
|
||||
// Load element_width argument (usize).
|
||||
self.load_layout_stack_size(elem_layout, Symbol::DEV_TMP2);
|
||||
|
||||
// Setup the return location.
|
||||
let base_offset =
|
||||
self.storage_manager
|
||||
.claim_stack_area_layout(self.layout_interner, dst, ret_layout);
|
||||
|
||||
let lowlevel_args = [
|
||||
input_list,
|
||||
// alignment
|
||||
Symbol::DEV_TMP,
|
||||
// element_width
|
||||
Symbol::DEV_TMP2,
|
||||
];
|
||||
let lowlevel_arg_layouts = [ret_layout, Layout::U32, Layout::U64];
|
||||
|
||||
self.build_fn_call(
|
||||
&Symbol::DEV_TMP3,
|
||||
bitcode::LIST_CLONE.to_string(),
|
||||
&lowlevel_args,
|
||||
&lowlevel_arg_layouts,
|
||||
&ret_layout,
|
||||
);
|
||||
self.free_symbol(&Symbol::DEV_TMP);
|
||||
self.free_symbol(&Symbol::DEV_TMP2);
|
||||
|
||||
// Copy from list to the output record.
|
||||
self.storage_manager.copy_symbol_to_stack_offset(
|
||||
self.layout_interner,
|
||||
&mut self.buf,
|
||||
base_offset,
|
||||
&Symbol::DEV_TMP3,
|
||||
&ret_layout,
|
||||
);
|
||||
|
||||
self.free_symbol(&Symbol::DEV_TMP3);
|
||||
}
|
||||
|
||||
fn build_list_with_capacity(
|
||||
&mut self,
|
||||
dst: &Symbol,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue