slang::ast::LookupResult struct

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

Public types

struct MemberSelector
using Selector = std::variant<const syntax::ElementSelectSyntax*, MemberSelector>

Public functions

auto addDiag(const Scope& scope, DiagCode code, SourceLocation location) -> Diagnostic&
auto addDiag(const Scope& scope, DiagCode code, SourceRange sourceRange) -> Diagnostic&
auto getDiagnostics() const -> const Diagnostics&
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
void errorIfSelectors(const ASTContext& context) const
Issues a diagnostic if there are selectors in the lookup result.

Public variables

const Symbol* found
const SystemSubroutine* systemSubroutine
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
bool fromTypeParam
bool fromForwardTypedef
SmallVector<Selector, 4> selectors

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.

void slang::ast::LookupResult::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.

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.

const SystemSubroutine* slang::ast::LookupResult::systemSubroutine

If the lookup found a system subroutine, a pointer to it is returned here and the found field will be nullptr.

bool slang::ast::LookupResult::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 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.