mirror of
https://github.com/YosysHQ/yosys
synced 2025-09-11 12:11:27 +00:00
Add IdString const &id_string() const to StaticIdString and IdString
The vast majority of ID(...) uses are in a context that is overloaded for StaticIdString or will cause implicit conversion to an IdString constant reference. For some sufficently overloaded contexts, implicit conversion may fail, so it's useful to have a method to force obtaining a `IdString const &` from an ID(...) use. When turning all literal IdStrings of the codebase into StaticIdStrings this was needed in exactly one place, for which this commit adds an `id_string()` call.
This commit is contained in:
parent
6a1d8abf7c
commit
ca9d1e5fd8
2 changed files with 4 additions and 1 deletions
|
@ -121,6 +121,7 @@ namespace RTLIL
|
|||
constexpr StaticIdString(StaticId id, const IdString &id_str) : id_str(id_str), id(id) {}
|
||||
constexpr inline operator const IdString &() const { return id_str; }
|
||||
constexpr inline int index() const { return static_cast<short>(id); }
|
||||
constexpr inline const IdString &id_string() const { return id_str; }
|
||||
|
||||
const IdString &id_str;
|
||||
const StaticId id;
|
||||
|
@ -343,6 +344,8 @@ struct RTLIL::IdString
|
|||
*this = id;
|
||||
}
|
||||
|
||||
constexpr inline const IdString &id_string() const { return *this; }
|
||||
|
||||
inline const char *c_str() const {
|
||||
return global_id_storage_.at(index_);
|
||||
}
|
||||
|
|
|
@ -77,7 +77,7 @@ struct ExampleDtPass : public Pass
|
|||
auto enqueue = [&](DriveSpec const &spec) {
|
||||
int index = queue(spec);
|
||||
if (index == GetSize(graph_nodes))
|
||||
graph_nodes.emplace_back(compute_graph.add(ID($pending), index).index());
|
||||
graph_nodes.emplace_back(compute_graph.add(ID($pending).id_string(), index).index());
|
||||
//if (index >= GetSize(graph_nodes))
|
||||
return compute_graph[graph_nodes[index]];
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue