diff options
author | chriseth <chris@ethereum.org> | 2017-12-20 20:47:51 +0800 |
---|---|---|
committer | Alex Beregszaszi <alex@rtfs.hu> | 2018-02-06 00:43:39 +0800 |
commit | 3c8b777b9b7e438e16a3cb60dece5af3753fc8d4 (patch) | |
tree | 653a5ea1568b5aebed2afa1ff4bb483732519651 /libjulia/optimiser/NameCollector.h | |
parent | 5437457f46cb3a06f149af154f66334350ec439b (diff) | |
download | dexon-solidity-3c8b777b9b7e438e16a3cb60dece5af3753fc8d4.tar dexon-solidity-3c8b777b9b7e438e16a3cb60dece5af3753fc8d4.tar.gz dexon-solidity-3c8b777b9b7e438e16a3cb60dece5af3753fc8d4.tar.bz2 dexon-solidity-3c8b777b9b7e438e16a3cb60dece5af3753fc8d4.tar.lz dexon-solidity-3c8b777b9b7e438e16a3cb60dece5af3753fc8d4.tar.xz dexon-solidity-3c8b777b9b7e438e16a3cb60dece5af3753fc8d4.tar.zst dexon-solidity-3c8b777b9b7e438e16a3cb60dece5af3753fc8d4.zip |
References counter.
Diffstat (limited to 'libjulia/optimiser/NameCollector.h')
-rw-r--r-- | libjulia/optimiser/NameCollector.h | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/libjulia/optimiser/NameCollector.h b/libjulia/optimiser/NameCollector.h index b7e38f46..7fe386f7 100644 --- a/libjulia/optimiser/NameCollector.h +++ b/libjulia/optimiser/NameCollector.h @@ -15,7 +15,7 @@ along with solidity. If not, see <http://www.gnu.org/licenses/>. */ /** - * Specific AST walker that collects all defined names. + * Specific AST walkers that collect facts about identifiers and definitions. */ #pragma once @@ -48,5 +48,23 @@ private: std::map<std::string, FunctionDefinition const*> m_functions; }; +/** + * Specific AST walker that counts all references to all declarations. + */ +class ReferencesCounter: public ASTWalker +{ +public: + using ASTWalker::operator (); + virtual void operator()(Identifier const& _identifier); + virtual void operator()(FunctionCall const& _funCall); + + static std::map<std::string, size_t> countReferences(Block const& _block); + static std::map<std::string, size_t> countReferences(Expression const& _expression); + + std::map<std::string, size_t> const& references() const { return m_references; } +private: + std::map<std::string, size_t> m_references; +}; + } } |