kwasm imports

This commit is contained in:
Heyang Zhou
2019-05-04 08:28:13 -07:00
parent af0b1476f3
commit c4e4efc694
5 changed files with 46 additions and 5 deletions

View File

@ -449,10 +449,17 @@ fn import_functions(
});
}
None => {
link_errors.push(LinkError::ImportNotFound {
namespace: namespace.to_string(),
name: name.to_string(),
});
if imports.allow_missing_functions {
functions.push(vm::ImportedFunc {
func: ::std::ptr::null(),
vmctx: ::std::ptr::null_mut(),
});
} else {
link_errors.push(LinkError::ImportNotFound {
namespace: namespace.to_string(),
name: name.to_string(),
});
}
}
}
}

View File

@ -47,6 +47,7 @@ impl IsExport for Export {
pub struct ImportObject {
map: Rc<RefCell<HashMap<String, Box<dyn LikeNamespace>>>>,
state_creator: Option<Rc<Fn() -> (*mut c_void, fn(*mut c_void))>>,
pub allow_missing_functions: bool,
}
impl ImportObject {
@ -55,6 +56,7 @@ impl ImportObject {
Self {
map: Rc::new(RefCell::new(HashMap::new())),
state_creator: None,
allow_missing_functions: false,
}
}
@ -65,6 +67,7 @@ impl ImportObject {
Self {
map: Rc::new(RefCell::new(HashMap::new())),
state_creator: Some(Rc::new(state_creator)),
allow_missing_functions: false,
}
}
@ -116,6 +119,7 @@ impl ImportObject {
Self {
map: Rc::clone(&self.map),
state_creator: self.state_creator.clone(),
allow_missing_functions: false,
}
}