mirror of
https://github.com/pezkuwichain/wasm-instrument.git
synced 2026-06-13 08:11:09 +00:00
make unknown-unknown primary
This commit is contained in:
+26
-9
@@ -49,20 +49,37 @@ pub fn externalize_mem(mut module: elements::Module) -> elements::Module {
|
||||
module
|
||||
}
|
||||
|
||||
pub fn underscore_funcs(mut module: elements::Module) -> elements::Module {
|
||||
for entry in import_section(&mut module).expect("Import section to exist").entries_mut() {
|
||||
if let elements::External::Function(_) = *entry.external() {
|
||||
entry.field_mut().insert(0, '_');
|
||||
fn foreach_public_func_name<F>(mut module: elements::Module, f: F) -> elements::Module
|
||||
where F: Fn(&mut String)
|
||||
{
|
||||
import_section(&mut module).map(|is| {
|
||||
for entry in is.entries_mut() {
|
||||
if let elements::External::Function(_) = *entry.external() {
|
||||
f(entry.field_mut())
|
||||
}
|
||||
}
|
||||
}
|
||||
for entry in export_section(&mut module).expect("Import section to exist").entries_mut() {
|
||||
if let elements::Internal::Function(_) = *entry.internal() {
|
||||
entry.field_mut().insert(0, '_');
|
||||
});
|
||||
|
||||
export_section(&mut module).map(|es| {
|
||||
for entry in es.entries_mut() {
|
||||
if let elements::Internal::Function(_) = *entry.internal() {
|
||||
f(entry.field_mut())
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
module
|
||||
}
|
||||
|
||||
pub fn underscore_funcs(mut module: elements::Module) -> elements::Module {
|
||||
foreach_public_func_name(module, |n| n.insert(0, '_'))
|
||||
}
|
||||
|
||||
|
||||
pub fn ununderscore_funcs(mut module: elements::Module) -> elements::Module {
|
||||
foreach_public_func_name(module, |n| { n.remove(0); })
|
||||
}
|
||||
|
||||
pub fn externalize(
|
||||
module: elements::Module,
|
||||
replaced_funcs: Vec<&str>,
|
||||
|
||||
+4
-4
@@ -4,8 +4,9 @@ extern crate byteorder;
|
||||
#[macro_use] extern crate log;
|
||||
#[macro_use] extern crate lazy_static;
|
||||
|
||||
pub static CREATE_SYMBOL: &'static str = "_deploy";
|
||||
pub static CALL_SYMBOL: &'static str = "_call";
|
||||
pub static CREATE_SYMBOL: &'static str = "deploy";
|
||||
pub static CALL_SYMBOL: &'static str = "call";
|
||||
pub static MEMORY_SYMBOL: &'static str = "memory";
|
||||
|
||||
pub mod rules;
|
||||
|
||||
@@ -21,8 +22,7 @@ mod runtime_type;
|
||||
pub use optimizer::{optimize, Error as OptimizerError};
|
||||
pub use gas::inject_gas_counter;
|
||||
pub use logger::init_log;
|
||||
pub use ext::{externalize, externalize_mem, underscore_funcs};
|
||||
pub use ext::{externalize, externalize_mem, underscore_funcs, ununderscore_funcs};
|
||||
pub use pack::pack_instance;
|
||||
pub use nondeterminism_check::is_deterministic;
|
||||
pub use runtime_type::inject_runtime_type;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user