Enable multiple functions exposed to the host

This commit is contained in:
Brendan Hansknecht 2024-10-06 18:30:09 -07:00
parent c61b7bf2a6
commit a9d1327dd1
No known key found for this signature in database
GPG key ID: A199D0660F95F948
7 changed files with 63 additions and 13 deletions

View file

@ -1,6 +1,7 @@
use crate::link::{
legacy_host_file, link, preprocess_host_wasm32, rebuild_host, LinkType, LinkingStrategy,
};
use bumpalo::collections::CollectIn;
use bumpalo::Bump;
use inkwell::memory_buffer::MemoryBuffer;
use roc_error_macros::internal_error;
@ -227,11 +228,16 @@ fn gen_from_mono_module_llvm<'a>(
exposed_to_host,
platform_path: _,
} => {
// TODO support multiple of these!
debug_assert_eq!(exposed_to_host.len(), 1);
let (symbol, layout) = exposed_to_host[0];
let entry_points: bumpalo::collections::Vec<_> = exposed_to_host
.iter()
.map(|(fn_name, symbol, layout)| SingleEntryPoint {
name: fn_name,
symbol: *symbol,
layout: *layout,
})
.collect_in(arena);
roc_mono::ir::EntryPoint::Single(SingleEntryPoint { symbol, layout })
roc_mono::ir::EntryPoint::Multiple(entry_points.into_bump_slice())
}
EntryPoint::Test => roc_mono::ir::EntryPoint::Expects { symbols: &[] },
};