Refactor TargetRuntime as enum

Don't rename create symbol for substrate binaries
This commit is contained in:
holygits
2019-01-23 17:03:53 +13:00
parent 7c7a0713fc
commit c47adc1bd4
5 changed files with 74 additions and 53 deletions
+3 -3
View File
@@ -51,7 +51,7 @@ impl std::fmt::Display for Error {
fn has_ctor(module: &elements::Module, target_runtime: &TargetRuntime) -> bool {
if let Some(ref section) = module.export_section() {
section.entries().iter().any(|e| target_runtime.create_symbol == e.field())
section.entries().iter().any(|e| target_runtime.symbols().create == e.field())
} else {
false
}
@@ -94,7 +94,7 @@ pub fn build(
let mut ctor_module = module.clone();
let mut public_api_entries = public_api_entries.to_vec();
public_api_entries.push(target_runtime.call_symbol);
public_api_entries.push(target_runtime.symbols().call);
if !skip_optimization {
optimize(
&mut module,
@@ -104,7 +104,7 @@ pub fn build(
if has_ctor(&ctor_module, target_runtime) {
if !skip_optimization {
optimize(&mut ctor_module, vec![target_runtime.create_symbol])?;
optimize(&mut ctor_module, vec![target_runtime.symbols().create])?;
}
let ctor_module = pack_instance(
parity_wasm::serialize(module.clone()).map_err(Error::Encoding)?,