diff options
author | chriseth <c@ethdev.com> | 2015-05-22 16:48:54 +0800 |
---|---|---|
committer | chriseth <c@ethdev.com> | 2015-05-22 22:12:40 +0800 |
commit | 2414a23168e9abb5c343a7f3a93e4d0e247c12ac (patch) | |
tree | ec622458af8b01d63f3692bfabdcee125fe6b926 | |
parent | cd28fb8faa6009a53e1f127fb934d00f29da832d (diff) | |
download | dexon-solidity-2414a23168e9abb5c343a7f3a93e4d0e247c12ac.tar dexon-solidity-2414a23168e9abb5c343a7f3a93e4d0e247c12ac.tar.gz dexon-solidity-2414a23168e9abb5c343a7f3a93e4d0e247c12ac.tar.bz2 dexon-solidity-2414a23168e9abb5c343a7f3a93e4d0e247c12ac.tar.lz dexon-solidity-2414a23168e9abb5c343a7f3a93e4d0e247c12ac.tar.xz dexon-solidity-2414a23168e9abb5c343a7f3a93e4d0e247c12ac.tar.zst dexon-solidity-2414a23168e9abb5c343a7f3a93e4d0e247c12ac.zip |
Functional gas estimator.
-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); |