mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-03 19:58:18 +00:00
Merge branch 'trunk' of github.com:rtfeldman/roc into crates-folder
This commit is contained in:
commit
b1b9a8dc0a
29 changed files with 358 additions and 156 deletions
|
@ -13,6 +13,7 @@ use crate::llvm::build_list::{
|
|||
list_keep_if, list_keep_oks, list_len, list_map, list_map2, list_map3, list_map4,
|
||||
list_map_with_index, list_prepend, list_range, list_repeat, list_replace_unsafe, list_reverse,
|
||||
list_single, list_sort_with, list_sublist, list_swap, list_symbol_to_c_abi, list_to_c_abi,
|
||||
list_with_capacity,
|
||||
};
|
||||
use crate::llvm::build_str::{
|
||||
str_from_float, str_from_int, str_from_utf8, str_from_utf8_range, str_split,
|
||||
|
@ -5585,6 +5586,15 @@ fn run_low_level<'a, 'ctx, 'env>(
|
|||
|
||||
list_len(env.builder, arg.into_struct_value()).into()
|
||||
}
|
||||
ListWithCapacity => {
|
||||
// List.withCapacity : Nat -> List a
|
||||
debug_assert_eq!(args.len(), 1);
|
||||
|
||||
let list_len = load_symbol(scope, &args[0]).into_int_value();
|
||||
let result_layout = *layout;
|
||||
|
||||
list_with_capacity(env, list_len, &list_element_layout!(result_layout))
|
||||
}
|
||||
ListSingle => {
|
||||
// List.single : a -> List a
|
||||
debug_assert_eq!(args.len(), 1);
|
||||
|
|
|
@ -123,6 +123,22 @@ pub fn list_single<'a, 'ctx, 'env>(
|
|||
)
|
||||
}
|
||||
|
||||
pub fn list_with_capacity<'a, 'ctx, 'env>(
|
||||
env: &Env<'a, 'ctx, 'env>,
|
||||
capacity: IntValue<'ctx>,
|
||||
element_layout: &Layout<'a>,
|
||||
) -> BasicValueEnum<'ctx> {
|
||||
call_list_bitcode_fn(
|
||||
env,
|
||||
&[
|
||||
capacity.into(),
|
||||
env.alignment_intvalue(element_layout),
|
||||
layout_width(env, element_layout),
|
||||
],
|
||||
bitcode::LIST_WITH_CAPACITY,
|
||||
)
|
||||
}
|
||||
|
||||
/// List.repeat : elem, Nat -> List elem
|
||||
pub fn list_repeat<'a, 'ctx, 'env>(
|
||||
env: &Env<'a, 'ctx, 'env>,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue