diff options
author | Alex Beregszaszi <alex@rtfs.hu> | 2017-07-13 07:08:28 +0800 |
---|---|---|
committer | Alex Beregszaszi <alex@rtfs.hu> | 2017-07-19 21:56:40 +0800 |
commit | a9bddf71aaca7fb6e00292b788479a465b867faf (patch) | |
tree | e58d74cbd3e88337c169026ceceb123c08fc076b /libsolidity | |
parent | 1b0ef0b785d195ca28aa756047da040b676f5fc9 (diff) | |
download | dexon-solidity-a9bddf71aaca7fb6e00292b788479a465b867faf.tar dexon-solidity-a9bddf71aaca7fb6e00292b788479a465b867faf.tar.gz dexon-solidity-a9bddf71aaca7fb6e00292b788479a465b867faf.tar.bz2 dexon-solidity-a9bddf71aaca7fb6e00292b788479a465b867faf.tar.lz dexon-solidity-a9bddf71aaca7fb6e00292b788479a465b867faf.tar.xz dexon-solidity-a9bddf71aaca7fb6e00292b788479a465b867faf.tar.zst dexon-solidity-a9bddf71aaca7fb6e00292b788479a465b867faf.zip |
Add referencedSourceUnits() helper
Diffstat (limited to 'libsolidity')
-rw-r--r-- | libsolidity/ast/AST.cpp | 10 | ||||
-rw-r--r-- | libsolidity/ast/AST.h | 3 |
2 files changed, 13 insertions, 0 deletions
diff --git a/libsolidity/ast/AST.cpp b/libsolidity/ast/AST.cpp index 1e1e4839..c5fb35f6 100644 --- a/libsolidity/ast/AST.cpp +++ b/libsolidity/ast/AST.cpp @@ -84,6 +84,16 @@ SourceUnitAnnotation& SourceUnit::annotation() const return dynamic_cast<SourceUnitAnnotation&>(*m_annotation); } +vector<SourceUnit const*> SourceUnit::referencedSourceUnits() const +{ + vector<SourceUnit const*> sourceUnits; + for (ImportDirective const* importDirective: filteredNodes<ImportDirective>(nodes())) + { + sourceUnits.push_back(importDirective->annotation().sourceUnit); + } + return sourceUnits; +} + SourceUnit const& Declaration::sourceUnit() const { solAssert(!!m_scope, ""); diff --git a/libsolidity/ast/AST.h b/libsolidity/ast/AST.h index 41785780..e2117613 100644 --- a/libsolidity/ast/AST.h +++ b/libsolidity/ast/AST.h @@ -136,6 +136,9 @@ public: std::vector<ASTPointer<ASTNode>> nodes() const { return m_nodes; } + /// @returns a vector of referenced SourceUnits. + std::vector<SourceUnit const*> referencedSourceUnits() const; + private: std::vector<ASTPointer<ASTNode>> m_nodes; }; |