remove FunctionPointer completely

This commit is contained in:
Folkert 2021-06-19 14:53:18 +02:00
parent c776d98686
commit f2f9897187
12 changed files with 11 additions and 58 deletions

View file

@ -2244,9 +2244,6 @@ fn build_specialized_proc_from_var<'a>(
fn_var: Variable,
) -> Result<SpecializedLayout<'a>, LayoutProblem> {
match layout_cache.from_var(env.arena, fn_var, env.subs) {
Ok(Layout::FunctionPointer(_, _)) => {
unreachable!(r"layout generated by from_var should never by a function pointer")
}
Ok(Layout::Closure(pattern_layouts, closure_layout, ret_layout)) => {
let mut pattern_layouts_vec = Vec::with_capacity_in(pattern_layouts.len(), env.arena);
pattern_layouts_vec.extend_from_slice(pattern_layouts);
@ -2550,7 +2547,6 @@ fn specialize_solved_type<'a>(
RawFunctionLayout::Function(a, lambda_set, c)
}
}
Layout::FunctionPointer(_, _) => unreachable!(),
_ => RawFunctionLayout::ZeroArgumentThunk(attempted_layout),
};
@ -2634,12 +2630,9 @@ impl<'a> TopLevelFunctionLayout<'a> {
}
pub fn from_layout(arena: &'a Bump, layout: Layout<'a>) -> Self {
match layout {
Layout::FunctionPointer(old_arguments, result) => {
Self::new(arena, old_arguments, *result)
}
Layout::Closure(arguments, lambda_set, result) => {
let full = lambda_set.extend_function_layout(arena, arguments, result);
TopLevelFunctionLayout::from_layout(arena, full)
let arguments = lambda_set.extend_argument_list(arena, arguments);
TopLevelFunctionLayout::new(arena, arguments, *result)
}
_ => TopLevelFunctionLayout {
arguments: &[],
@ -2690,9 +2683,6 @@ fn specialize_naked_symbol<'a>(
} else if env.is_imported_symbol(symbol) {
match layout_cache.from_var(env.arena, variable, env.subs) {
Err(e) => panic!("invalid layout {:?}", e),
Ok(Layout::FunctionPointer(_, _)) => {
unreachable!(r"layout generated by from_var should never by a function pointer")
}
Ok(_) => {
// this is a 0-arity thunk
let result = call_by_name(
@ -6568,7 +6558,6 @@ fn call_by_name_module_thunk<'a>(
let top_level_layout = TopLevelFunctionLayout::new(env.arena, &[], *ret_layout);
// the layout without the `FunctionPointer(&[], ...)` wrapper
let inner_layout = *ret_layout;
// If we've already specialized this one, no further work is needed.