diff options
author | Christian <c@ethdev.com> | 2014-10-14 00:22:15 +0800 |
---|---|---|
committer | Christian <c@ethdev.com> | 2014-10-16 00:40:19 +0800 |
commit | 89b794f1dc15c8688526470b9d68b361dab82be3 (patch) | |
tree | 92db8a29965ee2dd796b22a1508f58b2d199e71e /Scope.h | |
parent | bdac5c7b4b5c23ea4f2cfe4a779da05b4722f1be (diff) | |
download | dexon-solidity-89b794f1dc15c8688526470b9d68b361dab82be3.tar dexon-solidity-89b794f1dc15c8688526470b9d68b361dab82be3.tar.gz dexon-solidity-89b794f1dc15c8688526470b9d68b361dab82be3.tar.bz2 dexon-solidity-89b794f1dc15c8688526470b9d68b361dab82be3.tar.lz dexon-solidity-89b794f1dc15c8688526470b9d68b361dab82be3.tar.xz dexon-solidity-89b794f1dc15c8688526470b9d68b361dab82be3.tar.zst dexon-solidity-89b794f1dc15c8688526470b9d68b361dab82be3.zip |
Type system, not yet complete.
Diffstat (limited to 'Scope.h')
-rw-r--r-- | Scope.h | 24 |
1 files changed, 6 insertions, 18 deletions
@@ -24,6 +24,8 @@ #include <map> +#include <boost/noncopyable.hpp> + #include <libsolidity/ASTForward.h> namespace dev { @@ -33,29 +35,15 @@ class Scope { public: explicit Scope(Scope* _outerScope = nullptr) : m_outerScope(_outerScope) {} - /// Registers the name _name in the scope unless it is already declared. Returns true iff + /// Registers the declaration in the scope unless its name is already declared. Returns true iff /// it was not yet declared. - bool registerName(ASTString const& _name, ASTNode& _declaration) - { - if (m_declaredNames.find(_name) != m_declaredNames.end()) - return false; - m_declaredNames[_name] = &_declaration; - return true; - } - ASTNode* resolveName(ASTString const& _name, bool _recursive = false) const - { - auto result = m_declaredNames.find(_name); - if (result != m_declaredNames.end()) - return result->second; - if (_recursive && m_outerScope != nullptr) - return m_outerScope->resolveName(_name, true); - return nullptr; - } + bool registerDeclaration(Declaration& _declaration); + Declaration* resolveName(ASTString const& _name, bool _recursive = false) const; Scope* getOuterScope() const { return m_outerScope; } private: Scope* m_outerScope; - std::map<ASTString, ASTNode*> m_declaredNames; + std::map<ASTString, Declaration*> m_declarations; }; } } |