mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 07:14:46 +00:00
refactor
This commit is contained in:
parent
565a962613
commit
3ba643df70
1 changed files with 9 additions and 38 deletions
|
@ -2255,48 +2255,18 @@ fn build_specialized_proc_from_var<'a>(
|
||||||
*ret_layout,
|
*ret_layout,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
RawFunctionLayout::ZeroArgumentThunk(_) => {
|
RawFunctionLayout::ZeroArgumentThunk(ret_layout) => {
|
||||||
// a top-level constant 0-argument thunk
|
// a top-level constant 0-argument thunk
|
||||||
build_specialized_proc_adapter(
|
|
||||||
env,
|
|
||||||
layout_cache,
|
|
||||||
proc_name,
|
|
||||||
pattern_symbols,
|
|
||||||
&[],
|
|
||||||
None,
|
|
||||||
fn_var,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#[allow(clippy::type_complexity)]
|
|
||||||
fn build_specialized_proc_adapter<'a>(
|
|
||||||
env: &mut Env<'a, '_>,
|
|
||||||
layout_cache: &mut LayoutCache<'a>,
|
|
||||||
proc_name: Symbol,
|
|
||||||
pattern_symbols: &[Symbol],
|
|
||||||
pattern_vars: &[Variable],
|
|
||||||
closure_layout: Option<LambdaSet<'a>>,
|
|
||||||
ret_var: Variable,
|
|
||||||
) -> Result<SpecializedLayout<'a>, LayoutProblem> {
|
|
||||||
let mut arg_layouts = Vec::with_capacity_in(pattern_vars.len(), &env.arena);
|
|
||||||
|
|
||||||
for arg_var in pattern_vars {
|
|
||||||
let layout = layout_cache.from_var(&env.arena, *arg_var, env.subs)?;
|
|
||||||
|
|
||||||
arg_layouts.push(layout);
|
|
||||||
}
|
|
||||||
|
|
||||||
let ret_layout = layout_cache.from_var(&env.arena, ret_var, env.subs)?;
|
|
||||||
|
|
||||||
build_specialized_proc(
|
build_specialized_proc(
|
||||||
env.arena,
|
env.arena,
|
||||||
proc_name,
|
proc_name,
|
||||||
pattern_symbols,
|
pattern_symbols,
|
||||||
arg_layouts,
|
Vec::new_in(env.arena),
|
||||||
closure_layout,
|
None,
|
||||||
ret_layout,
|
ret_layout,
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::type_complexity)]
|
#[allow(clippy::type_complexity)]
|
||||||
|
@ -2510,6 +2480,7 @@ fn specialize_solved_type<'a>(
|
||||||
|
|
||||||
let fn_var = introduce_solved_type_to_subs(env, &solved_type);
|
let fn_var = introduce_solved_type_to_subs(env, &solved_type);
|
||||||
|
|
||||||
|
// for debugging only
|
||||||
let attempted_layout = layout_cache
|
let attempted_layout = layout_cache
|
||||||
.from_var(&env.arena, fn_var, env.subs)
|
.from_var(&env.arena, fn_var, env.subs)
|
||||||
.unwrap_or_else(|err| panic!("TODO handle invalid function {:?}", err));
|
.unwrap_or_else(|err| panic!("TODO handle invalid function {:?}", err));
|
||||||
|
@ -2618,9 +2589,9 @@ impl<'a> ProcLayout<'a> {
|
||||||
|
|
||||||
fn from_raw(arena: &'a Bump, raw: RawFunctionLayout<'a>) -> Self {
|
fn from_raw(arena: &'a Bump, raw: RawFunctionLayout<'a>) -> Self {
|
||||||
match raw {
|
match raw {
|
||||||
RawFunctionLayout::Function(a, b, c) => {
|
RawFunctionLayout::Function(arguments, lambda_set, result) => {
|
||||||
let l = Layout::Closure(a, b, c);
|
let arguments = lambda_set.extend_argument_list(arena, arguments);
|
||||||
ProcLayout::from_layout(arena, l)
|
ProcLayout::new(arena, arguments, *result)
|
||||||
}
|
}
|
||||||
RawFunctionLayout::ZeroArgumentThunk(result) => ProcLayout::new(arena, &[], result),
|
RawFunctionLayout::ZeroArgumentThunk(result) => ProcLayout::new(arena, &[], result),
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue