mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 13:29:12 +00:00
Lift Niche from just captures-niche to generic niche
This commit is contained in:
parent
ea53a50447
commit
972046445b
16 changed files with 119 additions and 140 deletions
|
@ -45,8 +45,8 @@ use roc_mono::ir::{
|
|||
OptLevel, ProcLayout, SingleEntryPoint,
|
||||
};
|
||||
use roc_mono::layout::{
|
||||
Builtin, CapturesNiche, LambdaName, LambdaSet, Layout, LayoutIds, RawFunctionLayout,
|
||||
STLayoutInterner, TagIdIntType, UnionLayout,
|
||||
Builtin, LambdaName, LambdaSet, Layout, LayoutIds, Niche, RawFunctionLayout, STLayoutInterner,
|
||||
TagIdIntType, UnionLayout,
|
||||
};
|
||||
use roc_std::RocDec;
|
||||
use roc_target::{PtrWidth, TargetInfo};
|
||||
|
@ -620,12 +620,8 @@ fn promote_to_main_function<'a, 'ctx, 'env>(
|
|||
top_level: ProcLayout<'a>,
|
||||
) -> (&'static str, FunctionValue<'ctx>) {
|
||||
let it = top_level.arguments.iter().copied();
|
||||
let bytes = roc_alias_analysis::func_name_bytes_help(
|
||||
symbol,
|
||||
it,
|
||||
CapturesNiche::no_niche(),
|
||||
&top_level.result,
|
||||
);
|
||||
let bytes =
|
||||
roc_alias_analysis::func_name_bytes_help(symbol, it, Niche::NONE, &top_level.result);
|
||||
let func_name = FuncName(&bytes);
|
||||
let func_solutions = mod_solutions.func_solutions(func_name).unwrap();
|
||||
|
||||
|
@ -637,14 +633,8 @@ fn promote_to_main_function<'a, 'ctx, 'env>(
|
|||
);
|
||||
|
||||
// NOTE fake layout; it is only used for debug prints
|
||||
let roc_main_fn = function_value_by_func_spec(
|
||||
env,
|
||||
*func_spec,
|
||||
symbol,
|
||||
&[],
|
||||
CapturesNiche::no_niche(),
|
||||
&Layout::UNIT,
|
||||
);
|
||||
let roc_main_fn =
|
||||
function_value_by_func_spec(env, *func_spec, symbol, &[], Niche::NONE, &Layout::UNIT);
|
||||
|
||||
let main_fn_name = "$Test.main";
|
||||
|
||||
|
@ -681,12 +671,8 @@ fn promote_to_wasm_test_wrapper<'a, 'ctx, 'env>(
|
|||
let main_fn_name = "test_wrapper";
|
||||
|
||||
let it = top_level.arguments.iter().copied();
|
||||
let bytes = roc_alias_analysis::func_name_bytes_help(
|
||||
symbol,
|
||||
it,
|
||||
CapturesNiche::no_niche(),
|
||||
&top_level.result,
|
||||
);
|
||||
let bytes =
|
||||
roc_alias_analysis::func_name_bytes_help(symbol, it, Niche::NONE, &top_level.result);
|
||||
let func_name = FuncName(&bytes);
|
||||
let func_solutions = mod_solutions.func_solutions(func_name).unwrap();
|
||||
|
||||
|
@ -698,14 +684,8 @@ fn promote_to_wasm_test_wrapper<'a, 'ctx, 'env>(
|
|||
);
|
||||
|
||||
// NOTE fake layout; it is only used for debug prints
|
||||
let roc_main_fn = function_value_by_func_spec(
|
||||
env,
|
||||
*func_spec,
|
||||
symbol,
|
||||
&[],
|
||||
CapturesNiche::no_niche(),
|
||||
&Layout::UNIT,
|
||||
);
|
||||
let roc_main_fn =
|
||||
function_value_by_func_spec(env, *func_spec, symbol, &[], Niche::NONE, &Layout::UNIT);
|
||||
|
||||
let output_type = match roc_main_fn.get_type().get_return_type() {
|
||||
Some(return_type) => {
|
||||
|
@ -3546,7 +3526,7 @@ fn expose_function_to_host<'a, 'ctx, 'env>(
|
|||
symbol: Symbol,
|
||||
roc_function: FunctionValue<'ctx>,
|
||||
arguments: &'a [Layout<'a>],
|
||||
captures_niche: CapturesNiche<'a>,
|
||||
niche: Niche<'a>,
|
||||
return_layout: Layout<'a>,
|
||||
layout_ids: &mut LayoutIds<'a>,
|
||||
) {
|
||||
|
@ -3555,7 +3535,7 @@ fn expose_function_to_host<'a, 'ctx, 'env>(
|
|||
let proc_layout = ProcLayout {
|
||||
arguments,
|
||||
result: return_layout,
|
||||
captures_niche,
|
||||
niche,
|
||||
};
|
||||
|
||||
let c_function_name: String = layout_ids
|
||||
|
@ -4676,12 +4656,12 @@ pub fn build_procedures_expose_expects<'a, 'ctx, 'env>(
|
|||
Some(&std::env::temp_dir().join("test.ll")),
|
||||
);
|
||||
|
||||
let captures_niche = CapturesNiche::no_niche();
|
||||
let captures_niche = Niche::NONE;
|
||||
|
||||
let top_level = ProcLayout {
|
||||
arguments: &[],
|
||||
result: Layout::UNIT,
|
||||
captures_niche,
|
||||
niche: captures_niche,
|
||||
};
|
||||
|
||||
let mut expect_names = Vec::with_capacity_in(expects.len(), env.arena);
|
||||
|
@ -4904,7 +4884,7 @@ fn build_proc_header<'a, 'ctx, 'env>(
|
|||
symbol,
|
||||
fn_val,
|
||||
arguments.into_bump_slice(),
|
||||
proc.name.captures_niche(),
|
||||
proc.name.niche(),
|
||||
proc.ret_layout,
|
||||
layout_ids,
|
||||
);
|
||||
|
@ -4951,7 +4931,7 @@ fn expose_alias_to_host<'a, 'ctx, 'env>(
|
|||
let bytes = roc_alias_analysis::func_name_bytes_help(
|
||||
exposed_function_symbol,
|
||||
it,
|
||||
CapturesNiche::no_niche(),
|
||||
Niche::NONE,
|
||||
&top_level.result,
|
||||
);
|
||||
let func_name = FuncName(&bytes);
|
||||
|
@ -4970,7 +4950,7 @@ fn expose_alias_to_host<'a, 'ctx, 'env>(
|
|||
*func_spec,
|
||||
exposed_function_symbol,
|
||||
top_level.arguments,
|
||||
CapturesNiche::no_niche(),
|
||||
Niche::NONE,
|
||||
&top_level.result,
|
||||
)
|
||||
}
|
||||
|
@ -5305,19 +5285,19 @@ pub(crate) fn function_value_by_func_spec<'a, 'ctx, 'env>(
|
|||
func_spec: FuncSpec,
|
||||
symbol: Symbol,
|
||||
arguments: &[Layout<'a>],
|
||||
captures_niche: CapturesNiche<'a>,
|
||||
niche: Niche<'a>,
|
||||
result: &Layout<'a>,
|
||||
) -> FunctionValue<'ctx> {
|
||||
let fn_name = func_spec_name(env.arena, &env.interns, symbol, func_spec);
|
||||
let fn_name = fn_name.as_str();
|
||||
|
||||
function_value_by_name_help(env, arguments, captures_niche, result, symbol, fn_name)
|
||||
function_value_by_name_help(env, arguments, niche, result, symbol, fn_name)
|
||||
}
|
||||
|
||||
fn function_value_by_name_help<'a, 'ctx, 'env>(
|
||||
env: &Env<'a, 'ctx, 'env>,
|
||||
arguments: &[Layout<'a>],
|
||||
_captures_niche: CapturesNiche<'a>,
|
||||
_niche: Niche<'a>,
|
||||
result: &Layout<'a>,
|
||||
symbol: Symbol,
|
||||
fn_name: &str,
|
||||
|
@ -5368,7 +5348,7 @@ fn roc_call_with_args<'a, 'ctx, 'env>(
|
|||
func_spec,
|
||||
name.name(),
|
||||
argument_layouts,
|
||||
name.captures_niche(),
|
||||
name.niche(),
|
||||
result_layout,
|
||||
);
|
||||
|
||||
|
|
|
@ -2308,7 +2308,7 @@ pub(crate) fn run_higher_order_low_level<'a, 'ctx, 'env>(
|
|||
func_spec,
|
||||
function_name.name(),
|
||||
argument_layouts,
|
||||
function_name.captures_niche(),
|
||||
function_name.niche(),
|
||||
return_layout,
|
||||
);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue