mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Avoid cyclic imports in referencedSourceUnits
This commit is contained in:
parent
c617336587
commit
89a1e97e7d
@ -84,16 +84,21 @@ SourceUnitAnnotation& SourceUnit::annotation() const
|
||||
return dynamic_cast<SourceUnitAnnotation&>(*m_annotation);
|
||||
}
|
||||
|
||||
set<SourceUnit const*> SourceUnit::referencedSourceUnits(bool _recurse) const
|
||||
set<SourceUnit const*> SourceUnit::referencedSourceUnits(bool _recurse, set<SourceUnit const*> _skipList) const
|
||||
{
|
||||
set<SourceUnit const*> sourceUnits;
|
||||
for (ImportDirective const* importDirective: filteredNodes<ImportDirective>(nodes()))
|
||||
{
|
||||
sourceUnits.insert(importDirective->annotation().sourceUnit);
|
||||
if (_recurse)
|
||||
auto const& sourceUnit = importDirective->annotation().sourceUnit;
|
||||
if (!_skipList.count(sourceUnit))
|
||||
{
|
||||
set<SourceUnit const*> referencedSourceUnits = importDirective->annotation().sourceUnit->referencedSourceUnits(true);
|
||||
sourceUnits.insert(referencedSourceUnits.begin(), referencedSourceUnits.end());
|
||||
_skipList.insert(sourceUnit);
|
||||
sourceUnits.insert(sourceUnit);
|
||||
if (_recurse)
|
||||
{
|
||||
set<SourceUnit const*> referencedSourceUnits = sourceUnit->referencedSourceUnits(true, _skipList);
|
||||
sourceUnits.insert(referencedSourceUnits.begin(), referencedSourceUnits.end());
|
||||
}
|
||||
}
|
||||
}
|
||||
return sourceUnits;
|
||||
|
@ -137,7 +137,7 @@ public:
|
||||
std::vector<ASTPointer<ASTNode>> nodes() const { return m_nodes; }
|
||||
|
||||
/// @returns a set of referenced SourceUnits. Recursively if @a _recurse is true.
|
||||
std::set<SourceUnit const*> referencedSourceUnits(bool _recurse = false) const;
|
||||
std::set<SourceUnit const*> referencedSourceUnits(bool _recurse = false, std::set<SourceUnit const*> _skipList = std::set<SourceUnit const*>()) const;
|
||||
|
||||
private:
|
||||
std::vector<ASTPointer<ASTNode>> m_nodes;
|
||||
|
Loading…
Reference in New Issue
Block a user