slang::ast::HierarchicalReference class

Represents a hierarchical reference to a symbol.

Public types

struct Element
An element in the hierarchical path.

Public static functions

static auto fromLookup(Compilation& compilation, const LookupResult& result) -> HierarchicalReference
Constructs a HierarchicalReference from a lookup result.

Constructors, destructors, conversion operators

HierarchicalReference() defaulted
Default constructor.

Public functions

auto isViaIfacePort() const -> bool
Returns true if the hierarchical reference was resolved via an interface port connection.
auto isUpward() const -> bool
Returns true if the hierarchical reference traverses upward through the hierarchy.
auto retargetIfacePort(const InstanceSymbol& base) const -> const Symbol*
Re-resolves the target symbol starting from the corresponding port in the new base instance and following the same path as the original reference.
auto join(Compilation& compilation, const HierarchicalReference& other) const -> const HierarchicalReference&
Returns a new HierarchicalReference that represents the joined path of this reference and another.

Public variables

const Symbol* target
The target symbol of the hierarchical reference.
const Expression* expr
The expression that was used to start the lookup, typically a HierarchicalValueExpression.
std::span<const Element> path
The resolved path to the target symbol.
size_t upwardCount
The number of times the path traverses upward before going back down the hierarchy to reach the target symbol.

Function documentation

const Symbol* slang::ast::HierarchicalReference::retargetIfacePort(const InstanceSymbol& base) const

Re-resolves the target symbol starting from the corresponding port in the new base instance and following the same path as the original reference.

Returns the resolved symbol, or nullptr if the path could not be followed or this reference does not resolve through an interface port.