diff options
author | Philip Herron <philip.herron@embecosm.com> | 2020-12-10 17:44:33 +0000 |
---|---|---|
committer | Philip Herron <herron.philip@googlemail.com> | 2020-12-17 17:23:46 +0000 |
commit | 3514168b990fd67225c59e84c7fffec075788905 (patch) | |
tree | 937dc0fbfe0a754e502f1947a01fdb4e20ad5698 /gcc/rust/analysis | |
parent | 29fb9e4d937f2d98734330f46f539514e2518cc3 (diff) | |
download | gcc-3514168b990fd67225c59e84c7fffec075788905.zip gcc-3514168b990fd67225c59e84c7fffec075788905.tar.gz gcc-3514168b990fd67225c59e84c7fffec075788905.tar.bz2 |
Introduce HIR Mapping
This is the start of a bigger refactor of the compiler to follow the
rustc internals. This introduces a mapping system for.
- HirId which maps to any Hir Node within the current crate
- LocalDefId any toplevel Hir Node HIR::Item within current crate
- NodeId maps any AST node akin to HirId such that they can map back
- DefId Cratea and localDefId combination
Diffstat (limited to 'gcc/rust/analysis')
-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 |