mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 07:14:46 +00:00
add first version of List.dropAt
* adds an implementation with no uniqueness/mutability
This commit is contained in:
parent
ff9866420b
commit
3baff93a97
11 changed files with 145 additions and 13 deletions
|
@ -297,7 +297,7 @@ pub fn list_swap<'a, 'ctx, 'env>(
|
|||
)
|
||||
}
|
||||
|
||||
/// List.drop : List elem, Nat, Nat -> List elem
|
||||
/// List.drop : List elem, Nat -> List elem
|
||||
pub fn list_drop<'a, 'ctx, 'env>(
|
||||
env: &Env<'a, 'ctx, 'env>,
|
||||
layout_ids: &mut LayoutIds<'a>,
|
||||
|
@ -319,6 +319,29 @@ pub fn list_drop<'a, 'ctx, 'env>(
|
|||
)
|
||||
}
|
||||
|
||||
// GIESCH ask about how this calling/linking to compiled zig works
|
||||
/// List.dropAt : List elem, Nat -> List elem
|
||||
pub fn list_drop_at<'a, 'ctx, 'env>(
|
||||
env: &Env<'a, 'ctx, 'env>,
|
||||
layout_ids: &mut LayoutIds<'a>,
|
||||
original_wrapper: StructValue<'ctx>,
|
||||
count: IntValue<'ctx>,
|
||||
element_layout: &Layout<'a>,
|
||||
) -> BasicValueEnum<'ctx> {
|
||||
let dec_element_fn = build_dec_wrapper(env, layout_ids, element_layout);
|
||||
call_bitcode_fn_returns_list(
|
||||
env,
|
||||
&[
|
||||
pass_list_cc(env, original_wrapper.into()),
|
||||
env.alignment_intvalue(element_layout),
|
||||
layout_width(env, element_layout),
|
||||
count.into(),
|
||||
dec_element_fn.as_global_value().as_pointer_value().into(),
|
||||
],
|
||||
bitcode::LIST_DROP_AT,
|
||||
)
|
||||
}
|
||||
|
||||
/// List.set : List elem, Nat, elem -> List elem
|
||||
pub fn list_set<'a, 'ctx, 'env>(
|
||||
env: &Env<'a, 'ctx, 'env>,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue