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 copyFrom(const LookupResult& other)
Copies result members from the given result object.
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.
bool wasImported
Set to true if the found symbol was imported from a package.
bool isHierarchical
Set to true if the lookup was hierarchical.
bool suppressUndeclared
Set to true if there were problems during lookup that indicate we should ignore the lack of a found symbol, because we're in a context where such a failure may be expected (for example, within a default instantiation of a generic class where the base class fails to resolve).
bool fromTypeParam
Set to true if the lookup was resolved through a type parameter.
bool fromForwardTypedef
Set to true if the lookup was resolved through a forwarded typedef.
SmallVector<Selector, 4> selectors
A list of selectors that should be applied to the found symbol.

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.

bool slang::ast::LookupResult::fromTypeParam

Set to true if the lookup was resolved through a type parameter.

Some language rules restrict where this can be done.

bool slang::ast::LookupResult::fromForwardTypedef

Set to true if the lookup was resolved through a forwarded typedef.

Some language rules restrict where this can be done.

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.