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,37 @@
use alloc::boxed::Box;
use alloc::string::ToString;
use anyhow::Result;
use cranelift_entity::PrimaryMap;
use cranelift_wasm::TableElementType;
use wasmtime_environ::Module;
use wasmtime_runtime::InstanceHandle;
use super::create_handle::create_handle;
use crate::{TableType, ValType};
pub fn create_handle_with_table(table: &TableType) -> Result<InstanceHandle> {
let mut module = Module::new();
let table = cranelift_wasm::Table {
minimum: table.limits().min(),
maximum: if table.limits().max() == core::u32::MAX {
None
} else {
Some(table.limits().max())
},
ty: match table.element() {
ValType::FuncRef => TableElementType::Func,
_ => TableElementType::Val(table.element().get_cranelift_type()),
},
};
let tunable = Default::default();
let table_plan = wasmtime_environ::TablePlan::for_table(table, &tunable);
let table_id = module.table_plans.push(table_plan);
module.exports.insert(
"table".to_string(),
wasmtime_environ::Export::Table(table_id),
);
create_handle(module, None, PrimaryMap::new(), Box::new(()))
}