add == and != for lists

This commit is contained in:
Folkert 2021-01-03 20:09:28 +01:00
parent 23ed281345
commit a7cf98df9b
6 changed files with 328 additions and 11 deletions

View file

@ -1003,6 +1003,7 @@ pub fn list_walk_backwards<'a, 'ctx, 'env>(
/// List.contains : List elem, elem -> Bool
pub fn list_contains<'a, 'ctx, 'env>(
env: &Env<'a, 'ctx, 'env>,
layout_ids: &mut LayoutIds<'a>,
parent: FunctionValue<'ctx>,
elem: BasicValueEnum<'ctx>,
elem_layout: &Layout<'a>,
@ -1034,6 +1035,7 @@ pub fn list_contains<'a, 'ctx, 'env>(
list_contains_help(
env,
layout_ids,
parent,
length,
list_ptr,
@ -1045,6 +1047,7 @@ pub fn list_contains<'a, 'ctx, 'env>(
pub fn list_contains_help<'a, 'ctx, 'env>(
env: &Env<'a, 'ctx, 'env>,
layout_ids: &mut LayoutIds<'a>,
parent: FunctionValue<'ctx>,
length: IntValue<'ctx>,
source_ptr: PointerValue<'ctx>,
@ -1082,7 +1085,14 @@ pub fn list_contains_help<'a, 'ctx, 'env>(
let current_elem = builder.build_load(current_elem_ptr, "load_elem");
let has_found = build_eq(env, current_elem, elem, list_elem_layout, elem_layout);
let has_found = build_eq(
env,
layout_ids,
current_elem,
elem,
list_elem_layout,
elem_layout,
);
builder.build_store(bool_alloca, has_found.into_int_value());