mirror of
https://github.com/pezkuwichain/wasm-instrument.git
synced 2026-06-12 19:21:07 +00:00
finalize tool
This commit is contained in:
+15
-1
@@ -1,5 +1,5 @@
|
||||
use parity_wasm::{elements, builder};
|
||||
use optimizer::import_section;
|
||||
use optimizer::{import_section, export_section};
|
||||
|
||||
type Insertion = (usize, u32, u32, String);
|
||||
|
||||
@@ -49,6 +49,20 @@ 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, '_');
|
||||
}
|
||||
}
|
||||
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, '_');
|
||||
}
|
||||
}
|
||||
module
|
||||
}
|
||||
|
||||
pub fn externalize(
|
||||
module: elements::Module,
|
||||
replaced_funcs: Vec<&str>,
|
||||
|
||||
+1
-1
@@ -21,7 +21,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};
|
||||
pub use ext::{externalize, externalize_mem, underscore_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