From 727393ff43865f2928ea63a718edaf56dfdee100 Mon Sep 17 00:00:00 2001
From: Guanqun Lu <guanqun.lu@gmail.com>
Date: Sat, 27 May 2017 00:54:27 +0800
Subject: [PATCH 1/3] add a simple test for is_push so that every small utility
 has a corresponding unit test

---
 ethcore/src/evm/instructions.rs | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/ethcore/src/evm/instructions.rs b/ethcore/src/evm/instructions.rs
index 336a3dcf1cd..2fb6cfd66a9 100644
--- a/ethcore/src/evm/instructions.rs
+++ b/ethcore/src/evm/instructions.rs
@@ -23,6 +23,13 @@ pub fn is_push(i: Instruction) -> bool {
 	i >= PUSH1 && i <= PUSH32
 }
 
+#[test]
+fn test_is_push() {
+	assert!(is_push(PUSH1));
+	assert!(is_push(PUSH32));
+	assert!(!is_push(DUP1));
+}
+
 /// Returns number of bytes to read for `PUSHN` instruction
 /// PUSH1 -> 1
 pub fn get_push_bytes(i: Instruction) -> usize {

From bb9cf6572ad6a1a9880ba15f6d4176b926e1ebfb Mon Sep 17 00:00:00 2001
From: Guanqun Lu <guanqun.lu@gmail.com>
Date: Sat, 27 May 2017 10:13:55 +0800
Subject: [PATCH 2/3] split evm/factory.rs into two files as the TODO suggests

---
 ethcore/src/evm/factory.rs | 61 +------------------------------
 ethcore/src/evm/mod.rs     |  4 +-
 ethcore/src/evm/vmtype.rs  | 75 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 79 insertions(+), 61 deletions(-)
 create mode 100644 ethcore/src/evm/vmtype.rs

diff --git a/ethcore/src/evm/factory.rs b/ethcore/src/evm/factory.rs
index fc16b1955fe..2d8934ca1f8 100644
--- a/ethcore/src/evm/factory.rs
+++ b/ethcore/src/evm/factory.rs
@@ -16,70 +16,11 @@
 
 //! Evm factory.
 //!
-//! TODO: consider spliting it into two separate files.
-use std::fmt;
 use std::sync::Arc;
 use evm::Evm;
 use util::U256;
 use super::interpreter::SharedCache;
-
-#[derive(Debug, PartialEq, Clone)]
-/// Type of EVM to use.
-pub enum VMType {
-	/// JIT EVM
-	#[cfg(feature = "jit")]
-	Jit,
-	/// RUST EVM
-	Interpreter
-}
-
-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"
-		})
-	}
-}
-
-impl Default for VMType {
-	fn default() -> Self {
-		VMType::Interpreter
-	}
-}
-
-impl VMType {
-	/// Return all possible VMs (JIT, Interpreter)
-	#[cfg(feature = "jit")]
-	pub fn all() -> Vec<VMType> {
-		vec![VMType::Jit, VMType::Interpreter]
-	}
-
-	/// Return all possible VMs (Interpreter)
-	#[cfg(not(feature = "jit"))]
-	pub fn all() -> Vec<VMType> {
-		vec![VMType::Interpreter]
-	}
-
-	/// Return new jit if it's possible
-	#[cfg(not(feature = "jit"))]
-	pub fn jit() -> Option<Self> {
-		None
-	}
-
-	/// Return new jit if it's possible
-	#[cfg(feature = "jit")]
-	pub fn jit() -> Option<Self> {
-		Some(VMType::Jit)
-	}
-}
+use super::vmtype::VMType;
 
 /// Evm factory. Creates appropriate Evm.
 #[derive(Clone)]
diff --git a/ethcore/src/evm/mod.rs b/ethcore/src/evm/mod.rs
index 8693a346785..f3aef375df3 100644
--- a/ethcore/src/evm/mod.rs
+++ b/ethcore/src/evm/mod.rs
@@ -19,6 +19,7 @@
 pub mod ext;
 pub mod evm;
 pub mod interpreter;
