aboutsummaryrefslogtreecommitdiffstats
path: root/libevmasm
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2017-09-14 00:29:13 +0800
committerGitHub <noreply@github.com>2017-09-14 00:29:13 +0800
commit3f3bcc4f8a0d12e9b92d6b63e7cfd92cbbfa775d (patch)
tree5a8f36e2b2491e07534d9c1570b8f40a2235c4c5 /libevmasm
parent72b7e001aa837ab59b3b14bfbabf69bbd102ded1 (diff)
parent172704a58fa2b7562107b8df299c5a81ba702d12 (diff)
downloaddexon-solidity-3f3bcc4f8a0d12e9b92d6b63e7cfd92cbbfa775d.tar.gz
dexon-solidity-3f3bcc4f8a0d12e9b92d6b63e7cfd92cbbfa775d.tar.zst
dexon-solidity-3f3bcc4f8a0d12e9b92d6b63e7cfd92cbbfa775d.zip
Merge pull request #2848 from ethereum/checkViewPure
Enforce view and pure.
Diffstat (limited to 'libevmasm')
-rw-r--r--libevmasm/SemanticInformation.cpp53
-rw-r--r--libevmasm/SemanticInformation.h2
2 files changed, 55 insertions, 0 deletions
diff --git a/libevmasm/SemanticInformation.cpp b/libevmasm/SemanticInformation.cpp
index f63f0c61..ceb3fbdd 100644
--- a/libevmasm/SemanticInformation.cpp
+++ b/libevmasm/SemanticInformation.cpp
@@ -188,3 +188,56 @@ 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::STATICCALL:
+ 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);
};
}