mirror of
https://github.com/pezkuwichain/wasm-instrument.git
synced 2026-06-12 12:21:22 +00:00
Refactor TargetRuntime as enum
Don't rename create symbol for substrate binaries
This commit is contained in:
+47
-30
@@ -5,59 +5,76 @@
|
||||
#[macro_use]
|
||||
extern crate alloc;
|
||||
|
||||
extern crate parity_wasm;
|
||||
extern crate byteorder;
|
||||
#[macro_use] extern crate log;
|
||||
extern crate parity_wasm;
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
|
||||
pub mod rules;
|
||||
|
||||
mod build;
|
||||
mod optimizer;
|
||||
mod gas;
|
||||
mod symbols;
|
||||
mod ext;
|
||||
mod gas;
|
||||
mod optimizer;
|
||||
mod pack;
|
||||
mod runtime_type;
|
||||
mod symbols;
|
||||
|
||||
pub mod stack_height;
|
||||
|
||||
pub use build::{build, SourceTarget, Error as BuildError};
|
||||
pub use optimizer::{optimize, Error as OptimizerError};
|
||||
pub use build::{build, Error as BuildError, SourceTarget};
|
||||
pub use ext::{
|
||||
externalize, externalize_mem, shrink_unknown_stack, underscore_funcs, ununderscore_funcs,
|
||||
};
|
||||
pub use gas::inject_gas_counter;
|
||||
pub use ext::{externalize, externalize_mem, underscore_funcs, ununderscore_funcs, shrink_unknown_stack};
|
||||
pub use optimizer::{optimize, Error as OptimizerError};
|
||||
pub use pack::{pack_instance, Error as PackingError};
|
||||
pub use runtime_type::inject_runtime_type;
|
||||
|
||||
pub struct TargetRuntime {
|
||||
pub create_symbol: &'static str,
|
||||
pub call_symbol: &'static str,
|
||||
pub return_symbol: &'static str,
|
||||
pub struct TargetSymbols {
|
||||
pub create: &'static str,
|
||||
pub call: &'static str,
|
||||
pub return_: &'static str,
|
||||
}
|
||||
|
||||
pub enum TargetRuntime {
|
||||
Substrate(TargetSymbols),
|
||||
PWasm(TargetSymbols),
|
||||
}
|
||||
|
||||
impl TargetRuntime {
|
||||
pub fn substrate() -> TargetRuntime {
|
||||
TargetRuntime {
|
||||
create_symbol: "deploy",
|
||||
call_symbol: "call",
|
||||
return_symbol: "ext_return",
|
||||
}
|
||||
}
|
||||
|
||||
pub fn pwasm() -> TargetRuntime {
|
||||
TargetRuntime {
|
||||
create_symbol: "deploy",
|
||||
call_symbol: "call",
|
||||
return_symbol: "ret",
|
||||
pub fn substrate() -> TargetRuntime {
|
||||
TargetRuntime::Substrate(TargetSymbols {
|
||||
create: "deploy",
|
||||
call: "call",
|
||||
return_: "ext_return",
|
||||
})
|
||||
}
|
||||
|
||||
pub fn pwasm() -> TargetRuntime {
|
||||
TargetRuntime::PWasm(TargetSymbols {
|
||||
create: "deploy",
|
||||
call: "call",
|
||||
return_: "ret",
|
||||
})
|
||||
}
|
||||
|
||||
pub fn symbols(&self) -> &TargetSymbols {
|
||||
match self {
|
||||
TargetRuntime::Substrate(s) => s,
|
||||
TargetRuntime::PWasm(s) => s,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "std"))]
|
||||
mod std {
|
||||
pub use core::*;
|
||||
pub use alloc::{vec, string, boxed, borrow};
|
||||
pub use alloc::{borrow, boxed, string, vec};
|
||||
pub use core::*;
|
||||
|
||||
pub mod collections {
|
||||
pub use alloc::collections::{BTreeMap, BTreeSet};
|
||||
}
|
||||
pub mod collections {
|
||||
pub use alloc::collections::{BTreeMap, BTreeSet};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user