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:
@@ -150,6 +150,9 @@ pub trait FuncEnvironment {
|
||||
/// [`translate_module`](fn.translate_module.html) function. These methods should not be called
|
||||
/// by the user, they are only for `cretonne-wasm` internal use.
|
||||
pub trait WasmRuntime: FuncEnvironment {
|
||||
/// Return the name for the given function index.
|
||||
fn get_name(&self, func_index: FunctionIndex) -> ir::FunctionName;
|
||||
|
||||
/// Declares a function signature to the runtime.
|
||||
fn declare_signature(&mut self, sig: &ir::Signature);
|
||||
|
||||
@@ -157,7 +160,7 @@ pub trait WasmRuntime: FuncEnvironment {
|
||||
fn get_signature(&self, sig_index: SignatureIndex) -> &ir::Signature;
|
||||
|
||||
/// Declares a function import to the runtime.
|
||||
fn declare_func_import(&mut self, sig_index: SignatureIndex, module: &[u8], field: &[u8]);
|
||||
fn declare_func_import(&mut self, sig_index: SignatureIndex, module: &str, field: &str);
|
||||
|
||||
/// Return the number of imported funcs.
|
||||
fn get_num_func_imports(&self) -> usize;
|
||||
@@ -193,6 +196,15 @@ pub trait WasmRuntime: FuncEnvironment {
|
||||
data: &[u8],
|
||||
) -> Result<(), String>;
|
||||
|
||||
/// Declares a function export to the runtime.
|
||||
fn declare_func_export(&mut self, func_index: FunctionIndex, name: &str);
|
||||
/// Declares a table export to the runtime.
|
||||
fn declare_table_export(&mut self, table_index: TableIndex, name: &str);
|
||||
/// Declares a memory export to the runtime.
|
||||
fn declare_memory_export(&mut self, memory_index: MemoryIndex, name: &str);
|
||||
/// Declares a global export to the runtime.
|
||||
fn declare_global_export(&mut self, global_index: GlobalIndex, name: &str);
|
||||
|
||||
/// Declares a start function.
|
||||
fn declare_start_func(&mut self, index: FunctionIndex);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user