diff options
Diffstat (limited to 'libsolidity/ast/AST.cpp')
-rw-r--r-- | libsolidity/ast/AST.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/libsolidity/ast/AST.cpp b/libsolidity/ast/AST.cpp index c5fb35f6..a126e6ed 100644 --- a/libsolidity/ast/AST.cpp +++ b/libsolidity/ast/AST.cpp @@ -84,12 +84,17 @@ SourceUnitAnnotation& SourceUnit::annotation() const return dynamic_cast<SourceUnitAnnotation&>(*m_annotation); } -vector<SourceUnit const*> SourceUnit::referencedSourceUnits() const +set<SourceUnit const*> SourceUnit::referencedSourceUnits(bool _recurse) const { - vector<SourceUnit const*> sourceUnits; + set<SourceUnit const*> sourceUnits; for (ImportDirective const* importDirective: filteredNodes<ImportDirective>(nodes())) { - sourceUnits.push_back(importDirective->annotation().sourceUnit); + sourceUnits.insert(importDirective->annotation().sourceUnit); + if (_recurse) + { + set<SourceUnit const*> referencedSourceUnits = importDirective->annotation().sourceUnit->referencedSourceUnits(true); + sourceUnits.insert(referencedSourceUnits.begin(), referencedSourceUnits.end()); + } } return sourceUnits; } |