From 8a2db838034b15662dcd96f0c74329aab3f06bc3 Mon Sep 17 00:00:00 2001 From: Tomusdrw Date: Wed, 3 Feb 2016 15:57:17 +0100 Subject: [PATCH] Removing --- ethcore/src/evm/factory.rs | 35 +++++++++++++++++++++++------------ ethcore/src/state_diff.rs | 1 - ethcore/src/tests/helpers.rs | 18 +++++++++--------- 3 files changed, 32 insertions(+), 22 deletions(-) diff --git a/ethcore/src/evm/factory.rs b/ethcore/src/evm/factory.rs index eff2a1850..923de26f4 100644 --- a/ethcore/src/evm/factory.rs +++ b/ethcore/src/evm/factory.rs @@ -1,26 +1,35 @@ //! Evm factory. //! //! TODO: consider spliting it into two separate files. +#[cfg(test)] use std::fmt; use evm::Evm; #[derive(Clone)] /// Type of EVM to use. pub enum VMType { - #[allow(dead_code)] // crated only by jit /// JIT EVM + #[cfg(feature="jit")] Jit, /// RUST EVM Interpreter } +#[cfg(test)] impl fmt::Display for VMType { + #[cfg(feature="jit")] fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}", match *self { VMType::Jit => "JIT", VMType::Interpreter => "INT" }) } + #[cfg(not(feature="jit"))] + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{}", match *self { + VMType::Interpreter => "INT" + }) + } } #[cfg(test)] @@ -46,10 +55,12 @@ pub struct Factory { impl Factory { /// Create fresh instance of VM + #[cfg(test)] + #[cfg(feature="jit")] pub fn create(&self) -> Box { match self.evm { VMType::Jit => { - Factory::jit() + Box::new(super::jit::JitEvm) }, VMType::Interpreter => { Box::new(super::interpreter::Interpreter) @@ -57,6 +68,16 @@ impl Factory { } } + /// Create fresh instance of VM + #[cfg(not(feature="jit"))] + pub fn create(&self) -> Box { + match self.evm { + VMType::Interpreter => { + Box::new(super::interpreter::Interpreter) + } + } + } + /// Create new instance of specific `VMType` factory #[cfg(test)] pub fn new(evm: VMType) -> Factory { @@ -64,16 +85,6 @@ impl Factory { evm: evm } } - - #[cfg(feature = "jit")] - fn jit() -> Box { - Box::new(super::jit::JitEvm) - } - - #[cfg(not(feature = "jit"))] - fn jit() -> Box { - unimplemented!() - } } impl Default for Factory { /// Returns jitvm factory diff --git a/ethcore/src/state_diff.rs b/ethcore/src/state_diff.rs index 0d0f63fd8..ba9e6e816 100644 --- a/ethcore/src/state_diff.rs +++ b/ethcore/src/state_diff.rs @@ -11,7 +11,6 @@ pub struct StateDiff (BTreeMap); impl StateDiff { #[cfg(test)] /// Calculate and return diff between `pre` state and `post` state. - #[allow(dead_code)] // Used only in test code for now. pub fn diff_pod(pre: &PodState, post: &PodState) -> StateDiff { StateDiff(pre.get().keys().merge(post.get().keys()).filter_map(|acc| AccountDiff::diff_pod(pre.get().get(acc), post.get().get(acc)).map(|d|(acc.clone(), d))).collect()) } diff --git a/ethcore/src/tests/helpers.rs b/ethcore/src/tests/helpers.rs index 9d784ea98..04d47cbd3 100644 --- a/ethcore/src/tests/helpers.rs +++ b/ethcore/src/tests/helpers.rs @@ -46,10 +46,10 @@ impl Drop for RandomTempPath { } } -#[allow(dead_code)] +#[cfg(test)] pub struct GuardedTempResult { result: T, - temp: RandomTempPath + _temp: RandomTempPath } impl GuardedTempResult { @@ -149,7 +149,7 @@ pub fn generate_dummy_client(block_number: u32) -> GuardedTempResult client.import_verified_blocks(&IoChannel::disconnected()); GuardedTempResult::> { - temp: dir, + _temp: dir, result: client } } @@ -167,7 +167,7 @@ pub fn get_test_client_with_blocks(blocks: Vec) -> GuardedTempResult> { - temp: dir, + _temp: dir, result: client } } @@ -180,7 +180,7 @@ pub fn generate_dummy_blockchain(block_number: u32) -> GuardedTempResult { - temp: temp, + _temp: temp, result: bc } } @@ -193,7 +193,7 @@ pub fn generate_dummy_blockchain_with_extra(block_number: u32) -> GuardedTempRes } GuardedTempResult:: { - temp: temp, + _temp: temp, result: bc } } @@ -203,7 +203,7 @@ pub fn generate_dummy_empty_blockchain() -> GuardedTempResult { let bc = BlockChain::new(&create_unverifiable_block(0, H256::zero()), temp.as_path()); GuardedTempResult:: { - temp: temp, + _temp: temp, result: bc } } @@ -213,7 +213,7 @@ pub fn get_temp_journal_db() -> GuardedTempResult { let db = DB::open_default(temp.as_str()).unwrap(); let journal_db = JournalDB::new(db); GuardedTempResult { - temp: temp, + _temp: temp, result: journal_db } } @@ -222,7 +222,7 @@ pub fn get_temp_state() -> GuardedTempResult { let temp = RandomTempPath::new(); let journal_db = get_temp_journal_db_in(temp.as_path()); GuardedTempResult { - temp: temp, + _temp: temp, result: State::new(journal_db, U256::from(0u8)) } }