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.cpp | |
parent | 5437457f46cb3a06f149af154f66334350ec439b (diff) | |
download | dexon-solidity-3c8b777b9b7e438e16a3cb60dece5af3753fc8d4.tar.gz dexon-solidity-3c8b777b9b7e438e16a3cb60dece5af3753fc8d4.tar.zst dexon-solidity-3c8b777b9b7e438e16a3cb60dece5af3753fc8d4.zip |
References counter.
Diffstat (limited to 'libjulia/optimiser/NameCollector.cpp')
-rw-r--r-- | libjulia/optimiser/NameCollector.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/libjulia/optimiser/NameCollector.cpp b/libjulia/optimiser/NameCollector.cpp index 7b4c4793..f94104b7 100644 --- a/libjulia/optimiser/NameCollector.cpp +++ b/libjulia/optimiser/NameCollector.cpp @@ -42,3 +42,28 @@ void NameCollector::operator ()(FunctionDefinition const& _funDef) m_names.insert(ret.name); ASTWalker::operator ()(_funDef); } + +void ReferencesCounter::operator()(Identifier const& _identifier) +{ + ++m_references[_identifier.name]; +} + +void ReferencesCounter::operator()(FunctionCall const& _funCall) +{ + ++m_references[_funCall.functionName.name]; + ASTWalker::operator()(_funCall); +} + +map<string, size_t> ReferencesCounter::countReferences(Block const& _block) +{ + ReferencesCounter counter; + counter(_block); + return counter.references(); +} + +map<string, size_t> ReferencesCounter::countReferences(Expression const& _expression) +{ + ReferencesCounter counter; + counter.visit(_expression); + return counter.references(); +} |