2019-03-28 13:46:30 -07:00
|
|
|
use wasmer_runtime_core::module::Module;
|
2019-03-28 12:19:23 -07:00
|
|
|
|
2019-03-28 13:46:30 -07:00
|
|
|
/// Check if a provided module is compiled with WASI support
|
2019-03-28 12:19:23 -07:00
|
|
|
pub fn is_wasi_module(module: &Module) -> bool {
|
2019-09-22 18:23:22 -07:00
|
|
|
if module.info().imported_functions.is_empty() {
|
|
|
|
return false;
|
|
|
|
}
|
2019-03-28 13:46:30 -07:00
|
|
|
for (_, import_name) in &module.info().imported_functions {
|
|
|
|
let namespace = module
|
|
|
|
.info()
|
|
|
|
.namespace_table
|
|
|
|
.get(import_name.namespace_index);
|
2019-09-22 18:23:22 -07:00
|
|
|
if namespace != "wasi_unstable" {
|
|
|
|
return false;
|
2019-03-28 13:46:30 -07:00
|
|
|
}
|
|
|
|
}
|
2019-09-22 18:23:22 -07:00
|
|
|
true
|
2019-03-28 12:19:23 -07:00
|
|
|
}
|