11#include "slang/util/ConcurrentMap.h"
36 std::deque<SymbolReference> entries;
38 concurrent_map<std::string_view, SymbolReference const *> indexMap;
39 mutable std::mutex insertMutex;
44 auto intern(std::string_view name, std::string_view hierarchicalPath,
47 if (indexMap.visit(hierarchicalPath,
48 [&](
auto const &kv) { result = kv.second; })) {
51 std::lock_guard lock(insertMutex);
52 if (indexMap.visit(hierarchicalPath,
53 [&](
auto const &kv) { result = kv.second; })) {
56 auto &stored = entries.emplace_back(
57 std::string(name), std::string(hierarchicalPath), location);
59 indexMap.emplace(std::string_view(stored.hierarchicalPath), ptr);
65 return intern(ref.name, ref.hierarchicalPath, ref.location);
69 auto size() const ->
size_t {
return entries.size(); }
Definition SymbolReference.hpp:34
auto intern(SymbolReference const &ref) -> SymbolReference const *
Convenience: intern by copying from an existing SymbolReference value.
Definition SymbolReference.hpp:64
auto size() const -> size_t
Number of unique symbol entries currently interned.
Definition SymbolReference.hpp:69
auto intern(std::string_view name, std::string_view hierarchicalPath, TextLocation location) -> SymbolReference const *
Definition SymbolReference.hpp:44
Definition Utilities.hpp:16
Extracted identity of an AST symbol, decoupled from the slang AST.
Definition SymbolReference.hpp:16
TextLocation location
Definition SymbolReference.hpp:19
SymbolReference(std::string name, std::string hierarchicalPath, TextLocation location)
Definition SymbolReference.hpp:22
std::string hierarchicalPath
Definition SymbolReference.hpp:18
auto empty() const -> bool
Definition SymbolReference.hpp:27
SymbolReference()=default
std::string name
Definition SymbolReference.hpp:17
Definition TextLocation.hpp:71