slang::ast::LookupResult struct

A structure that contains the results of a name lookup operation.

Public types

struct MemberSelector
A structure that represents a selection of a single member from the resulting symbol found during a lookup operation.
using Selector = std::variant<const syntax::ElementSelectSyntax*, MemberSelector>
A type that represents a kind of selector for picking a child member from a found symbol.

Public functions

auto addDiag(const Scope& scope, DiagCode code, SourceLocation location) -> Diagnostic&
Reports a diagnostic that occurred during lookup.
auto addDiag(const Scope& scope, DiagCode code, SourceRange sourceRange) -> Diagnostic&
Reports a diagnostic that occurred during lookup.
auto getDiagnostics() const -> const Diagnostics&
Gets the list of diagnostics that occurred during lookup.
auto hasError() const -> bool
Returns true if an error occurred during lookup.
void clear()
Clears the structure of all results, as if it had been default initialized.
void reportDiags(const ASTContext& context) const
Reports any diagnostics that have occurred during lookup to the given AST context, which will ensure they are visible to the compilation.
void errorIfSelectors(const ASTContext& context) const
Issues a diagnostic if there are selectors in the lookup result.

Public variables

const Symbol* found
The symbol that was found by the lookup, or nullptr if no symbol was found.
const SystemSubroutine* systemSubroutine
If the lookup found a system subroutine, a pointer to it is returned here and the found field will be nullptr.
uint32_t upwardCount
If the lookup was via hierarchical path, this indicates the number of steps upward through the hierarchy we had to take before we started traversing back down to the found symbol.
bitmask<LookupResultFlags> flags
Flags that specify additional information about the result of the lookup.
SmallVector<Selector, 4> selectors
A list of selectors that should be applied to the found symbol.
SmallVector<HierarchicalReference::Element, 2> path
If this lookup was via a hierarchical reference, this value contains information about how the path was resolved.

Typedef documentation

using slang::ast::LookupResult::Selector = std::variant<const syntax::ElementSelectSyntax*, MemberSelector>

A type that represents a kind of selector for picking a child member from a found symbol.

This can either be a dotted member select or an indexed element select (from an array).

Function documentation

Diagnostic& slang::ast::LookupResult::addDiag(const Scope& scope, DiagCode code, SourceLocation location)

Reports a diagnostic that occurred during lookup.

The stored diagnostics are not automatically emitted to the compilation, letting them be suppressed if desired.

Diagnostic& slang::ast::LookupResult::addDiag(const Scope& scope, DiagCode code, SourceRange sourceRange)

Reports a diagnostic that occurred during lookup.

The stored diagnostics are not automatically emitted to the compilation, letting them be suppressed if desired.

const Diagnostics& slang::ast::LookupResult::getDiagnostics() const

Gets the list of diagnostics that occurred during lookup.

The stored diagnostics are not automatically emitted to the compilation, letting them be suppressed if desired.

Variable documentation

const Symbol* slang::ast::LookupResult::found

The symbol that was found by the lookup, or nullptr if no symbol was found.

Note that there can still be errors even if a symbol is found.

SmallVector<Selector, 4> slang::ast::LookupResult::selectors

A list of selectors that should be applied to the found symbol.

Only applicable if the found symbol is a value symbol.