mirror of
https://github.com/pezkuwichain/wasm-instrument.git
synced 2026-04-29 18:27:54 +00:00
Allow specifying the module of the imported 'gas' function (#140)
* No need for mem::replace when doing a simple assignment * Allow specifying the module of the imported 'gas' function This allows users to place the imported function inside a custom module instead of the generic 'env' module.
This commit is contained in:
committed by
GitHub
parent
b61f6dd52f
commit
409ced002a
+3
-4
@@ -29,7 +29,7 @@ pub fn optimize(
|
||||
let module_temp = module_temp
|
||||
.parse_names()
|
||||
.unwrap_or_else(|(_err, module)| module);
|
||||
mem::replace(module, module_temp);
|
||||
*module = module_temp;
|
||||
|
||||
// Algo starts from the top, listing all items that should stay
|
||||
let mut stay = Set::new();
|
||||
@@ -309,7 +309,7 @@ pub fn optimize(
|
||||
let totalle = eliminated_funcs.iter().take_while(|i| (**i as u32) < index).count() as u32;
|
||||
(index - totalle, value)
|
||||
}).collect();
|
||||
mem::replace(func_name.names_mut(), updated_map);
|
||||
*func_name.names_mut() = updated_map;
|
||||
}
|
||||
|
||||
if let Some(ref mut local_name) = name_section.locals_mut() {
|
||||
@@ -321,8 +321,7 @@ pub fn optimize(
|
||||
let totalle = eliminated_funcs.iter().take_while(|i| (**i as u32) < index).count() as u32;
|
||||
(index - totalle, value)
|
||||
}).collect();
|
||||
|
||||
mem::replace(local_name.local_names_mut(), updated_map);
|
||||
*local_name.local_names_mut() = updated_map;
|
||||
}
|
||||
}
|
||||
_ => { }
|
||||
|
||||
Reference in New Issue
Block a user