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