mirror of
https://github.com/fluencelabs/frank
synced 2025-04-24 14:02:13 +00:00
improve prepare
This commit is contained in:
parent
29ec1d0e4f
commit
9a3bd83dbf
@ -16,7 +16,7 @@ object SbtCommons {
|
||||
|
||||
val commons = Seq(
|
||||
scalaV,
|
||||
version := "0.1.1",
|
||||
version := "0.1.2",
|
||||
fork in Test := true,
|
||||
parallelExecution in Test := false,
|
||||
fork in IntegrationTest := true,
|
||||
|
@ -23,7 +23,7 @@ use parity_wasm::elements;
|
||||
|
||||
use crate::vm::config::Config;
|
||||
use crate::vm::errors::InitializationError;
|
||||
use parity_wasm::elements::{MemorySection, MemoryType, ResizableLimits};
|
||||
use parity_wasm::elements::{MemorySection, MemoryType};
|
||||
|
||||
struct ModulePreparator {
|
||||
module: elements::Module,
|
||||
@ -40,20 +40,19 @@ impl<'a> ModulePreparator {
|
||||
let Self { mut module } = self;
|
||||
|
||||
// At now, there is could be only one memory section, so
|
||||
// it needs just to extract previous initial page count, delete existing memory section
|
||||
let limits = match module.memory_section_mut() {
|
||||
// it needs just to extract previous initial page count,
|
||||
// delete an old entry and add create a new one with updated limits
|
||||
let mem_initial = match module.memory_section_mut() {
|
||||
Some(section) => match section.entries_mut().pop() {
|
||||
Some(entry) => *entry.limits(),
|
||||
None => ResizableLimits::new(0 as _, Some(mem_pages_count)),
|
||||
Some(entry) => entry.limits().initial(),
|
||||
None => 0,
|
||||
},
|
||||
None => ResizableLimits::new(0 as _, Some(mem_pages_count)),
|
||||
None => 0,
|
||||
};
|
||||
|
||||
let memory_entry = MemoryType::new(limits.initial(), Some(mem_pages_count));
|
||||
|
||||
let memory_entry = MemoryType::new(mem_initial, Some(mem_pages_count));
|
||||
let mut default_mem_section = MemorySection::default();
|
||||
|
||||
// and create a new one
|
||||
module
|
||||
.memory_section_mut()
|
||||
.unwrap_or_else(|| &mut default_mem_section)
|
||||
|
Loading…
x
Reference in New Issue
Block a user