Store module name on wasmtime_environ::Module (#1309)

* Store module name on `wasmtime_environ::Module`

This keeps all name information in one place so we dont' have to keep
extra structures around in `wasmtime::Module`.

* rustfmt
This commit is contained in:
Alex Crichton
2020-03-13 17:51:10 -05:00
committed by GitHub
parent 922b49744b
commit 65e32b3660
8 changed files with 47 additions and 47 deletions

View File

@@ -128,6 +128,9 @@ pub struct DummyEnvironment {
/// Instructs to collect debug data during translation.
debug_info: bool,
/// Name of the module from the wasm file.
pub module_name: Option<String>,
/// Function names.
function_names: SecondaryMap<FuncIndex, String>,
}
@@ -141,6 +144,7 @@ impl DummyEnvironment {
func_bytecode_sizes: Vec::new(),
return_mode,
debug_info,
module_name: None,
function_names: SecondaryMap::new(),
}
}
@@ -726,6 +730,11 @@ impl<'data> ModuleEnvironment<'data> for DummyEnvironment {
Ok(())
}
fn declare_module_name(&mut self, name: &'data str) -> WasmResult<()> {
self.module_name = Some(String::from(name));
Ok(())
}
fn declare_func_name(&mut self, func_index: FuncIndex, name: &'data str) -> WasmResult<()> {
self.function_names[func_index] = String::from(name);
Ok(())