Refactor data flow analyzer state access.

This commit is contained in:
chriseth
2022-03-14 19:32:33 +01:00
parent e154d43176
commit eab4ca906c
14 changed files with 81 additions and 48 deletions
+9
View File
@@ -29,6 +29,7 @@
#include <libyul/AST.h> // Needed for m_zero below.
#include <libyul/SideEffects.h>
#include <libsolutil/Numeric.h>
#include <libsolutil/Common.h>
#include <map>
@@ -38,6 +39,7 @@ namespace solidity::yul
{
struct Dialect;
struct SideEffects;
class KnowledgeBase;
/// Value assigned to a variable.
struct AssignedValue
@@ -98,6 +100,13 @@ public:
void operator()(ForLoop&) override;
void operator()(Block& _block) override;
/// @returns the current value of the given variable, if known - always movable.
AssignedValue const* variableValue(YulString _variable) const { return util::valueOrNullptr(m_value, _variable); }
std::set<YulString> const* references(YulString _variable) const { return util::valueOrNullptr(m_references, _variable); }
std::map<YulString, AssignedValue> const& allValues() const { return m_value; }
std::optional<YulString> storageValue(YulString _key) const;
std::optional<YulString> memoryValue(YulString _key) const;
protected:
/// Registers the assignment.
void handleAssignment(std::set<YulString> const& _names, Expression* _value, bool _isDeclaration);