wasm_module: Create DataSection::load_into

This commit is contained in:
Brian Carroll 2022-11-25 09:19:35 +00:00
parent a0fe01dd5f
commit 96bff3e304
No known key found for this signature in database
GPG key ID: 5C7B2EC4101703C0
2 changed files with 28 additions and 1 deletions

View file

@ -1,5 +1,6 @@
use bumpalo::{collections::Vec, Bump};
use std::fmt::Write;
use std::iter;
use roc_wasm_module::opcodes::OpCode;
use roc_wasm_module::parse::Parse;
@ -59,6 +60,8 @@ impl<'a> ExecutionState<'a> {
e.offset, e.message
)
})?;
let mut memory = Vec::from_iter_in(iter::repeat(0).take(mem_bytes as usize), arena);
module.data.load_into(&mut memory)?;
let globals = module.global.initial_values(arena);
@ -110,7 +113,7 @@ impl<'a> ExecutionState<'a> {
};
Ok(ExecutionState {
memory: Vec::with_capacity_in(mem_bytes as usize, arena),
memory,
call_stack,
value_stack,
globals,