mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 22:34:45 +00:00
Re-index all internal functions to make room for imported external functions
Linked external functions must be declared in the Import section, and they must come first in the function index space. In other words, internal function numbers start at the number of imports. However we don't know in advance how many builtins the code may call, and we don't want to add more passes over the full IR. Instead we re-index function references at the end of code generation.
This commit is contained in:
parent
141480aa8d
commit
d0ffaabe83
6 changed files with 197 additions and 44 deletions
|
@ -34,7 +34,7 @@ pub fn build_module<'a>(
|
|||
) -> Result<std::vec::Vec<u8>, String> {
|
||||
let mut wasm_module = build_module_help(env, procedures)?;
|
||||
let mut buffer = std::vec::Vec::with_capacity(4096);
|
||||
wasm_module.serialize(&mut buffer);
|
||||
wasm_module.serialize_mut(&mut buffer);
|
||||
Ok(buffer)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue