working functions in list

This commit is contained in:
Folkert 2021-05-13 19:43:17 +02:00
parent 2163e01288
commit c4fc526038
3 changed files with 26 additions and 13 deletions

View File

@ -82,7 +82,6 @@ pub fn build_transform_caller_new<'a, 'ctx, 'env>(
Some(function_value) => function_value,
None => build_transform_caller_help_new(
env,
layout_ids,
function,
closure_data_layout,
argument_layouts,
@ -93,7 +92,6 @@ pub fn build_transform_caller_new<'a, 'ctx, 'env>(
fn build_transform_caller_help_new<'a, 'ctx, 'env>(
env: &Env<'a, 'ctx, 'env>,
layout_ids: &mut LayoutIds<'a>,
roc_function: FunctionValue<'ctx>,
closure_data_layout: Layout<'a>,
argument_layouts: &[Layout<'a>],
@ -134,9 +132,6 @@ fn build_transform_caller_help_new<'a, 'ctx, 'env>(
set_name(*argument, name.ident_string(&env.interns));
}
let closure_type =
basic_type_from_layout(env, &closure_data_layout).ptr_type(AddressSpace::Generic);
let mut arguments_cast =
bumpalo::collections::Vec::with_capacity_in(arguments.len(), env.arena);
@ -153,15 +148,33 @@ fn build_transform_caller_help_new<'a, 'ctx, 'env>(
arguments_cast.push(argument);
}
let closure_cast = env
.builder
.build_bitcast(closure_ptr, closure_type, "load_opaque")
.into_pointer_value();
match closure_data_layout {
Layout::FunctionPointer(_, _) => {
// do nothing
}
Layout::Closure(_, lambda_set, _) => {
if let Layout::Struct(&[]) = lambda_set.runtime_representation() {
// do nothing
} else {
let closure_type =
basic_type_from_layout(env, &lambda_set.runtime_representation())
.ptr_type(AddressSpace::Generic);
let closure_data = env.builder.build_load(closure_cast, "load_opaque");
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");
dbg!(closure_data);
arguments_cast.push(closure_data);
}
}
_ => unreachable!(),
}
let call = {
arguments_cast.push(closure_data);
env.builder
.build_call(roc_function, arguments_cast.as_slice(), "tmp")
};

View File

@ -872,7 +872,7 @@ fn list_map_generic_new<'a, 'ctx, 'env>(
.as_global_value()
.as_pointer_value();
dbg!(stepper_caller);
dbg!(element_layout, layout_width(env, element_layout));
call_bitcode_fn_returns_list(
env,

View File

@ -524,7 +524,7 @@ impl<'a> Layout<'a> {
| NonNullableUnwrapped(_) => pointer_size,
}
}
Closure(_, closure_layout, _) => pointer_size + closure_layout.stack_size(pointer_size),
Closure(_, lambda_set, _) => lambda_set.stack_size(pointer_size),
FunctionPointer(_, _) => pointer_size,
RecursivePointer => pointer_size,
Pointer(_) => pointer_size,