This commit is contained in:
Richard Feldman 2022-11-11 16:37:49 -05:00
parent c5037e7311
commit a0e450cadd
No known key found for this signature in database
GPG key ID: F1F21AA5B1D9E43B
2 changed files with 103 additions and 29 deletions

View file

@ -2979,33 +2979,21 @@ fn finish_specialization<'a>(
};
let platform_path = Path::new(path_to_platform).into();
let symbol = match platform_data {
let provides = match platform_data {
None => {
debug_assert_eq!(exposed_to_host.values.len(), 1);
*exposed_to_host.values.iter().next().unwrap().0
}
Some(PlatformData { provides, .. }) => provides,
};
match procedures.keys().find(|(s, _)| *s == symbol) {
Some((_, layout)) => EntryPoint::Executable {
layout: *layout,
symbol,
platform_path,
},
None => {
// the entry point is not specialized. This can happen if the repl output
// is a function value
EntryPoint::Executable {
layout: roc_mono::ir::ProcLayout {
arguments: &[],
result: Layout::struct_no_name_order(&[]),
captures_niche: CapturesNiche::no_niche(),
},
symbol,
platform_path,
}
}
let layout = get_exe_entry_point(provides, &procedures);
EntryPoint::Executable {
layout,
symbol: provides,
platform_path,
}
}
ExecutionMode::Check => unreachable!(),
@ -3062,6 +3050,25 @@ fn finish_specialization<'a>(
})
}
pub fn get_exe_entry_point<'a>(
provides: Symbol,
procedures: &MutMap<(Symbol, ProcLayout<'a>), Proc<'a>>,
) -> ProcLayout<'a> {
match procedures.keys().find(|(s, _)| *s == provides) {
Some((_, layout)) => *layout,
None =>
// the entry point is not specialized. This can happen if the repl output
// is a function value
{
ProcLayout {
arguments: &[],
result: Layout::struct_no_name_order(&[]),
captures_niche: CapturesNiche::no_niche(),
}
}
}
}
#[allow(clippy::too_many_arguments)]
fn finish(
mut state: State,