mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 22:34:45 +00:00
Merge remote-tracking branch 'origin/trunk' into tag-union-imitate-rust
This commit is contained in:
commit
a9d483cb60
58 changed files with 5821 additions and 843 deletions
|
@ -8,7 +8,7 @@ use crate::llvm::build_dict::{
|
|||
};
|
||||
use crate::llvm::build_hash::generic_hash;
|
||||
use crate::llvm::build_list::{
|
||||
self, allocate_list, empty_list, empty_polymorphic_list, list_append, list_concat,
|
||||
self, allocate_list, empty_list, empty_polymorphic_list, list_any, list_append, list_concat,
|
||||
list_contains, list_drop, list_drop_at, list_get_unsafe, list_join, list_keep_errs,
|
||||
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_reverse, list_set,
|
||||
|
@ -5149,6 +5149,30 @@ fn run_higher_order_low_level<'a, 'ctx, 'env>(
|
|||
_ => unreachable!("invalid list layout"),
|
||||
}
|
||||
}
|
||||
ListAny { xs } => {
|
||||
let (list, list_layout) = load_symbol_and_layout(scope, &xs);
|
||||
let (function, closure, closure_layout) = function_details!();
|
||||
|
||||
match list_layout {
|
||||
Layout::Builtin(Builtin::EmptyList) => env.context.bool_type().const_zero().into(),
|
||||
Layout::Builtin(Builtin::List(element_layout)) => {
|
||||
let argument_layouts = &[**element_layout];
|
||||
|
||||
let roc_function_call = roc_function_call(
|
||||
env,
|
||||
layout_ids,
|
||||
function,
|
||||
closure,
|
||||
closure_layout,
|
||||
function_owns_closure_data,
|
||||
argument_layouts,
|
||||
);
|
||||
|
||||
list_any(env, roc_function_call, list, element_layout)
|
||||
}
|
||||
_ => unreachable!("invalid list layout"),
|
||||
}
|
||||
}
|
||||
DictWalk { xs, state } => {
|
||||
let (dict, dict_layout) = load_symbol_and_layout(scope, &xs);
|
||||
let (default, default_layout) = load_symbol_and_layout(scope, &state);
|
||||
|
@ -6000,7 +6024,7 @@ fn run_low_level<'a, 'ctx, 'env>(
|
|||
|
||||
ListMap | ListMap2 | ListMap3 | ListMap4 | ListMapWithIndex | ListKeepIf | ListWalk
|
||||
| ListWalkUntil | ListWalkBackwards | ListKeepOks | ListKeepErrs | ListSortWith
|
||||
| DictWalk => unreachable!("these are higher order, and are handled elsewhere"),
|
||||
| ListAny | DictWalk => unreachable!("these are higher order, and are handled elsewhere"),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6964,39 +6988,6 @@ fn build_float_unary_op<'a, 'ctx, 'env>(
|
|||
}
|
||||
}
|
||||
|
||||
pub fn call_bitcode_int_fn<'a, 'ctx, 'env>(
|
||||
env: &Env<'a, 'ctx, 'env>,
|
||||
fn_name: &str,
|
||||
args: &[BasicValueEnum<'ctx>],
|
||||
int_width: IntWidth,
|
||||
) -> BasicValueEnum<'ctx> {
|
||||
match int_width {
|
||||
IntWidth::U8 => call_bitcode_fn(env, args, &format!("{}_u8", fn_name)),
|
||||
IntWidth::U16 => call_bitcode_fn(env, args, &format!("{}_u16", fn_name)),
|
||||
IntWidth::U32 => call_bitcode_fn(env, args, &format!("{}_u32", fn_name)),
|
||||
IntWidth::U64 => call_bitcode_fn(env, args, &format!("{}_u64", fn_name)),
|
||||
IntWidth::U128 => call_bitcode_fn(env, args, &format!("{}_u128", fn_name)),
|
||||
IntWidth::I8 => call_bitcode_fn(env, args, &format!("{}_i8", fn_name)),
|
||||
IntWidth::I16 => call_bitcode_fn(env, args, &format!("{}_i16", fn_name)),
|
||||
IntWidth::I32 => call_bitcode_fn(env, args, &format!("{}_i32", fn_name)),
|
||||
IntWidth::I64 => call_bitcode_fn(env, args, &format!("{}_i64", fn_name)),
|
||||
IntWidth::I128 => call_bitcode_fn(env, args, &format!("{}_i128", fn_name)),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn call_bitcode_float_fn<'a, 'ctx, 'env>(
|
||||
env: &Env<'a, 'ctx, 'env>,
|
||||
fn_name: &str,
|
||||
args: &[BasicValueEnum<'ctx>],
|
||||
float_width: FloatWidth,
|
||||
) -> BasicValueEnum<'ctx> {
|
||||
match float_width {
|
||||
FloatWidth::F32 => call_bitcode_fn(env, args, &format!("{}_f32", fn_name)),
|
||||
FloatWidth::F64 => call_bitcode_fn(env, args, &format!("{}_f64", fn_name)),
|
||||
FloatWidth::F128 => todo!("suport 128-bit floats"),
|
||||
}
|
||||
}
|
||||
|
||||
fn define_global_str_literal_ptr<'a, 'ctx, 'env>(
|
||||
env: &Env<'a, 'ctx, 'env>,
|
||||
message: &str,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue