aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/ast
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2016-11-14 18:46:43 +0800
committerchriseth <c@ethdev.com>2016-12-01 23:03:59 +0800
commit5789eaa78d0e00f6289101e02f7de5e9decdc7e5 (patch)
tree8964f493235d310baa50806fdff65138054d2439 /libsolidity/ast
parent55a719a79c1ab5b78ea6e1bcb4f27a888494a538 (diff)
downloaddexon-solidity-5789eaa78d0e00f6289101e02f7de5e9decdc7e5.tar.gz
dexon-solidity-5789eaa78d0e00f6289101e02f7de5e9decdc7e5.tar.zst
dexon-solidity-5789eaa78d0e00f6289101e02f7de5e9decdc7e5.zip
Metadata stamp.
Diffstat (limited to 'libsolidity/ast')
-rw-r--r--libsolidity/ast/AST.cpp8
-rw-r--r--libsolidity/ast/AST.h4
2 files changed, 12 insertions, 0 deletions
diff --git a/libsolidity/ast/AST.cpp b/libsolidity/ast/AST.cpp
index 9b478393..f8eb7108 100644
--- a/libsolidity/ast/AST.cpp
+++ b/libsolidity/ast/AST.cpp
@@ -63,6 +63,14 @@ SourceUnitAnnotation& SourceUnit::annotation() const
return static_cast<SourceUnitAnnotation&>(*m_annotation);
}
+string Declaration::sourceUnitName() const
+{
+ 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;
+}
+
ImportAnnotation& ImportDirective::annotation() const
{
if (!m_annotation)
diff --git a/libsolidity/ast/AST.h b/libsolidity/ast/AST.h
index 89b96f09..ab4be1ea 100644
--- a/libsolidity/ast/AST.h
+++ b/libsolidity/ast/AST.h
@@ -158,6 +158,10 @@ public:
ASTNode const* scope() const { return m_scope; }
void setScope(ASTNode const* _scope) { m_scope = _scope; }
+ /// @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;
+
virtual bool isLValue() const { return false; }
virtual bool isPartOfExternalInterface() const { return false; }