mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 21:39:07 +00:00
Simplify the model of handling imported/unloaded symbol specializations
This commit is contained in:
parent
f08d9c9173
commit
02eec1f60c
1 changed files with 51 additions and 62 deletions
|
@ -4307,7 +4307,7 @@ pub fn with_hole<'a>(
|
||||||
variant_var,
|
variant_var,
|
||||||
assigned,
|
assigned,
|
||||||
hole,
|
hole,
|
||||||
tag_name.clone(),
|
tag_name,
|
||||||
procs,
|
procs,
|
||||||
layout_cache,
|
layout_cache,
|
||||||
args,
|
args,
|
||||||
|
@ -8218,73 +8218,62 @@ fn specialize_symbol<'a>(
|
||||||
Err(e) => return_on_layout_error_help!(env, e, "specialize_symbol"),
|
Err(e) => return_on_layout_error_help!(env, e, "specialize_symbol"),
|
||||||
};
|
};
|
||||||
|
|
||||||
if procs.is_imported_module_thunk(original) {
|
match raw {
|
||||||
let layout = match raw {
|
RawFunctionLayout::ZeroArgumentThunk(layout) => {
|
||||||
RawFunctionLayout::ZeroArgumentThunk(layout) => layout,
|
let raw = RawFunctionLayout::ZeroArgumentThunk(layout);
|
||||||
RawFunctionLayout::Function(_, lambda_set, _) => {
|
let top_level = ProcLayout::from_raw(
|
||||||
Layout::LambdaSet(lambda_set)
|
env.arena,
|
||||||
}
|
&layout_cache.interner,
|
||||||
};
|
raw,
|
||||||
|
CapturesNiche::no_niche(),
|
||||||
|
);
|
||||||
|
|
||||||
let raw = RawFunctionLayout::ZeroArgumentThunk(layout);
|
procs.insert_passed_by_name(
|
||||||
let top_level = ProcLayout::from_raw(
|
env,
|
||||||
env.arena,
|
arg_var,
|
||||||
&layout_cache.interner,
|
LambdaName::no_niche(original),
|
||||||
raw,
|
top_level,
|
||||||
CapturesNiche::no_niche(),
|
layout_cache,
|
||||||
);
|
);
|
||||||
|
|
||||||
procs.insert_passed_by_name(
|
force_thunk(env, original, layout, assign_to, env.arena.alloc(result))
|
||||||
env,
|
}
|
||||||
arg_var,
|
RawFunctionLayout::Function(_, lambda_set, _) => {
|
||||||
LambdaName::no_niche(original),
|
debug_assert!(!procs.is_imported_module_thunk(original));
|
||||||
top_level,
|
|
||||||
layout_cache,
|
|
||||||
);
|
|
||||||
|
|
||||||
force_thunk(env, original, layout, assign_to, env.arena.alloc(result))
|
let lambda_name =
|
||||||
} else {
|
find_lambda_name(env, layout_cache, lambda_set, original, &[]);
|
||||||
// Figure out the lambda set this top-level function is used in.
|
|
||||||
let lambda_set = match raw {
|
|
||||||
RawFunctionLayout::Function(_, lambda_set, _) => lambda_set,
|
|
||||||
RawFunctionLayout::ZeroArgumentThunk(_) => internal_error!(
|
|
||||||
"ZATs should have been covered in the previous branch"
|
|
||||||
),
|
|
||||||
};
|
|
||||||
|
|
||||||
let lambda_name =
|
debug_assert!(
|
||||||
find_lambda_name(env, layout_cache, lambda_set, original, &[]);
|
lambda_name.no_captures(),
|
||||||
|
"imported functions are top-level and should never capture"
|
||||||
|
);
|
||||||
|
|
||||||
debug_assert!(
|
let function_ptr_layout = ProcLayout::from_raw(
|
||||||
lambda_name.no_captures(),
|
env.arena,
|
||||||
"imported functions are top-level and should never capture"
|
&layout_cache.interner,
|
||||||
);
|
raw,
|
||||||
|
lambda_name.captures_niche(),
|
||||||
|
);
|
||||||
|
procs.insert_passed_by_name(
|
||||||
|
env,
|
||||||
|
arg_var,
|
||||||
|
lambda_name,
|
||||||
|
function_ptr_layout,
|
||||||
|
layout_cache,
|
||||||
|
);
|
||||||
|
|
||||||
let function_ptr_layout = ProcLayout::from_raw(
|
construct_closure_data(
|
||||||
env.arena,
|
env,
|
||||||
&layout_cache.interner,
|
procs,
|
||||||
raw,
|
layout_cache,
|
||||||
lambda_name.captures_niche(),
|
lambda_set,
|
||||||
);
|
lambda_name,
|
||||||
procs.insert_passed_by_name(
|
&[],
|
||||||
env,
|
assign_to,
|
||||||
arg_var,
|
env.arena.alloc(result),
|
||||||
lambda_name,
|
)
|
||||||
function_ptr_layout,
|
}
|
||||||
layout_cache,
|
|
||||||
);
|
|
||||||
|
|
||||||
//let_empty_struct(assign_to, env.arena.alloc(result))
|
|
||||||
construct_closure_data(
|
|
||||||
env,
|
|
||||||
procs,
|
|
||||||
layout_cache,
|
|
||||||
lambda_set,
|
|
||||||
lambda_name,
|
|
||||||
&[],
|
|
||||||
assign_to,
|
|
||||||
env.arena.alloc(result),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue