Initial reorg.

This is largely the same as #305, but updated for the current tree.
This commit is contained in:
Dan Gohman
2019-11-07 17:11:06 -08:00
parent 2c69546a24
commit 22641de629
351 changed files with 52 additions and 52 deletions

View File

@@ -0,0 +1,35 @@
use alloc::boxed::Box;
use alloc::string::ToString;
use anyhow::Result;
use cranelift_entity::PrimaryMap;
use wasmtime_environ::Module;
use wasmtime_runtime::InstanceHandle;
use super::create_handle::create_handle;
use crate::MemoryType;
#[allow(dead_code)]
pub fn create_handle_with_memory(memory: &MemoryType) -> Result<InstanceHandle> {
let mut module = Module::new();
let memory = cranelift_wasm::Memory {
minimum: memory.limits().min(),
maximum: if memory.limits().max() == core::u32::MAX {
None
} else {
Some(memory.limits().max())
},
shared: false, // TODO
};
let tunable = Default::default();
let memory_plan = wasmtime_environ::MemoryPlan::for_memory(memory, &tunable);
let memory_id = module.memory_plans.push(memory_plan);
module.exports.insert(
"memory".to_string(),
wasmtime_environ::Export::Memory(memory_id),
);
create_handle(module, None, PrimaryMap::new(), Box::new(()))
}