fix test hanging forever

This commit is contained in:
Folkert 2021-01-25 13:20:40 +01:00
parent 171e0358f3
commit 0166a4d915
7 changed files with 66 additions and 17 deletions

View file

@ -1,4 +1,4 @@
use crate::llvm::build_dict::dict_len;
use crate::llvm::build_dict::{dict_len, dict_empty};
use crate::llvm::build_hash::hash;
use crate::llvm::build_list::{
allocate_list, empty_list, empty_polymorphic_list, list_append, list_concat, list_contains,
@ -3854,7 +3854,14 @@ fn run_low_level<'a, 'ctx, 'env>(
hash(env, value, layout)
}
DictSize => dict_len(env, scope, args[0]),
DictSize => {
debug_assert_eq!(args.len(), 1);
dict_len(env, scope, args[0])
}
DictEmpty => {
debug_assert_eq!(args.len(), 0);
dict_empty(env, scope)
}
}
}

View file

@ -25,6 +25,28 @@ pub fn dict_len<'a, 'ctx, 'env>(
}
}
pub fn dict_empty<'a, 'ctx, 'env>(
env: &Env<'a, 'ctx, 'env>,
scope: &Scope<'a, 'ctx>,
) -> BasicValueEnum<'ctx> {
let ctx = env.context;
/*
let (_, dict_layout) = load_symbol_and_layout(env, scope, &dict_symbol);
match dict_layout {
Layout::Builtin(Builtin::Dict(_, _)) => {
let dict_as_int = dict_symbol_to_i128(env, scope, dict_symbol);
call_bitcode_fn(env, &[dict_as_int.into()], &bitcode::DICT_LEN)
}
Layout::Builtin(Builtin::EmptyDict) => ctx.i64_type().const_zero().into(),
_ => unreachable!("Invalid layout given to Dict.len : {:?}", dict_layout),
}
*/
todo!()
}
fn dict_symbol_to_i128<'a, 'ctx, 'env>(
env: &Env<'a, 'ctx, 'env>,
scope: &Scope<'a, 'ctx>,

View file

@ -181,7 +181,7 @@ pub fn basic_type_from_builtin<'ctx>(
Float64 => context.f64_type().as_basic_type_enum(),
Float32 => context.f32_type().as_basic_type_enum(),
Float16 => context.f16_type().as_basic_type_enum(),
Dict(_, _) | EmptyDict => panic!("TODO layout_to_basic_type for Builtin::Dict"),
Dict(_, _) | EmptyDict => collection(context, ptr_bytes).into(),
Set(_) | EmptySet => panic!("TODO layout_to_basic_type for Builtin::Set"),
List(_, _) | Str | EmptyStr => collection(context, ptr_bytes).into(),
EmptyList => BasicTypeEnum::StructType(collection(context, ptr_bytes)),