Evaluate keccak(a, const) if value at memory location a is known

Here the value of constant can be at most 32.
This commit is contained in:
hrkrshnn
2021-04-22 18:19:47 +02:00
parent 011f8d3ff7
commit 3bc4f5708a
4 changed files with 103 additions and 4 deletions
+9 -1
View File
@@ -27,6 +27,7 @@
#include <libyul/AST.h>
#include <libyul/Dialect.h>
#include <libyul/Exceptions.h>
#include <libyul/Utilities.h>
#include <libsolutil/CommonData.h>
#include <libsolutil/cxx20.h>
@@ -388,6 +389,14 @@ bool DataFlowAnalyzer::inScope(YulString _variableName) const
return false;
}
optional<u256> DataFlowAnalyzer::valueOfIdentifier(YulString const& _name)
{
if (m_value.count(_name))
if (Literal const* literal = get_if<Literal>(m_value.at(_name).value))
return valueOfLiteral(*literal);
return nullopt;
}
std::optional<pair<YulString, YulString>> DataFlowAnalyzer::isSimpleStore(
StoreLoadLocation _location,
ExpressionStatement const& _statement
@@ -412,4 +421,3 @@ std::optional<YulString> DataFlowAnalyzer::isSimpleLoad(
return key->name;
return {};
}