slang::LookupResult struct

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

Public types

struct MemberSelector
using Selector = std::variant<const 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 reportErrors(const BindContext& context)

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 sawBadImport
bool fromTypeParam
bool fromForwardTypedef
SmallVectorSized<Selector, 4> selectors

Typedef documentation

using slang::LookupResult::Selector = std::variant<const 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::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::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::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::LookupResult::reportErrors(const BindContext& context)

Reports any diagnostics that have occurred during lookup to the given bind context, which will ensure they are visible to the compilation.

Variable documentation

const Symbol* slang::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::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::LookupResult::sawBadImport

Set to true if we observed an invalid import statement somewhere during lookup. This means the lack of a found symbol should be treated with caution, because it could be the import failure causing it instead of some otherwise invalid name.

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

Set to true if the lookup was resolved through a forwarded typedef. Some language rules restrict where this can be done.

SmallVectorSized<Selector, 4> slang::LookupResult::selectors

A list of selectors that should be applied to the found symbol. Only applicable if the found symbol is a value symbol.