Declare exports via the WasmRuntime.
Also, redo how functions are named in the DummyRuntime. Use the FunctionName field to just encode the wasm function index rather than trying to shoehorn a printable name into it. And to make up for that, teach the wasm printer to print export names as comments next to the function definitions. This also makes the fields of DummyRuntime public, in preparation for the DummyRuntime to have a more general-purpose debugging role, as well as possibly to allow it to serve as a base for other implementations.
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
//! IL. Can also executes the `start` function of the module by laying out the memories, globals
|
||||
//! and tables, then emitting the translated code with hardcoded addresses to memory.
|
||||
|
||||
use cton_wasm::{translate_module, DummyRuntime};
|
||||
use cton_wasm::{translate_module, DummyRuntime, WasmRuntime};
|
||||
use std::path::PathBuf;
|
||||
use cretonne::Context;
|
||||
use cretonne::settings::FlagsOrIsa;
|
||||
@@ -113,7 +113,9 @@ fn handle_module(
|
||||
vprint!(flag_verbose, "Compiling... ");
|
||||
}
|
||||
terminal.reset().unwrap();
|
||||
for func in &translation.functions {
|
||||
let num_func_imports = dummy_runtime.get_num_func_imports();
|
||||
for (def_index, func) in translation.functions.iter().enumerate() {
|
||||
let func_index = num_func_imports + def_index;
|
||||
let mut context = Context::new();
|
||||
context.func = func.clone();
|
||||
if flag_check_translation {
|
||||
@@ -131,6 +133,14 @@ fn handle_module(
|
||||
}
|
||||
if flag_print {
|
||||
vprintln!(flag_verbose, "");
|
||||
if let Some(start_func) = dummy_runtime.start_func {
|
||||
if func_index == start_func {
|
||||
println!("; Selected as wasm start function");
|
||||
}
|
||||
}
|
||||
for export_name in &dummy_runtime.functions[func_index].export_names {
|
||||
println!("; Exported as \"{}\"", export_name);
|
||||
}
|
||||
println!("{}", context.func.display(fisa.isa));
|
||||
vprintln!(flag_verbose, "");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user