mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Add sourceUnit() helper to Declaration
This commit is contained in:
parent
84f8e7a467
commit
1b0ef0b785
@ -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
|
||||
|
@ -168,6 +168,9 @@ public:
|
||||
ASTNode const* scope() const { return m_scope; }
|
||||
void setScope(ASTNode const* _scope) { m_scope = _scope; }
|
||||
|
||||
/// @returns the source unit this declaration is present in.
|
||||
SourceUnit const& sourceUnit() const;
|
||||
|
||||
/// @returns the source name this declaration is present in.
|
||||
/// Can be combined with annotation().canonicalName to form a globally unique name.
|
||||
std::string sourceUnitName() const;
|
||||
|
Loading…
Reference in New Issue
Block a user