Rename the address field of Table/Memory/Global exports to definition.
For functions, `address` makes sense because it's the address of the function. Bt for Table/Memory/Global, it points to a `VM*Definition` field.
This commit is contained in:
@@ -213,12 +213,12 @@ impl InstancePlus {
|
||||
start: usize,
|
||||
len: usize,
|
||||
) -> Result<&[u8], ActionError> {
|
||||
let address = match unsafe { self.instance.lookup_immutable(memory_name) } {
|
||||
let definition = match unsafe { self.instance.lookup_immutable(memory_name) } {
|
||||
Some(Export::Memory {
|
||||
address,
|
||||
definition,
|
||||
memory: _memory,
|
||||
vmctx: _vmctx,
|
||||
}) => address,
|
||||
}) => definition,
|
||||
Some(_) => {
|
||||
return Err(ActionError::Kind(format!(
|
||||
"exported item \"{}\" is not a linear memory",
|
||||
@@ -234,15 +234,15 @@ impl InstancePlus {
|
||||
};
|
||||
|
||||
Ok(unsafe {
|
||||
let memory_def = &*address;
|
||||
let memory_def = &*definition;
|
||||
&slice::from_raw_parts(memory_def.base, memory_def.current_length)[start..start + len]
|
||||
})
|
||||
}
|
||||
|
||||
/// Read a global in this `Instance` identified by an export name.
|
||||
pub fn get(&self, global_name: &str) -> Result<RuntimeValue, ActionError> {
|
||||
let (address, global) = match unsafe { self.instance.lookup_immutable(global_name) } {
|
||||
Some(Export::Global { address, global }) => (address, global),
|
||||
let (definition, global) = match unsafe { self.instance.lookup_immutable(global_name) } {
|
||||
Some(Export::Global { definition, global }) => (definition, global),
|
||||
Some(_) => {
|
||||
return Err(ActionError::Kind(format!(
|
||||
"exported item \"{}\" is not a global variable",
|
||||
@@ -258,7 +258,7 @@ impl InstancePlus {
|
||||
};
|
||||
|
||||
unsafe {
|
||||
let global_def = &*address;
|
||||
let global_def = &*definition;
|
||||
Ok(match global.ty {
|
||||
ir::types::I32 => RuntimeValue::I32(*global_def.as_i32()),
|
||||
ir::types::I64 => RuntimeValue::I64(*global_def.as_i64()),
|
||||
|
||||
@@ -71,7 +71,7 @@ pub fn link_module(
|
||||
match resolver.resolve(module_name, field) {
|
||||
Some(export_value) => match export_value {
|
||||
Export::Table {
|
||||
address,
|
||||
definition,
|
||||
vmctx,
|
||||
table,
|
||||
} => {
|
||||
@@ -83,7 +83,7 @@ pub fn link_module(
|
||||
)));
|
||||
}
|
||||
table_imports.push(VMTableImport {
|
||||
from: address,
|
||||
from: definition,
|
||||
vmctx,
|
||||
});
|
||||
}
|
||||
@@ -108,7 +108,7 @@ pub fn link_module(
|
||||
match resolver.resolve(module_name, field) {
|
||||
Some(export_value) => match export_value {
|
||||
Export::Memory {
|
||||
address,
|
||||
definition,
|
||||
vmctx,
|
||||
memory,
|
||||
} => {
|
||||
@@ -136,7 +136,7 @@ pub fn link_module(
|
||||
assert!(memory.offset_guard_size >= import_memory.offset_guard_size);
|
||||
|
||||
memory_imports.push(VMMemoryImport {
|
||||
from: address,
|
||||
from: definition,
|
||||
vmctx,
|
||||
});
|
||||
}
|
||||
@@ -160,7 +160,7 @@ pub fn link_module(
|
||||
for (index, (ref module_name, ref field)) in module.imported_globals.iter() {
|
||||
match resolver.resolve(module_name, field) {
|
||||
Some(export_value) => match export_value {
|
||||
Export::Global { address, global } => {
|
||||
Export::Global { definition, global } => {
|
||||
let imported_global = module.globals[index];
|
||||
if !is_global_compatible(&global, &imported_global) {
|
||||
return Err(LinkError(format!(
|
||||
@@ -168,7 +168,7 @@ pub fn link_module(
|
||||
module_name, field
|
||||
)));
|
||||
}
|
||||
global_imports.push(VMGlobalImport { from: address });
|
||||
global_imports.push(VMGlobalImport { from: definition });
|
||||
}
|
||||
Export::Table { .. } | Export::Memory { .. } | Export::Function { .. } => {
|
||||
return Err(LinkError(format!(
|
||||
|
||||
Reference in New Issue
Block a user