Instruction.cpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  1. /*
  2. This file is part of cpp-ethereum.
  3. cpp-ethereum is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation, either version 3 of the License, or
  6. (at your option) any later version.
  7. cpp-ethereum is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
  13. */
  14. /** @file Instruction.cpp
  15. * @author Gav Wood <i@gavwood.com>
  16. * @date 2014
  17. */
  18. #include "Instruction.h"
  19. #include <functional>
  20. #include <libdevcore/Common.h>
  21. #include <libdevcore/CommonIO.h>
  22. #include <libdevcore/Log.h>
  23. using namespace std;
  24. using namespace dev;
  25. using namespace dev::eth;
  26. const std::map<std::string, Instruction> dev::eth::c_instructions =
  27. {
  28. { "STOP", Instruction::STOP },
  29. { "ADD", Instruction::ADD },
  30. { "SUB", Instruction::SUB },
  31. { "MUL", Instruction::MUL },
  32. { "DIV", Instruction::DIV },
  33. { "SDIV", Instruction::SDIV },
  34. { "MOD", Instruction::MOD },
  35. { "SMOD", Instruction::SMOD },
  36. { "EXP", Instruction::EXP },
  37. { "BNOT", Instruction::NOT },
  38. { "LT", Instruction::LT },
  39. { "GT", Instruction::GT },
  40. { "SLT", Instruction::SLT },
  41. { "SGT", Instruction::SGT },
  42. { "EQ", Instruction::EQ },
  43. { "NOT", Instruction::ISZERO },
  44. { "AND", Instruction::AND },
  45. { "OR", Instruction::OR },
  46. { "XOR", Instruction::XOR },
  47. { "BYTE", Instruction::BYTE },
  48. { "ADDMOD", Instruction::ADDMOD },
  49. { "MULMOD", Instruction::MULMOD },
  50. { "SIGNEXTEND", Instruction::SIGNEXTEND },
  51. { "SHA3", Instruction::SHA3 },
  52. { "ADDRESS", Instruction::ADDRESS },
  53. { "BALANCE", Instruction::BALANCE },
  54. { "ORIGIN", Instruction::ORIGIN },
  55. { "CALLER", Instruction::CALLER },
  56. { "CALLVALUE", Instruction::CALLVALUE },
  57. { "CALLDATALOAD", Instruction::CALLDATALOAD },
  58. { "CALLDATASIZE", Instruction::CALLDATASIZE },
  59. { "CALLDATACOPY", Instruction::CALLDATACOPY },
  60. { "CODESIZE", Instruction::CODESIZE },
  61. { "CODECOPY", Instruction::CODECOPY },
  62. { "GASPRICE", Instruction::GASPRICE },
  63. { "EXTCODESIZE", Instruction::EXTCODESIZE },
  64. { "EXTCODECOPY", Instruction::EXTCODECOPY },
  65. { "BLOCKHASH", Instruction::BLOCKHASH },
  66. { "COINBASE", Instruction::COINBASE },
  67. { "TIMESTAMP", Instruction::TIMESTAMP },
  68. { "NUMBER", Instruction::NUMBER },
  69. { "DIFFICULTY", Instruction::DIFFICULTY },
  70. { "GASLIMIT", Instruction::GASLIMIT },
  71. { "POP", Instruction::POP },
  72. { "MLOAD", Instruction::MLOAD },
  73. { "MSTORE", Instruction::MSTORE },
  74. { "MSTORE8", Instruction::MSTORE8 },
  75. { "SLOAD", Instruction::SLOAD },
  76. { "SSTORE", Instruction::SSTORE },
  77. { "JUMP", Instruction::JUMP },
  78. { "JUMPI", Instruction::JUMPI },
  79. { "PC", Instruction::PC },
  80. { "MSIZE", Instruction::MSIZE },
  81. { "GAS", Instruction::GAS },
  82. { "JUMPDEST", Instruction::JUMPDEST },
  83. { "PUSH1", Instruction::PUSH1 },
  84. { "PUSH2", Instruction::PUSH2 },
  85. { "PUSH3", Instruction::PUSH3 },
  86. { "PUSH4", Instruction::PUSH4 },
  87. { "PUSH5", Instruction::PUSH5 },
  88. { "PUSH6", Instruction::PUSH6 },
  89. { "PUSH7", Instruction::PUSH7 },
  90. { "PUSH8", Instruction::PUSH8 },
  91. { "PUSH9", Instruction::PUSH9 },
  92. { "PUSH10", Instruction::PUSH10 },
  93. { "PUSH11", Instruction::PUSH11 },
  94. { "PUSH12", Instruction::PUSH12 },
  95. { "PUSH13", Instruction::PUSH13 },
  96. { "PUSH14", Instruction::PUSH14 },
  97. { "PUSH15", Instruction::PUSH15 },
  98. { "PUSH16", Instruction::PUSH16 },
  99. { "PUSH17", Instruction::PUSH17 },
  100. { "PUSH18", Instruction::PUSH18 },
  101. { "PUSH19", Instruction::PUSH19 },
  102. { "PUSH20", Instruction::PUSH20 },
  103. { "PUSH21", Instruction::PUSH21 },
  104. { "PUSH22", Instruction::PUSH22 },
  105. { "PUSH23", Instruction::PUSH23 },
  106. { "PUSH24", Instruction::PUSH24 },
  107. { "PUSH25", Instruction::PUSH25 },
  108. { "PUSH26", Instruction::PUSH26 },
  109. { "PUSH27", Instruction::PUSH27 },
  110. { "PUSH28", Instruction::PUSH28 },
  111. { "PUSH29", Instruction::PUSH29 },
  112. { "PUSH30", Instruction::PUSH30 },
  113. { "PUSH31", Instruction::PUSH31 },
  114. { "PUSH32", Instruction::PUSH32 },
  115. { "DUP1", Instruction::DUP1 },
  116. { "DUP2", Instruction::DUP2 },
  117. { "DUP3", Instruction::DUP3 },
  118. { "DUP4", Instruction::DUP4 },
  119. { "DUP5", Instruction::DUP5 },
  120. { "DUP6", Instruction::DUP6 },
  121. { "DUP7", Instruction::DUP7 },
  122. { "DUP8", Instruction::DUP8 },
  123. { "DUP9", Instruction::DUP9 },
  124. { "DUP10", Instruction::DUP10 },
  125. { "DUP11", Instruction::DUP11 },
  126. { "DUP12", Instruction::DUP12 },
  127. { "DUP13", Instruction::DUP13 },
  128. { "DUP14", Instruction::DUP14 },
  129. { "DUP15", Instruction::DUP15 },
  130. { "DUP16", Instruction::DUP16 },
  131. { "SWAP1", Instruction::SWAP1 },
  132. { "SWAP2", Instruction::SWAP2 },
  133. { "SWAP3", Instruction::SWAP3 },
  134. { "SWAP4", Instruction::SWAP4 },
  135. { "SWAP5", Instruction::SWAP5 },
  136. { "SWAP6", Instruction::SWAP6 },
  137. { "SWAP7", Instruction::SWAP7 },
  138. { "SWAP8", Instruction::SWAP8 },
  139. { "SWAP9", Instruction::SWAP9 },
  140. { "SWAP10", Instruction::SWAP10 },
  141. { "SWAP11", Instruction::SWAP11 },
  142. { "SWAP12", Instruction::SWAP12 },
  143. { "SWAP13", Instruction::SWAP13 },
  144. { "SWAP14", Instruction::SWAP14 },
  145. { "SWAP15", Instruction::SWAP15 },
  146. { "SWAP16", Instruction::SWAP16 },
  147. { "LOG0", Instruction::LOG0 },
  148. { "LOG1", Instruction::LOG1 },
  149. { "LOG2", Instruction::LOG2 },
  150. { "LOG3", Instruction::LOG3 },
  151. { "LOG4", Instruction::LOG4 },
  152. { "CREATE", Instruction::CREATE },
  153. { "CALL", Instruction::CALL },
  154. { "CALLCODE", Instruction::CALLCODE },
  155. { "RETURN", Instruction::RETURN },
  156. { "DELEGATECALL", Instruction::DELEGATECALL },
  157. { "SUICIDE", Instruction::SUICIDE },
  158. // these are generated by the interpreter - should never be in user code
  159. { "PUSHC", Instruction::PUSHC },
  160. { "JUMPV", Instruction::JUMPV },
  161. { "JUMPVI", Instruction::JUMPVI }
  162. };
  163. static const std::map<Instruction, InstructionInfo> c_instructionInfo =
  164. { // Add, Args, Ret, SideEffects, GasPriceTier
  165. { Instruction::STOP, { "STOP", 0, 0, 0, true, ZeroTier } },
  166. { Instruction::ADD, { "ADD", 0, 2, 1, false, VeryLowTier } },
  167. { Instruction::SUB, { "SUB", 0, 2, 1, false, VeryLowTier } },
  168. { Instruction::MUL, { "MUL", 0, 2, 1, false, LowTier } },
  169. { Instruction::DIV, { "DIV", 0, 2, 1, false, LowTier } },
  170. { Instruction::SDIV, { "SDIV", 0, 2, 1, false, LowTier } },
  171. { Instruction::MOD, { "MOD", 0, 2, 1, false, LowTier } },
  172. { Instruction::SMOD, { "SMOD", 0, 2, 1, false, LowTier } },
  173. { Instruction::EXP, { "EXP", 0, 2, 1, false, SpecialTier } },
  174. { Instruction::NOT, { "NOT", 0, 1, 1, false, VeryLowTier } },
  175. { Instruction::LT, { "LT", 0, 2, 1, false, VeryLowTier } },
  176. { Instruction::GT, { "GT", 0, 2, 1, false, VeryLowTier } },
  177. { Instruction::SLT, { "SLT", 0, 2, 1, false, VeryLowTier } },
  178. { Instruction::SGT, { "SGT", 0, 2, 1, false, VeryLowTier } },
  179. { Instruction::EQ, { "EQ", 0, 2, 1, false, VeryLowTier } },
  180. { Instruction::ISZERO, { "ISZERO", 0, 1, 1, false, VeryLowTier } },
  181. { Instruction::AND, { "AND", 0, 2, 1, false, VeryLowTier } },
  182. { Instruction::OR, { "OR", 0, 2, 1, false, VeryLowTier } },
  183. { Instruction::XOR, { "XOR", 0, 2, 1, false, VeryLowTier } },
  184. { Instruction::BYTE, { "BYTE", 0, 2, 1, false, VeryLowTier } },
  185. { Instruction::ADDMOD, { "ADDMOD", 0, 3, 1, false, MidTier } },
  186. { Instruction::MULMOD, { "MULMOD", 0, 3, 1, false, MidTier } },
  187. { Instruction::SIGNEXTEND, { "SIGNEXTEND", 0, 2, 1, false, LowTier } },
  188. { Instruction::SHA3, { "SHA3", 0, 2, 1, false, SpecialTier } },
  189. { Instruction::ADDRESS, { "ADDRESS", 0, 0, 1, false, BaseTier } },
  190. { Instruction::BALANCE, { "BALANCE", 0, 1, 1, false, SpecialTier } },
  191. { Instruction::ORIGIN, { "ORIGIN", 0, 0, 1, false, BaseTier } },
  192. { Instruction::CALLER, { "CALLER", 0, 0, 1, false, BaseTier } },
  193. { Instruction::CALLVALUE, { "CALLVALUE", 0, 0, 1, false, BaseTier } },
  194. { Instruction::CALLDATALOAD,{ "CALLDATALOAD", 0, 1, 1, false, VeryLowTier } },
  195. { Instruction::CALLDATASIZE,{ "CALLDATASIZE", 0, 0, 1, false, BaseTier } },
  196. { Instruction::CALLDATACOPY,{ "CALLDATACOPY", 0, 3, 0, true, VeryLowTier } },
  197. { Instruction::CODESIZE, { "CODESIZE", 0, 0, 1, false, BaseTier } },
  198. { Instruction::CODECOPY, { "CODECOPY", 0, 3, 0, true, VeryLowTier } },
  199. { Instruction::GASPRICE, { "GASPRICE", 0, 0, 1, false, BaseTier } },
  200. { Instruction::EXTCODESIZE, { "EXTCODESIZE", 0, 1, 1, false, SpecialTier } },
  201. { Instruction::EXTCODECOPY, { "EXTCODECOPY", 0, 4, 0, true, SpecialTier } },
  202. { Instruction::BLOCKHASH, { "BLOCKHASH", 0, 1, 1, false, ExtTier } },
  203. { Instruction::COINBASE, { "COINBASE", 0, 0, 1, false, BaseTier } },
  204. { Instruction::TIMESTAMP, { "TIMESTAMP", 0, 0, 1, false, BaseTier } },
  205. { Instruction::NUMBER, { "NUMBER", 0, 0, 1, false, BaseTier } },
  206. { Instruction::DIFFICULTY, { "DIFFICULTY", 0, 0, 1, false, BaseTier } },
  207. { Instruction::GASLIMIT, { "GASLIMIT", 0, 0, 1, false, BaseTier } },
  208. { Instruction::POP, { "POP", 0, 1, 0, false, BaseTier } },
  209. { Instruction::MLOAD, { "MLOAD", 0, 1, 1, false, VeryLowTier } },
  210. { Instruction::MSTORE, { "MSTORE", 0, 2, 0, true, VeryLowTier } },
  211. { Instruction::MSTORE8, { "MSTORE8", 0, 2, 0, true, VeryLowTier } },
  212. { Instruction::SLOAD, { "SLOAD", 0, 1, 1, false, SpecialTier } },
  213. { Instruction::SSTORE, { "SSTORE", 0, 2, 0, true, SpecialTier } },
  214. { Instruction::JUMP, { "JUMP", 0, 1, 0, true, MidTier } },
  215. { Instruction::JUMPI, { "JUMPI", 0, 2, 0, true, HighTier } },
  216. { Instruction::PC, { "PC", 0, 0, 1, false, BaseTier } },
  217. { Instruction::MSIZE, { "MSIZE", 0, 0, 1, false, BaseTier } },
  218. { Instruction::GAS, { "GAS", 0, 0, 1, false, BaseTier } },
  219. { Instruction::JUMPDEST, { "JUMPDEST", 0, 0, 0, true, SpecialTier } },
  220. { Instruction::PUSH1, { "PUSH1", 1, 0, 1, false, VeryLowTier } },
  221. { Instruction::PUSH2, { "PUSH2", 2, 0, 1, false, VeryLowTier } },
  222. { Instruction::PUSH3, { "PUSH3", 3, 0, 1, false, VeryLowTier } },
  223. { Instruction::PUSH4, { "PUSH4", 4, 0, 1, false, VeryLowTier } },
  224. { Instruction::PUSH5, { "PUSH5", 5, 0, 1, false, VeryLowTier } },
  225. { Instruction::PUSH6, { "PUSH6", 6, 0, 1, false, VeryLowTier } },
  226. { Instruction::PUSH7, { "PUSH7", 7, 0, 1, false, VeryLowTier } },
  227. { Instruction::PUSH8, { "PUSH8", 8, 0, 1, false, VeryLowTier } },
  228. { Instruction::PUSH9, { "PUSH9", 9, 0, 1, false, VeryLowTier } },
  229. { Instruction::PUSH10, { "PUSH10", 10, 0, 1, false, VeryLowTier } },
  230. { Instruction::PUSH11, { "PUSH11", 11, 0, 1, false, VeryLowTier } },
  231. { Instruction::PUSH12, { "PUSH12", 12, 0, 1, false, VeryLowTier } },
  232. { Instruction::PUSH13, { "PUSH13", 13, 0, 1, false, VeryLowTier } },
  233. { Instruction::PUSH14, { "PUSH14", 14, 0, 1, false, VeryLowTier } },
  234. { Instruction::PUSH15, { "PUSH15", 15, 0, 1, false, VeryLowTier } },
  235. { Instruction::PUSH16, { "PUSH16", 16, 0, 1, false, VeryLowTier } },
  236. { Instruction::PUSH17, { "PUSH17", 17, 0, 1, false, VeryLowTier } },
  237. { Instruction::PUSH18, { "PUSH18", 18, 0, 1, false, VeryLowTier } },
  238. { Instruction::PUSH19, { "PUSH19", 19, 0, 1, false, VeryLowTier } },
  239. { Instruction::PUSH20, { "PUSH20", 20, 0, 1, false, VeryLowTier } },
  240. { Instruction::PUSH21, { "PUSH21", 21, 0, 1, false, VeryLowTier } },
  241. { Instruction::PUSH22, { "PUSH22", 22, 0, 1, false, VeryLowTier } },
  242. { Instruction::PUSH23, { "PUSH23", 23, 0, 1, false, VeryLowTier } },
  243. { Instruction::PUSH24, { "PUSH24", 24, 0, 1, false, VeryLowTier } },
  244. { Instruction::PUSH25, { "PUSH25", 25, 0, 1, false, VeryLowTier } },
  245. { Instruction::PUSH26, { "PUSH26", 26, 0, 1, false, VeryLowTier } },
  246. { Instruction::PUSH27, { "PUSH27", 27, 0, 1, false, VeryLowTier } },
  247. { Instruction::PUSH28, { "PUSH28", 28, 0, 1, false, VeryLowTier } },
  248. { Instruction::PUSH29, { "PUSH29", 29, 0, 1, false, VeryLowTier } },
  249. { Instruction::PUSH30, { "PUSH30", 30, 0, 1, false, VeryLowTier } },
  250. { Instruction::PUSH31, { "PUSH31", 31, 0, 1, false, VeryLowTier } },
  251. { Instruction::PUSH32, { "PUSH32", 32, 0, 1, false, VeryLowTier } },
  252. { Instruction::DUP1, { "DUP1", 0, 1, 2, false, VeryLowTier } },
  253. { Instruction::DUP2, { "DUP2", 0, 2, 3, false, VeryLowTier } },
  254. { Instruction::DUP3, { "DUP3", 0, 3, 4, false, VeryLowTier } },
  255. { Instruction::DUP4, { "DUP4", 0, 4, 5, false, VeryLowTier } },
  256. { Instruction::DUP5, { "DUP5", 0, 5, 6, false, VeryLowTier } },
  257. { Instruction::DUP6, { "DUP6", 0, 6, 7, false, VeryLowTier } },
  258. { Instruction::DUP7, { "DUP7", 0, 7, 8, false, VeryLowTier } },
  259. { Instruction::DUP8, { "DUP8", 0, 8, 9, false, VeryLowTier } },
  260. { Instruction::DUP9, { "DUP9", 0, 9, 10, false, VeryLowTier } },
  261. { Instruction::DUP10, { "DUP10", 0, 10, 11, false, VeryLowTier } },
  262. { Instruction::DUP11, { "DUP11", 0, 11, 12, false, VeryLowTier } },
  263. { Instruction::DUP12, { "DUP12", 0, 12, 13, false, VeryLowTier } },
  264. { Instruction::DUP13, { "DUP13", 0, 13, 14, false, VeryLowTier } },
  265. { Instruction::DUP14, { "DUP14", 0, 14, 15, false, VeryLowTier } },
  266. { Instruction::DUP15, { "DUP15", 0, 15, 16, false, VeryLowTier } },
  267. { Instruction::DUP16, { "DUP16", 0, 16, 17, false, VeryLowTier } },
  268. { Instruction::SWAP1, { "SWAP1", 0, 2, 2, false, VeryLowTier } },
  269. { Instruction::SWAP2, { "SWAP2", 0, 3, 3, false, VeryLowTier } },
  270. { Instruction::SWAP3, { "SWAP3", 0, 4, 4, false, VeryLowTier } },
  271. { Instruction::SWAP4, { "SWAP4", 0, 5, 5, false, VeryLowTier } },
  272. { Instruction::SWAP5, { "SWAP5", 0, 6, 6, false, VeryLowTier } },
  273. { Instruction::SWAP6, { "SWAP6", 0, 7, 7, false, VeryLowTier } },
  274. { Instruction::SWAP7, { "SWAP7", 0, 8, 8, false, VeryLowTier } },
  275. { Instruction::SWAP8, { "SWAP8", 0, 9, 9, false, VeryLowTier } },
  276. { Instruction::SWAP9, { "SWAP9", 0, 10, 10, false, VeryLowTier } },
  277. { Instruction::SWAP10, { "SWAP10", 0, 11, 11, false, VeryLowTier } },
  278. { Instruction::SWAP11, { "SWAP11", 0, 12, 12, false, VeryLowTier } },
  279. { Instruction::SWAP12, { "SWAP12", 0, 13, 13, false, VeryLowTier } },
  280. { Instruction::SWAP13, { "SWAP13", 0, 14, 14, false, VeryLowTier } },
  281. { Instruction::SWAP14, { "SWAP14", 0, 15, 15, false, VeryLowTier } },
  282. { Instruction::SWAP15, { "SWAP15", 0, 16, 16, false, VeryLowTier } },
  283. { Instruction::SWAP16, { "SWAP16", 0, 17, 17, false, VeryLowTier } },
  284. { Instruction::LOG0, { "LOG0", 0, 2, 0, true, SpecialTier } },
  285. { Instruction::LOG1, { "LOG1", 0, 3, 0, true, SpecialTier } },
  286. { Instruction::LOG2, { "LOG2", 0, 4, 0, true, SpecialTier } },
  287. { Instruction::LOG3, { "LOG3", 0, 5, 0, true, SpecialTier } },
  288. { Instruction::LOG4, { "LOG4", 0, 6, 0, true, SpecialTier } },
  289. { Instruction::CREATE, { "CREATE", 0, 3, 1, true, SpecialTier } },
  290. { Instruction::CALL, { "CALL", 0, 7, 1, true, SpecialTier } },
  291. { Instruction::CALLCODE, { "CALLCODE", 0, 7, 1, true, SpecialTier } },
  292. { Instruction::RETURN, { "RETURN", 0, 2, 0, true, ZeroTier } },
  293. { Instruction::DELEGATECALL,{ "DELEGATECALL", 0, 6, 1, true, SpecialTier } },
  294. { Instruction::SUICIDE, { "SUICIDE", 0, 1, 0, true, SpecialTier } },
  295. // these are generated by the interpreter - should never be in user code
  296. { Instruction::PUSHC, { "PUSHC", 2, 0, 1, false, VeryLowTier } },
  297. { Instruction::JUMPV, { "JUMPV", 0, 1, 0, true, MidTier } },
  298. { Instruction::JUMPVI, { "JUMPVI", 0, 1, 0, true, HighTier } },
  299. { Instruction::STOP, { "BAD", 0, 0, 0, true, ZeroTier } },
  300. };
  301. void dev::eth::eachInstruction(
  302. bytes const& _mem,
  303. function<void(Instruction,u256 const&)> const& _onInstruction
  304. )
  305. {
  306. for (auto it = _mem.begin(); it < _mem.end(); ++it)
  307. {
  308. Instruction instr = Instruction(*it);
  309. size_t additional = 0;
  310. if (isValidInstruction(instr))
  311. additional = instructionInfo(instr).additional;
  312. u256 data;
  313. for (size_t i = 0; i < additional; ++i)
  314. {
  315. data <<= 8;
  316. if (++it < _mem.end())
  317. data |= *it;
  318. }
  319. _onInstruction(instr, data);
  320. }
  321. }
  322. string dev::eth::disassemble(bytes const& _mem)
  323. {
  324. stringstream ret;
  325. eachInstruction(_mem, [&](Instruction _instr, u256 const& _data) {
  326. if (!isValidInstruction(_instr))
  327. ret << "0x" << hex << int(_instr) << " ";
  328. else
  329. {
  330. InstructionInfo info = instructionInfo(_instr);
  331. ret << info.name << " ";
  332. if (info.additional)
  333. ret << "0x" << hex << _data << " ";
  334. }
  335. });
  336. return ret.str();
  337. }
  338. InstructionInfo dev::eth::instructionInfo(Instruction _inst)
  339. {
  340. try
  341. {
  342. return c_instructionInfo.at(_inst);
  343. }
  344. catch (...)
  345. {
  346. return InstructionInfo({"<INVALID_INSTRUCTION: " + toString((unsigned)_inst) + ">", 0, 0, 0, false, InvalidTier});
  347. }
  348. }
  349. bool dev::eth::isValidInstruction(Instruction _inst)
  350. {
  351. return !!c_instructionInfo.count(_inst);
  352. }