[wasmtime-api] Implementation of classes for run-{reflect,start,global,memory}-c (#295)

Implements apis for reflect-c, start-c, run-global-c and run-memory-c
This commit is contained in:
Yury Delendik
2019-08-26 10:07:02 -05:00
committed by GitHub
parent 45fd9dadd8
commit c94c383a7c
9 changed files with 1324 additions and 431 deletions

View File

@@ -27,11 +27,19 @@ impl Limits {
max: ::std::u32::MAX,
}
}
pub fn min(&self) -> u32 {
self.min
}
pub fn max(&self) -> u32 {
self.max
}
}
// Value Types
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Eq, PartialEq)]
pub enum ValType {
I32,
I64,
@@ -237,6 +245,17 @@ impl TableType {
pub fn limits(&self) -> &Limits {
&self.limits
}
pub(crate) fn from_cranelift_table(table: cranelift_wasm::Table) -> TableType {
assert!(if let cranelift_wasm::TableElementType::Func = table.ty {
true
} else {
false
});
let ty = ValType::FuncRef;
let limits = Limits::new(table.minimum, table.maximum.unwrap_or(::std::u32::MAX));
TableType::new(ty, limits)
}
}
// Memory Types