test_gen works again

This commit is contained in:
Folkert 2021-08-18 13:46:09 +02:00
parent 5fc629e5b8
commit c09b3b89f3
11 changed files with 95 additions and 124 deletions

View file

@ -270,6 +270,25 @@ fn build_transform_caller_help<'a, 'ctx, 'env>(
arguments_cast.push(argument);
}
match closure_data_layout {
Layout::Struct(&[]) => {
// do nothing
}
other => {
let closure_type = basic_type_from_layout(env, &other).ptr_type(AddressSpace::Generic);
let closure_cast = env
.builder
.build_bitcast(closure_ptr, closure_type, "load_opaque")
.into_pointer_value();
let closure_data = env.builder.build_load(closure_cast, "load_opaque");
arguments_cast.push(closure_data);
}
}
/*
match closure_data_layout {
Layout::Closure(_, lambda_set, _) => {
if let Layout::Struct(&[]) = lambda_set.runtime_representation() {
@ -316,6 +335,7 @@ fn build_transform_caller_help<'a, 'ctx, 'env>(
}
other => unreachable!("layout is not valid for a closure: {:?}", other),
}
*/
let call = {
env.builder
@ -624,6 +644,7 @@ pub fn build_compare_wrapper<'a, 'ctx, 'env>(
let default = [value1, value2];
/*
let arguments_cast = match closure_data_layout {
Layout::Closure(_, lambda_set, _) => {
if let Layout::Struct(&[]) = lambda_set.runtime_representation() {
@ -646,6 +667,29 @@ pub fn build_compare_wrapper<'a, 'ctx, 'env>(
Layout::Struct([]) => &default,
other => unreachable!("layout is not valid for a closure: {:?}", other),
};
*/
let arguments_cast = match closure_data_layout {
Layout::Struct(&[]) => {
// do nothing
&default
}
other => {
//
let closure_type =
basic_type_from_layout(env, &other).ptr_type(AddressSpace::Generic);
let closure_cast = env
.builder
.build_bitcast(closure_ptr, closure_type, "load_opaque")
.into_pointer_value();
let closure_data = env.builder.build_load(closure_cast, "load_opaque");
env.arena.alloc([value1, value2, closure_data]) as &[_]
}
};
let call = env.builder.build_call(
roc_function,

View file

@ -1082,14 +1082,6 @@ pub fn build_exp_expr<'a, 'ctx, 'env>(
)
.unwrap()
}
(StructValue(argument), Layout::Closure(_, _, _)) => env
.builder
.build_extract_value(
argument,
*index as u32,
env.arena.alloc(format!("closure_field_access_{}_", index)),
)
.unwrap(),
(
PointerValue(argument),
Layout::Union(UnionLayout::NonNullableUnwrapped(fields)),

View file

@ -88,10 +88,6 @@ fn build_hash_layout<'a, 'ctx, 'env>(
)
}
},
Layout::Closure(_, _, _) => {
unreachable!("the type system will guarantee these are never hashed")
}
}
}

View file

@ -198,10 +198,6 @@ fn build_eq<'a, 'ctx, 'env>(
)
}
},
Layout::Closure(_, _, _) => {
unreachable!("the type system will guarantee these are never compared")
}
}
}
@ -340,10 +336,6 @@ fn build_neq<'a, 'ctx, 'env>(
Layout::RecursivePointer => {
unreachable!("recursion pointers should never be compared directly")
}
Layout::Closure(_, _, _) => {
unreachable!("the type system will guarantee these are never compared")
}
}
}

View file

@ -26,10 +26,6 @@ pub fn basic_type_from_layout<'a, 'ctx, 'env>(
use Layout::*;
match layout {
Closure(_args, closure_layout, _ret_layout) => {
let closure_data_layout = closure_layout.runtime_representation();
basic_type_from_layout(env, &closure_data_layout)
}
Struct(sorted_fields) => basic_type_from_record(env, sorted_fields),
Union(union_layout) => {
use UnionLayout::*;

View file

@ -659,23 +659,6 @@ fn modify_refcount_layout_build_function<'a, 'ctx, 'env>(
Some(function)
}
Closure(_, lambda_set, _) => {
if lambda_set.contains_refcounted() {
let function = modify_refcount_layout_build_function(
env,
parent,
layout_ids,
mode,
when_recursive,
&lambda_set.runtime_representation(),
)?;
Some(function)
} else {
None
}
}
Struct(layouts) => {
let function = modify_refcount_struct(env, layout_ids, layouts, mode, when_recursive);