diff options
author | Clifford Wolf <clifford@clifford.at> | 2018-06-30 07:47:04 +0200 |
---|---|---|
committer | Clifford Wolf <clifford@clifford.at> | 2018-06-30 07:47:04 +0200 |
commit | 25f07549a132703079369c0ff387837bd84e9790 (patch) | |
tree | 7d17e8edc1d5adb6f02171aefc61ce663e3e3f33 | |
parent | b908b020220d0c5963dd59489cbd509b2873b3b6 (diff) | |
download | nextpnr-25f07549a132703079369c0ff387837bd84e9790.tar.gz nextpnr-25f07549a132703079369c0ff387837bd84e9790.tar.bz2 nextpnr-25f07549a132703079369c0ff387837bd84e9790.zip |
Refactor IdString::global_ctx
Signed-off-by: Clifford Wolf <clifford@clifford.at>
-rw-r--r-- | common/nextpnr.cc | 2 | ||||
-rw-r--r-- | common/nextpnr.h | 12 |
2 files changed, 7 insertions, 7 deletions
diff --git a/common/nextpnr.cc b/common/nextpnr.cc index ee0c13ba..5af83a15 100644 --- a/common/nextpnr.cc +++ b/common/nextpnr.cc @@ -21,7 +21,7 @@ NEXTPNR_NAMESPACE_BEGIN -BaseCtx *IdString::global_ctx = nullptr; +std::unordered_set<BaseCtx*> IdString::global_ctx; void IdString::set(const BaseCtx *ctx, const std::string &s) { diff --git a/common/nextpnr.h b/common/nextpnr.h index 36a8dc75..af092475 100644 --- a/common/nextpnr.h +++ b/common/nextpnr.h @@ -50,8 +50,6 @@ struct IdString { int index = 0; - static BaseCtx *global_ctx; - static void initialize_arch(const BaseCtx *ctx); static void initialize_add(const BaseCtx *ctx, const char *s, int idx); @@ -76,10 +74,12 @@ struct IdString // --- deprecated old API --- + static std::unordered_set<BaseCtx*> global_ctx; + const std::string &global_str() const __attribute__((deprecated)) { - assert(global_ctx != nullptr); - return str(global_ctx); + assert(global_ctx.size() == 1); + return str(*global_ctx.begin()); } }; @@ -204,8 +204,7 @@ struct BaseCtx BaseCtx() { - // assert(IdString::global_ctx == nullptr); - IdString::global_ctx = this; + IdString::global_ctx.insert(this); idstring_str_to_idx = new std::unordered_map<std::string, int>; idstring_idx_to_str = new std::vector<const std::string *>; @@ -215,6 +214,7 @@ struct BaseCtx ~BaseCtx() { + IdString::global_ctx.erase(this); delete idstring_str_to_idx; delete idstring_idx_to_str; } |