mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-04 04:08:19 +00:00
Enable multiple functions exposed to the host
This commit is contained in:
parent
c61b7bf2a6
commit
a9d1327dd1
7 changed files with 63 additions and 13 deletions
|
@ -238,6 +238,7 @@ where
|
|||
|
||||
match entry_point {
|
||||
EntryPoint::Single(SingleEntryPoint {
|
||||
name: entry_point_name,
|
||||
symbol: entry_point_symbol,
|
||||
layout: entry_point_layout,
|
||||
}) => {
|
||||
|
@ -263,9 +264,41 @@ where
|
|||
|
||||
type_definitions.extend(env.type_names);
|
||||
|
||||
let entry_point_name = FuncName(ENTRY_POINT_NAME);
|
||||
let entry_point_name = FuncName(entry_point_name.as_bytes());
|
||||
m.add_func(entry_point_name, entry_point_function)?;
|
||||
}
|
||||
EntryPoint::Multiple(entry_points) => {
|
||||
for SingleEntryPoint {
|
||||
name: entry_point_name,
|
||||
symbol: entry_point_symbol,
|
||||
layout: entry_point_layout,
|
||||
} in entry_points
|
||||
{
|
||||
let roc_main_bytes = func_name_bytes_help(
|
||||
*entry_point_symbol,
|
||||
entry_point_layout.arguments.iter().copied(),
|
||||
Niche::NONE,
|
||||
entry_point_layout.result,
|
||||
);
|
||||
let roc_main = FuncName(&roc_main_bytes);
|
||||
|
||||
let mut env = Env::new();
|
||||
|
||||
let entry_point_function = build_entry_point(
|
||||
&mut env,
|
||||
interner,
|
||||
*entry_point_layout,
|
||||
Some(roc_main),
|
||||
&host_exposed_functions,
|
||||
&erased_functions,
|
||||
)?;
|
||||
|
||||
type_definitions.extend(env.type_names);
|
||||
|
||||
let entry_point_name = FuncName(entry_point_name.as_bytes());
|
||||
m.add_func(entry_point_name, entry_point_function)?;
|
||||
}
|
||||
}
|
||||
EntryPoint::Expects { symbols } => {
|
||||
// construct a big pattern match picking one of the expects at random
|
||||
let layout: ProcLayout<'a> = ProcLayout {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue