diff options
author | SimplyTheOther <simplytheother@gmail.com> | 2020-12-18 21:33:09 +0800 |
---|---|---|
committer | SimplyTheOther <simplytheother@gmail.com> | 2020-12-18 21:33:09 +0800 |
commit | aa283484a3dffedc404653af18f9413775cbc3df (patch) | |
tree | 118a5b918c48fba3261731bba0a6b4149209f7d8 /gcc/rust/analysis/scope.h | |
parent | f764eeb8abf1ec50794ddb1f31bc57d025e29a3c (diff) | |
parent | bc14d9a0cd3c67093a9c11ad368c0d28325b21c6 (diff) | |
download | gcc-aa283484a3dffedc404653af18f9413775cbc3df.zip gcc-aa283484a3dffedc404653af18f9413775cbc3df.tar.gz gcc-aa283484a3dffedc404653af18f9413775cbc3df.tar.bz2 |
Merge branch 'master' of https://github.com/redbrain/gccrs
Diffstat (limited to 'gcc/rust/analysis/scope.h')
-rw-r--r-- | gcc/rust/analysis/scope.h | 57 |
1 files changed, 0 insertions, 57 deletions
diff --git a/gcc/rust/analysis/scope.h b/gcc/rust/analysis/scope.h deleted file mode 100644 index 41bcee6..0000000 --- a/gcc/rust/analysis/scope.h +++ /dev/null @@ -1,57 +0,0 @@ -#pragma once - -#include "rust-system.h" -#include "rust-ast-full.h" - -namespace Rust { -namespace Analysis { - -template <class T> class Scope -{ -public: - Scope () : scopeStack () {} - - ~Scope () {} - - bool Insert (std::string key, T val) - { - if (scopeStack.back ().find (key) != scopeStack.back ().end ()) - { - return false; - } - - scopeStack.back ().insert (std::make_pair (key, std::move (val))); - return true; - } - - bool Lookup (std::string key, T *result) - { - for (auto it = scopeStack.rbegin (); it != scopeStack.rend (); ++it) - { - auto lookup = it->find (key); - if (lookup != it->end ()) - { - *result = lookup->second; - return true; - } - } - return false; - } - - void Push () { scopeStack.push_back ({}); } - - std ::map<std::string, T> Pop () - { - auto toplevel = scopeStack.back (); - scopeStack.pop_back (); - return toplevel; - } - - std ::map<std::string, T> Peek () { return scopeStack.back (); } - -private: - std::vector<std::map<std::string, T> > scopeStack; -}; - -} // namespace Analysis -} // namespace Rust |