More code reorganization.

This commit is contained in:
Dan Gohman
2018-08-03 13:45:46 -07:00
parent 6659ef7018
commit 831b481f13
10 changed files with 177 additions and 180 deletions

View File

@@ -5,14 +5,14 @@ use wasmtime_runtime;
/// Emits a module that has been emitted with the `WasmRuntime` runtime
/// implementation to a native object file.
pub fn emit_module<'module>(
pub fn emit_module(
obj: &mut Artifact,
compilation: &wasmtime_runtime::Compilation<'module>,
module: &wasmtime_runtime::Module,
compilation: &wasmtime_runtime::Compilation,
relocations: &wasmtime_runtime::Relocations,
) -> Result<(), String> {
debug_assert!(
compilation.module.start_func.is_none()
|| compilation.module.start_func.unwrap() >= compilation.module.imported_funcs.len(),
module.start_func.is_none() || module.start_func.unwrap() >= module.imported_funcs.len(),
"imported start functions not supported yet"
);
@@ -24,7 +24,7 @@ pub fn emit_module<'module>(
for (i, function_relocs) in relocations.iter().enumerate() {
assert!(function_relocs.is_empty(), "relocations not supported yet");
let body = &compilation.functions[i];
let func_index = compilation.module.imported_funcs.len() + i;
let func_index = module.imported_funcs.len() + i;
let string_name = format!("wasm_function[{}]", func_index);
obj.define(string_name, body.clone())