diff --git a/src/lib.rs b/src/lib.rs index 8b42ccd..08bd80c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -42,6 +42,7 @@ pub use graph::{Module, parse as graph_parse, generate as graph_generate}; pub use ref_list::{RefList, Entry, EntryRef, DeleteTransaction}; #[cfg(feature = "std")] pub use export_globals::export_mutable_globals; +pub use parity_wasm::elements::Instruction; pub struct TargetSymbols { pub create: &'static str, diff --git a/src/rules.rs b/src/rules.rs index 2256a6c..3f83f6e 100644 --- a/src/rules.rs +++ b/src/rules.rs @@ -5,8 +5,7 @@ use crate::std::collections::BTreeMap as Map; use crate::std::num::NonZeroU32; use crate::std::str::FromStr; - -use parity_wasm::elements; +use crate::Instruction; pub struct UnknownInstruction; @@ -17,7 +16,7 @@ pub trait Rules { /// Returning `None` makes the gas instrumention end with an error. This is meant /// as a way to have a partial rule set where any instruction that is not specifed /// is considered as forbidden. - fn instruction_cost(&self, instruction: &elements::Instruction) -> Option; + fn instruction_cost(&self, instruction: &Instruction) -> Option; /// Returns the costs for growing the memory using the `memory.grow` instruction. /// @@ -100,8 +99,8 @@ impl FromStr for InstructionType { } impl InstructionType { - pub fn op(instruction: &elements::Instruction) -> Self { - use parity_wasm::elements::Instruction::*; + pub fn op(instruction: &Instruction) -> Self { + use Instruction::*; match *instruction { Unreachable => InstructionType::Unreachable, @@ -337,7 +336,7 @@ impl Set { } impl Rules for Set { - fn instruction_cost(&self, instruction: &elements::Instruction) -> Option { + fn instruction_cost(&self, instruction: &Instruction) -> Option { match self.entries.get(&InstructionType::op(instruction)) { None | Some(Metering::Regular) => Some(self.regular), Some(Metering::Fixed(val)) => Some(*val),