diff options
-rw-r--r-- | ExpressionClasses.cpp | 27 | ||||
-rw-r--r-- | ExpressionClasses.h | 5 |
2 files changed, 29 insertions, 3 deletions
diff --git a/ExpressionClasses.cpp b/ExpressionClasses.cpp index 81adc0db..81ba1154 100644 --- a/ExpressionClasses.cpp +++ b/ExpressionClasses.cpp @@ -57,11 +57,11 @@ ExpressionClasses::Id ExpressionClasses::find( exp.arguments = _arguments; exp.sequenceNumber = _sequenceNumber; + if (SemanticInformation::isCommutativeOperation(_item)) + sort(exp.arguments.begin(), exp.arguments.end()); + if (SemanticInformation::isDeterministic(_item)) { - if (SemanticInformation::isCommutativeOperation(_item)) - sort(exp.arguments.begin(), exp.arguments.end()); - auto it = m_expressions.find(exp); if (it != m_expressions.end()) return it->id; @@ -82,6 +82,27 @@ ExpressionClasses::Id ExpressionClasses::find( return exp.id; } +void ExpressionClasses::forceEqual( + ExpressionClasses::Id _id, + AssemblyItem const& _item, + ExpressionClasses::Ids const& _arguments, + bool _copyItem +) +{ + Expression exp; + exp.id = _id; + exp.item = &_item; + exp.arguments = _arguments; + + if (SemanticInformation::isCommutativeOperation(_item)) + sort(exp.arguments.begin(), exp.arguments.end()); + + if (_copyItem) + exp.item = storeItem(_item); + + m_expressions.insert(exp); +} + ExpressionClasses::Id ExpressionClasses::newClass(SourceLocation const& _location) { Expression exp; diff --git a/ExpressionClasses.h b/ExpressionClasses.h index dd94092e..4bfd7d24 100644 --- a/ExpressionClasses.h +++ b/ExpressionClasses.h @@ -74,6 +74,11 @@ public: /// @returns the number of classes. Id size() const { return m_representatives.size(); } + /// Forces the given @a _item with @a _arguments to the class @a _id. This can be used to + /// add prior knowledge e.g. about CALLDATA, but has to be used with caution. Will not work as + /// expected if @a _item applied to @a _arguments already exists. + void forceEqual(Id _id, AssemblyItem const& _item, Ids const& _arguments, bool _copyItem = true); + /// @returns the id of a new class which is different to all other classes. Id newClass(SourceLocation const& _location); |