From 7c61a6daf2052afaba86ad52623028cc8e14572b Mon Sep 17 00:00:00 2001 From: chriseth Date: Thu, 31 Aug 2017 13:13:05 +0200 Subject: Add view/pure information about instructions. --- libevmasm/SemanticInformation.cpp | 52 +++++++++++++++++++++++++++++++++++++++ libevmasm/SemanticInformation.h | 2 ++ 2 files changed, 54 insertions(+) (limited to 'libevmasm') 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); }; } -- cgit From d6861d909c7dabb6993cfa7a8269f76c613428f7 Mon Sep 17 00:00:00 2001 From: chriseth Date: Thu, 31 Aug 2017 13:13:35 +0200 Subject: Analyze assembly. --- libevmasm/SemanticInformation.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'libevmasm') diff --git a/libevmasm/SemanticInformation.cpp b/libevmasm/SemanticInformation.cpp index abe47e10..ceb3fbdd 100644 --- a/libevmasm/SemanticInformation.cpp +++ b/libevmasm/SemanticInformation.cpp @@ -207,6 +207,7 @@ bool SemanticInformation::invalidInPureFunctions(Instruction _instruction) case Instruction::NUMBER: case Instruction::DIFFICULTY: case Instruction::GASLIMIT: + case Instruction::STATICCALL: case Instruction::SLOAD: return true; default: -- cgit From 15bdc48a73d1cbebb9f75830fd1abbd29f798c12 Mon Sep 17 00:00:00 2001 From: chriseth Date: Fri, 1 Sep 2017 19:58:38 +0200 Subject: Rename and add anonymous namespace. --- libevmasm/SemanticInformation.cpp | 2 +- libevmasm/SemanticInformation.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'libevmasm') diff --git a/libevmasm/SemanticInformation.cpp b/libevmasm/SemanticInformation.cpp index ceb3fbdd..e277a08d 100644 --- a/libevmasm/SemanticInformation.cpp +++ b/libevmasm/SemanticInformation.cpp @@ -189,7 +189,7 @@ bool SemanticInformation::invalidatesStorage(Instruction _instruction) } } -bool SemanticInformation::invalidInPureFunctions(Instruction _instruction) +bool SemanticInformation::readsFromState(Instruction _instruction) { switch (_instruction) { diff --git a/libevmasm/SemanticInformation.h b/libevmasm/SemanticInformation.h index e5ea7c18..963088d9 100644 --- a/libevmasm/SemanticInformation.h +++ b/libevmasm/SemanticInformation.h @@ -53,7 +53,7 @@ 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 readsFromState(solidity::Instruction _instruction); static bool invalidInViewFunctions(solidity::Instruction _instruction); }; -- cgit From 66c01301fe5cb71a2bf66af2f7170043f088815c Mon Sep 17 00:00:00 2001 From: chriseth Date: Wed, 13 Sep 2017 17:18:22 +0200 Subject: Rename to invalidInPureFunctions --- libevmasm/SemanticInformation.cpp | 2 +- libevmasm/SemanticInformation.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'libevmasm') diff --git a/libevmasm/SemanticInformation.cpp b/libevmasm/SemanticInformation.cpp index e277a08d..ceb3fbdd 100644 --- a/libevmasm/SemanticInformation.cpp +++ b/libevmasm/SemanticInformation.cpp @@ -189,7 +189,7 @@ bool SemanticInformation::invalidatesStorage(Instruction _instruction) } } -bool SemanticInformation::readsFromState(Instruction _instruction) +bool SemanticInformation::invalidInPureFunctions(Instruction _instruction) { switch (_instruction) { diff --git a/libevmasm/SemanticInformation.h b/libevmasm/SemanticInformation.h index 963088d9..e5ea7c18 100644 --- a/libevmasm/SemanticInformation.h +++ b/libevmasm/SemanticInformation.h @@ -53,7 +53,7 @@ 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 readsFromState(solidity::Instruction _instruction); + static bool invalidInPureFunctions(solidity::Instruction _instruction); static bool invalidInViewFunctions(solidity::Instruction _instruction); }; -- cgit