diff options
author | chriseth <chris@ethereum.org> | 2018-02-09 23:53:25 +0800 |
---|---|---|
committer | chriseth <chris@ethereum.org> | 2018-02-27 19:17:25 +0800 |
commit | 5f20129e65f5b8b714189145d177067152a21ac1 (patch) | |
tree | 26c56df153f67bc2bf0f370216a81b314ec4987f /libsolidity/ast/AST.h | |
parent | 53289e15a2e1ea540a0c3abe28219c326a614fe5 (diff) | |
download | dexon-solidity-5f20129e65f5b8b714189145d177067152a21ac1.tar dexon-solidity-5f20129e65f5b8b714189145d177067152a21ac1.tar.gz dexon-solidity-5f20129e65f5b8b714189145d177067152a21ac1.tar.bz2 dexon-solidity-5f20129e65f5b8b714189145d177067152a21ac1.tar.lz dexon-solidity-5f20129e65f5b8b714189145d177067152a21ac1.tar.xz dexon-solidity-5f20129e65f5b8b714189145d177067152a21ac1.tar.zst dexon-solidity-5f20129e65f5b8b714189145d177067152a21ac1.zip |
Scopes do not have to be declarations.
Diffstat (limited to 'libsolidity/ast/AST.h')
-rw-r--r-- | libsolidity/ast/AST.h | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/libsolidity/ast/AST.h b/libsolidity/ast/AST.h index c0d55aec..a0089d64 100644 --- a/libsolidity/ast/AST.h +++ b/libsolidity/ast/AST.h @@ -140,9 +140,25 @@ private: }; /** + * Abstract class that is added to each AST node that is stored inside a scope + * (including scopes). + */ +class Scopable +{ +public: + /// @returns the scope this declaration resides in. Can be nullptr if it is the global scope. + /// Available only after name and type resolution step. + ASTNode const* scope() const { return m_scope; } + void setScope(ASTNode const* _scope) { m_scope = _scope; } + +protected: + ASTNode const* m_scope = nullptr; +}; + +/** * Abstract AST class for a declaration (contract, function, struct, variable, import directive). */ -class Declaration: public ASTNode +class Declaration: public ASTNode, public Scopable { public: /// Visibility ordered from restricted to unrestricted. @@ -171,7 +187,7 @@ public: ASTPointer<ASTString> const& _name, Visibility _visibility = Visibility::Default ): - ASTNode(_location), m_name(_name), m_visibility(_visibility), m_scope(nullptr) {} + ASTNode(_location), m_name(_name), m_visibility(_visibility) {} /// @returns the declared name. ASTString const& name() const { return *m_name; } @@ -181,11 +197,6 @@ public: virtual bool isVisibleInContract() const { return visibility() != Visibility::External; } bool isVisibleInDerivedContracts() const { return isVisibleInContract() && visibility() >= Visibility::Internal; } - /// @returns the scope this declaration resides in. Can be nullptr if it is the global scope. - /// Available only after name and type resolution step. - 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; @@ -213,7 +224,6 @@ protected: private: ASTPointer<ASTString> m_name; Visibility m_visibility; - ASTNode const* m_scope; }; /** |