+mod vmtype;
 #[macro_use]
 pub mod factory;
 pub mod schedule;
@@ -33,6 +34,7 @@ mod benches;
 
 pub use self::evm::{Evm, Error, Finalize, FinalizationResult, GasLeft, Result, CostType};
 pub use self::ext::{Ext, ContractCreateResult, MessageCallResult, CreateContractAddress};
-pub use self::factory::{Factory, VMType};
+pub use self::vmtype::VMType;
+pub use self::factory::Factory;
 pub use self::schedule::Schedule;
 pub use types::executed::CallType;
diff --git a/ethcore/src/evm/vmtype.rs b/ethcore/src/evm/vmtype.rs
new file mode 100644
index 00000000000..192c3b9730f
--- /dev/null
+++ b/ethcore/src/evm/vmtype.rs
@@ -0,0 +1,75 @@
+// Copyright 2015-2017 Parity Technologies (UK) Ltd.
+// This file is part of Parity.
+
+// Parity is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// Parity is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with Parity.  If not, see <http://www.gnu.org/licenses/>.
+
+use std::fmt;
+
+#[derive(Debug, PartialEq, Clone)]
+/// Type of EVM to use.
+pub enum VMType {
+	/// JIT EVM
+	#[cfg(feature = "jit")]
+	Jit,
+	/// RUST EVM
+	Interpreter
+}
+
+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"
+		})
+	}
+}
+
+impl Default for VMType {
+	fn default() -> Self {
+		VMType::Interpreter
+	}
+}
+
+impl VMType {
+	/// Return all possible VMs (JIT, Interpreter)
+	#[cfg(feature = "jit")]
+	pub fn all() -> Vec<VMType> {
+		vec![VMType::Jit, VMType::Interpreter]
+	}
+
+	/// Return all possible VMs (Interpreter)
+	#[cfg(not(feature = "jit"))]
+	pub fn all() -> Vec<VMType> {
+		vec![VMType::Interpreter]
+	}
+
+	/// Return new jit if it's possible
+	#[cfg(not(feature = "jit"))]
+	pub fn jit() -> Option<Self> {
+		None
+	}
+
+	/// Return new jit if it's possible
+	#[cfg(feature = "jit")]
+	pub fn jit() -> Option<Self> {
+		Some(VMType::Jit)
+	}
+}

From cc1cc379b98c9576697228296d731f5cf1b141ad Mon Sep 17 00:00:00 2001
From: Guanqun Lu <guanqun.lu@gmail.com>
Date: Wed, 31 May 2017 00:30:17 +0800
Subject: [PATCH 3/3] style fixes according to review comments

---
 ethcore/src/evm/mod.rs    | 3 ++-
 ethcore/src/evm/vmtype.rs | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/ethcore/src/evm/mod.rs b/ethcore/src/evm/mod.rs
index f3aef375df3..3b27c1f31be 100644
--- a/ethcore/src/evm/mod.rs
+++ b/ethcore/src/evm/mod.rs
@@ -19,10 +19,11 @@
 pub mod ext;
 pub mod evm;
 pub mod interpreter;
-mod vmtype;
 #[macro_use]
 pub mod factory;
 pub mod schedule;
+
+mod vmtype;
 mod instructions;
 #[cfg(feature = "jit" )]
 mod jit;
diff --git a/ethcore/src/evm/vmtype.rs b/ethcore/src/evm/vmtype.rs
index 192c3b9730f..608ab1e815c 100644
--- a/ethcore/src/evm/vmtype.rs
+++ b/ethcore/src/evm/vmtype.rs
@@ -16,8 +16,8 @@
 
 use std::fmt;
 
-#[derive(Debug, PartialEq, Clone)]
 /// Type of EVM to use.
+#[derive(Debug, PartialEq, Clone)]
 pub enum VMType {
 	/// JIT EVM
 	#[cfg(feature = "jit")]