diff --git a/common/nextpnr.h b/common/nextpnr.h index ad89046c..263c8e13 100644 --- a/common/nextpnr.h +++ b/common/nextpnr.h @@ -841,6 +841,8 @@ struct BaseCtx // Context meta data std::unordered_map attrs; + Context *as_ctx = nullptr; + BaseCtx() { idstring_str_to_idx = new std::unordered_map; @@ -914,9 +916,9 @@ struct BaseCtx IdString id(const char *s) const { return IdString(this, s); } - Context *getCtx() { return reinterpret_cast(this); } + Context *getCtx() { return as_ctx; } - const Context *getCtx() const { return reinterpret_cast(this); } + const Context *getCtx() const { return as_ctx; } const char *nameOf(IdString name) const { return name.c_str(this); } @@ -1245,7 +1247,7 @@ struct Context : Arch, DeterministicRNG // Should we disable printing of the location of nets in the critical path? bool disable_critical_path_source_print = false; - Context(ArchArgs args) : Arch(args) {} + Context(ArchArgs args) : Arch(args) { BaseCtx::as_ctx = this; } // --------------------------------------------------------------