aboutsummaryrefslogtreecommitdiffstats
path: root/SemanticInformation.cpp
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2015-04-30 21:31:16 +0800
committerchriseth <c@ethdev.com>2015-05-06 17:11:16 +0800
commita2e3bcbd0c45a79a9709dc8a69858765ab904805 (patch)
tree1201a25150145a991ef11c5f62465986c6b27dea /SemanticInformation.cpp
parent867101e40981db56d8b72fd363e4f9e376991284 (diff)
downloaddexon-solidity-a2e3bcbd0c45a79a9709dc8a69858765ab904805.tar
dexon-solidity-a2e3bcbd0c45a79a9709dc8a69858765ab904805.tar.gz
dexon-solidity-a2e3bcbd0c45a79a9709dc8a69858765ab904805.tar.bz2
dexon-solidity-a2e3bcbd0c45a79a9709dc8a69858765ab904805.tar.lz
dexon-solidity-a2e3bcbd0c45a79a9709dc8a69858765ab904805.tar.xz
dexon-solidity-a2e3bcbd0c45a79a9709dc8a69858765ab904805.tar.zst
dexon-solidity-a2e3bcbd0c45a79a9709dc8a69858765ab904805.zip
Make KnownState work with all instructions.
Diffstat (limited to 'SemanticInformation.cpp')
-rw-r--r--SemanticInformation.cpp54
1 files changed, 54 insertions, 0 deletions
diff --git a/SemanticInformation.cpp b/SemanticInformation.cpp
index 83d59efc..40c36f9e 100644
--- a/SemanticInformation.cpp
+++ b/SemanticInformation.cpp
@@ -122,3 +122,57 @@ bool SemanticInformation::altersControlFlow(AssemblyItem const& _item)
return false;
}
}
+
+
+bool SemanticInformation::isDeterministic(AssemblyItem const& _item)
+{
+ if (_item.type() != Operation)
+ return true;
+ assertThrow(!altersControlFlow(_item), OptimizerException, "");
+
+ switch (_item.instruction())
+ {
+ case Instruction::CALL:
+ case Instruction::CALLCODE:
+ case Instruction::CREATE:
+ case Instruction::GAS:
+ case Instruction::PC:
+ case Instruction::MSIZE: // depends on previous writes and reads, not only on content
+ case Instruction::BALANCE: // depends on previous calls
+ case Instruction::EXTCODESIZE:
+ return false;
+ default:
+ return true;
+ }
+}
+
+bool SemanticInformation::invalidatesMemory(Instruction _instruction)
+{
+ switch (_instruction)
+ {
+ case Instruction::CALLDATACOPY:
+ case Instruction::CODECOPY:
+ case Instruction::EXTCODECOPY:
+ case Instruction::MSTORE:
+ case Instruction::MSTORE8:
+ case Instruction::CALL:
+ case Instruction::CALLCODE:
+ return true;
+ default:
+ return false;
+ }
+}
+
+bool SemanticInformation::invalidatesStorage(Instruction _instruction)
+{
+ switch (_instruction)
+ {
+ case Instruction::CALL:
+ case Instruction::CALLCODE:
+ case Instruction::CREATE:
+ case Instruction::SSTORE:
+ return true;
+ default:
+ return false;
+ }
+}