mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 06:14:46 +00:00
Merge pull request #2109 from rtfeldman/refactor-passed-function
refactor passed (to higher order lowlevel) funcion
This commit is contained in:
commit
e6bec46898
5 changed files with 95 additions and 88 deletions
|
@ -955,7 +955,7 @@ pub fn build_exp_call<'a, 'ctx, 'env>(
|
|||
}
|
||||
|
||||
CallType::HigherOrder(higher_order) => {
|
||||
let bytes = higher_order.specialization_id.to_bytes();
|
||||
let bytes = higher_order.passed_function.specialization_id.to_bytes();
|
||||
let callee_var = CalleeSpecVar(&bytes);
|
||||
let func_spec = func_spec_solutions.callee_spec(callee_var).unwrap();
|
||||
|
||||
|
@ -4686,20 +4686,23 @@ fn run_higher_order_low_level<'a, 'ctx, 'env>(
|
|||
func_spec: FuncSpec,
|
||||
higher_order: &HigherOrderLowLevel<'a>,
|
||||
) -> BasicValueEnum<'ctx> {
|
||||
use roc_mono::ir::PassedFunction;
|
||||
use roc_mono::low_level::HigherOrder::*;
|
||||
|
||||
let HigherOrderLowLevel {
|
||||
op,
|
||||
arg_layouts: argument_layouts,
|
||||
ret_layout: result_layout,
|
||||
function_owns_closure_data,
|
||||
function_name,
|
||||
function_env,
|
||||
passed_function,
|
||||
..
|
||||
} = higher_order;
|
||||
|
||||
let function_owns_closure_data = *function_owns_closure_data;
|
||||
let function_name = *function_name;
|
||||
let PassedFunction {
|
||||
argument_layouts,
|
||||
return_layout: result_layout,
|
||||
owns_captured_environment: function_owns_closure_data,
|
||||
name: function_name,
|
||||
captured_environment,
|
||||
..
|
||||
} = *passed_function;
|
||||
|
||||
// macros because functions cause lifetime issues related to the `env` or `layout_ids`
|
||||
macro_rules! function_details {
|
||||
|
@ -4712,7 +4715,8 @@ fn run_higher_order_low_level<'a, 'ctx, 'env>(
|
|||
return_layout,
|
||||
);
|
||||
|
||||
let (closure, closure_layout) = load_symbol_and_lambda_set(scope, function_env);
|
||||
let (closure, closure_layout) =
|
||||
load_symbol_and_lambda_set(scope, &captured_environment);
|
||||
|
||||
(function, closure, closure_layout)
|
||||
}};
|
||||
|
@ -4737,14 +4741,14 @@ fn run_higher_order_low_level<'a, 'ctx, 'env>(
|
|||
closure_layout,
|
||||
function_owns_closure_data,
|
||||
argument_layouts,
|
||||
*result_layout,
|
||||
result_layout,
|
||||
);
|
||||
|
||||
crate::llvm::build_list::list_walk_generic(
|
||||
env,
|
||||
layout_ids,
|
||||
roc_function_call,
|
||||
result_layout,
|
||||
&result_layout,
|
||||
list,
|
||||
element_layout,
|
||||
default,
|
||||
|
@ -4974,7 +4978,7 @@ fn run_higher_order_low_level<'a, 'ctx, 'env>(
|
|||
closure_layout,
|
||||
function_owns_closure_data,
|
||||
argument_layouts,
|
||||
*result_layout,
|
||||
result_layout,
|
||||
);
|
||||
|
||||
list_keep_if(env, layout_ids, roc_function_call, list, element_layout)
|
||||
|
@ -5003,14 +5007,14 @@ fn run_higher_order_low_level<'a, 'ctx, 'env>(
|
|||
closure_layout,
|
||||
function_owns_closure_data,
|
||||
argument_layouts,
|
||||
*result_layout,
|
||||
result_layout,
|
||||
);
|
||||
|
||||
list_keep_oks(
|
||||
env,
|
||||
layout_ids,
|
||||
roc_function_call,
|
||||
result_layout,
|
||||
&result_layout,
|
||||
list,
|
||||
before_layout,
|
||||
after_layout,
|
||||
|
@ -5042,14 +5046,14 @@ fn run_higher_order_low_level<'a, 'ctx, 'env>(
|
|||
closure_layout,
|
||||
function_owns_closure_data,
|
||||
argument_layouts,
|
||||
*result_layout,
|
||||
result_layout,
|
||||
);
|
||||
|
||||
list_keep_errs(
|
||||
env,
|
||||
layout_ids,
|
||||
roc_function_call,
|
||||
result_layout,
|
||||
&result_layout,
|
||||
list,
|
||||
before_layout,
|
||||
after_layout,
|
||||
|
@ -5094,7 +5098,7 @@ fn run_higher_order_low_level<'a, 'ctx, 'env>(
|
|||
closure_layout,
|
||||
function_owns_closure_data,
|
||||
argument_layouts,
|
||||
*result_layout,
|
||||
result_layout,
|
||||
);
|
||||
|
||||
list_sort_with(
|
||||
|
@ -5197,7 +5201,7 @@ fn run_higher_order_low_level<'a, 'ctx, 'env>(
|
|||
closure_layout,
|
||||
function_owns_closure_data,
|
||||
argument_layouts,
|
||||
*result_layout,
|
||||
result_layout,
|
||||
);
|
||||
|
||||
dict_walk(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue