mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 06:14:46 +00:00
spec for list append
This commit is contained in:
parent
486f1d540f
commit
13d480d5f3
3 changed files with 7 additions and 2 deletions
|
@ -729,10 +729,13 @@ pub fn listSingle(alignment: u32, element: Opaque, element_width: usize) callcon
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn listAppend(list: RocList, alignment: u32, element: Opaque, element_width: usize) callconv(.C) RocList {
|
pub fn listAppend(list: RocList, alignment: u32, element: Opaque, element_width: usize, update_mode: UpdateMode) callconv(.C) RocList {
|
||||||
const old_length = list.len();
|
const old_length = list.len();
|
||||||
var output = list.reallocate(alignment, old_length + 1, element_width);
|
var output = list.reallocate(alignment, old_length + 1, element_width);
|
||||||
|
|
||||||
|
// we'd need capacity to use update_mode here
|
||||||
|
_ = update_mode;
|
||||||
|
|
||||||
if (output.bytes) |target| {
|
if (output.bytes) |target| {
|
||||||
if (element) |source| {
|
if (element) |source| {
|
||||||
@memcpy(target + old_length * element_width, source, element_width);
|
@memcpy(target + old_length * element_width, source, element_width);
|
||||||
|
|
|
@ -4972,7 +4972,7 @@ fn run_low_level<'a, 'ctx, 'env>(
|
||||||
let original_wrapper = load_symbol(scope, &args[0]).into_struct_value();
|
let original_wrapper = load_symbol(scope, &args[0]).into_struct_value();
|
||||||
let (elem, elem_layout) = load_symbol_and_layout(scope, &args[1]);
|
let (elem, elem_layout) = load_symbol_and_layout(scope, &args[1]);
|
||||||
|
|
||||||
list_append(env, original_wrapper, elem, elem_layout)
|
list_append(env, original_wrapper, elem, elem_layout, update_mode)
|
||||||
}
|
}
|
||||||
ListSwap => {
|
ListSwap => {
|
||||||
// List.swap : List elem, Nat, Nat -> List elem
|
// List.swap : List elem, Nat, Nat -> List elem
|
||||||
|
|
|
@ -238,6 +238,7 @@ pub fn list_append<'a, 'ctx, 'env>(
|
||||||
original_wrapper: StructValue<'ctx>,
|
original_wrapper: StructValue<'ctx>,
|
||||||
element: BasicValueEnum<'ctx>,
|
element: BasicValueEnum<'ctx>,
|
||||||
element_layout: &Layout<'a>,
|
element_layout: &Layout<'a>,
|
||||||
|
update_mode: UpdateMode,
|
||||||
) -> BasicValueEnum<'ctx> {
|
) -> BasicValueEnum<'ctx> {
|
||||||
call_bitcode_fn_returns_list(
|
call_bitcode_fn_returns_list(
|
||||||
env,
|
env,
|
||||||
|
@ -246,6 +247,7 @@ pub fn list_append<'a, 'ctx, 'env>(
|
||||||
env.alignment_intvalue(element_layout),
|
env.alignment_intvalue(element_layout),
|
||||||
pass_element_as_opaque(env, element),
|
pass_element_as_opaque(env, element),
|
||||||
layout_width(env, element_layout),
|
layout_width(env, element_layout),
|
||||||
|
pass_update_mode(env, update_mode),
|
||||||
],
|
],
|
||||||
bitcode::LIST_APPEND,
|
bitcode::LIST_APPEND,
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue