Add sourceUnit() helper to Declaration

This commit is contained in:
Alex Beregszaszi committed 2017-07-19 14:56:40 +01:00
1 parent 84f8e7a467
commit 1b0ef0b785
2 files changed
+10 -2

No files matched your search

+7 -2
View File
@@ -84,13 +84,18 @@ SourceUnitAnnotation& SourceUnit::annotation() const
return dynamic_cast<SourceUnitAnnotation&>(*m_annotation);
}
string Declaration::sourceUnitName() const
SourceUnit const& Declaration::sourceUnit() const
{
solAssert(!!m_scope, "");
ASTNode const* scope = m_scope;
while (dynamic_cast<Declaration const*>(scope) && dynamic_cast<Declaration const*>(scope)->m_scope)
scope = dynamic_cast<Declaration const*>(scope)->m_scope;
return dynamic_cast<SourceUnit const&>(*scope).annotation().path;
return dynamic_cast<SourceUnit const&>(*scope);
}
string Declaration::sourceUnitName() const
{
return sourceUnit().annotation().path;
}
ImportAnnotation& ImportDirective::annotation() const