diff options
author | chriseth <chris@ethereum.org> | 2017-08-31 19:13:05 +0800 |
---|---|---|
committer | chriseth <chris@ethereum.org> | 2017-09-06 19:52:29 +0800 |
commit | 7c61a6daf2052afaba86ad52623028cc8e14572b (patch) | |
tree | 6c0ce07510043d242e9f5136db74091ed931e9d2 | |
parent | 41d0ad7a9c3b3a3ee26db0be9392b941b0803530 (diff) | |
download | dexon-solidity-7c61a6daf2052afaba86ad52623028cc8e14572b.tar dexon-solidity-7c61a6daf2052afaba86ad52623028cc8e14572b.tar.gz dexon-solidity-7c61a6daf2052afaba86ad52623028cc8e14572b.tar.bz2 dexon-solidity-7c61a6daf2052afaba86ad52623028cc8e14572b.tar.lz dexon-solidity-7c61a6daf2052afaba86ad52623028cc8e14572b.tar.xz dexon-solidity-7c61a6daf2052afaba86ad52623028cc8e14572b.tar.zst dexon-solidity-7c61a6daf2052afaba86ad52623028cc8e14572b.zip |
Add view/pure information about instructions.
-rw-r--r-- | libevmasm/SemanticInformation.cpp | 52 | ||||
-rw-r--r-- | libevmasm/SemanticInformation.h | 2 |
2 files changed, 54 insertions, 0 deletions
diff --git a/libevmasm/SemanticInformation.cpp b/libevmasm/SemanticInformation.cpp index f63f0c61..abe47e10 100644 --- a/libevmasm/SemanticInformation.cpp +++ b/libevmasm/SemanticInformation.cpp @@ -188,3 +188,55 @@ bool SemanticInformation::invalidatesStorage(Instruction _instruction) return false; } } + +bool SemanticInformation::invalidInPureFunctions(Instruction _instruction) +{ + switch (_instruction) + { + case Instruction::ADDRESS: + case Instruction::BALANCE: + case Instruction::ORIGIN: + case Instruction::CALLER: + case Instruction::CALLVALUE: + case Instruction::GASPRICE: + case Instruction::EXTCODESIZE: + case Instruction::EXTCODECOPY: + case Instruction::BLOCKHASH: + case Instruction::COINBASE: + case Instruction::TIMESTAMP: + case Instruction::NUMBER: + case Instruction::DIFFICULTY: + case Instruction::GASLIMIT: + case Instruction::SLOAD: + return true; + default: + break; + } + return invalidInViewFunctions(_instruction); +} + +bool SemanticInformation::invalidInViewFunctions(Instruction _instruction) +{ + switch (_instruction) + { + case Instruction::SSTORE: + case Instruction::JUMP: + case Instruction::JUMPI: + case Instruction::GAS: + case Instruction::LOG0: + case Instruction::LOG1: + case Instruction::LOG2: + case Instruction::LOG3: + case Instruction::LOG4: + case Instruction::CREATE: + case Instruction::CALL: + case Instruction::CALLCODE: + case Instruction::DELEGATECALL: + case Instruction::CREATE2: + case Instruction::SELFDESTRUCT: + return true; + default: + break; + } + return false; +} diff --git a/libevmasm/SemanticInformation.h b/libevmasm/SemanticInformation.h index 5b02061f..e5ea7c18 100644 --- a/libevmasm/SemanticInformation.h +++ b/libevmasm/SemanticInformation.h @@ -53,6 +53,8 @@ struct SemanticInformation static bool invalidatesMemory(solidity::Instruction _instruction); /// @returns true if the given instruction modifies storage (even indirectly). static bool invalidatesStorage(solidity::Instruction _instruction); + static bool invalidInPureFunctions(solidity::Instruction _instruction); + static bool invalidInViewFunctions(solidity::Instruction _instruction); }; } |