mirror of
https://github.com/fluencelabs/parity-wasm
synced 2025-06-26 13:12:04 +00:00
TableElementType
This commit is contained in:
@ -167,31 +167,31 @@ impl ModuleInstance {
|
||||
// instantiate linear memory regions, if any
|
||||
let memory = match module.memory_section() {
|
||||
Some(memory_section) => memory_section.entries()
|
||||
.iter()
|
||||
.map(MemoryInstance::new)
|
||||
.collect::<Result<Vec<_>, _>>()?,
|
||||
.iter()
|
||||
.map(MemoryInstance::new)
|
||||
.collect::<Result<Vec<_>, _>>()?,
|
||||
None => Vec::new(),
|
||||
};
|
||||
|
||||
// instantiate tables, if any
|
||||
let tables = match module.table_section() {
|
||||
Some(table_section) => table_section.entries()
|
||||
.iter()
|
||||
.map(|tt| TableInstance::new(VariableType::AnyFunc, tt)) // TODO: actual table type
|
||||
.collect::<Result<Vec<_>, _>>()?,
|
||||
.iter()
|
||||
.map(|tt| TableInstance::new(tt))
|
||||
.collect::<Result<Vec<_>, _>>()?,
|
||||
None => Vec::new(),
|
||||
};
|
||||
|
||||
// instantiate globals, if any
|
||||
let globals = match module.global_section() {
|
||||
Some(global_section) => global_section.entries()
|
||||
.iter()
|
||||
.map(|g| {
|
||||
get_initializer(g.init_expr(), &module, &imports, g.global_type().content_type().into())
|
||||
.map_err(|e| Error::Initialization(e.into()))
|
||||
.and_then(|v| VariableInstance::new_global(g.global_type(), v).map(Arc::new))
|
||||
})
|
||||
.collect::<Result<Vec<_>, _>>()?,
|
||||
.iter()
|
||||
.map(|g| {
|
||||
get_initializer(g.init_expr(), &module, &imports, g.global_type().content_type().into())
|
||||
.map_err(|e| Error::Initialization(e.into()))
|
||||
.and_then(|v| VariableInstance::new_global(g.global_type(), v).map(Arc::new))
|
||||
})
|
||||
.collect::<Result<Vec<_>, _>>()?,
|
||||
None => Vec::new(),
|
||||
};
|
||||
|
||||
|
@ -17,9 +17,10 @@ pub struct TableInstance {
|
||||
|
||||
impl TableInstance {
|
||||
/// New instance of the table
|
||||
pub fn new(variable_type: VariableType, table_type: &TableType) -> Result<Arc<Self>, Error> {
|
||||
pub fn new(table_type: &TableType) -> Result<Arc<Self>, Error> {
|
||||
check_limits(table_type.limits())?;
|
||||
|
||||
let variable_type = table_type.elem_type().into();
|
||||
Ok(Arc::new(TableInstance {
|
||||
variable_type: variable_type,
|
||||
buffer: RwLock::new(
|
||||
|
@ -1,5 +1,5 @@
|
||||
use parking_lot::RwLock;
|
||||
use elements::{GlobalType, ValueType};
|
||||
use elements::{GlobalType, ValueType, TableElementType};
|
||||
use interpreter::Error;
|
||||
use interpreter::value::RuntimeValue;
|
||||
|
||||
@ -98,3 +98,11 @@ impl From<ValueType> for VariableType {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<TableElementType> for VariableType {
|
||||
fn from(tt: TableElementType) -> VariableType {
|
||||
match tt {
|
||||
TableElementType::AnyFunc => VariableType::AnyFunc,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user