class
#include <slang/ast/Lookup.h>
Lookup Centralized functionality for looking up symbols by name in the AST.
Public static functions
-
static void name(const syntax::
NameSyntax& syntax, const ASTContext& context, bitmask<LookupFlags> flags, LookupResult& result) - Performs a full fledged name lookup starting in the current scope, following all SystemVerilog rules for qualified or unqualified name resolution.
-
static auto unqualified(const Scope& scope,
std::
string_view name, bitmask<LookupFlags> flags = LookupFlags:: None) -> const Symbol* - Performs an unqualified lookup in this scope, then recursively up the parent chain until we reach root or the symbol is found.
-
static auto unqualifiedAt(const Scope& scope,
std::
string_view name, LookupLocation location, SourceRange sourceRange, bitmask<LookupFlags> flags = LookupFlags:: None) -> const Symbol* - Performs an unqualified lookup in this scope, then recursively up the parent chain until we reach root or the symbol is found.
-
static auto selectChild(const Symbol& symbol,
std::
span<const syntax:: ElementSelectSyntax*const> selectors, const ASTContext& context, LookupResult& result) -> const Symbol* - Applies the given selectors to the symbol and returns the selected child.
-
static void selectChild(const Type& virtualInterface,
SourceRange range,
std::
span<LookupResult:: Selector> selectors, const ASTContext& context, LookupResult& result) - Applies the given selectors to the virtualInterface type and returns the selected child in.
-
static auto findClass(const syntax::
NameSyntax& name, const ASTContext& context, std:: optional<DiagCode> requireInterfaceClass = {}) -> const ClassType* - Searches for a class with the given name within context – if no symbol is found, or if the found symbol is not a class type, appropriate diagnostics are issued.
-
static auto getContainingClass(const Scope& scope) -> std::
pair<const ClassType*, bool> - Gets the containing class for the given scope.
- static auto getVisibility(const Symbol& symbol) -> Visibility
- If the given symbol is a member of a class, returns its access visibility.
- static auto isVisibleFrom(const Symbol& symbol, const Scope& scope) -> bool
- Returns whether the given symbol is visible from the provided scope, taking into account class accessibility modifiers.
- static auto isAccessibleFrom(const Symbol& target, const Symbol& sourceScope) -> bool
- Returns whether the given target instance symbol is accessible from the provided scope, taking into account the class that owns the target (if any) and the class that owns the provided scope (if any).
-
static auto ensureVisible(const Symbol& symbol,
const ASTContext& context,
std::
optional<SourceRange> sourceRange) -> bool - If the given symbol is not a class member, returns true without doing any other work.
-
static auto ensureAccessible(const Symbol& symbol,
const ASTContext& context,
std::
optional<SourceRange> sourceRange) -> bool - If the given symbol is not a class member, returns true without doing any other work.
-
static auto findTempVar(const Scope& scope,
const TempVarSymbol& symbol,
const syntax::
NameSyntax& name, LookupResult& result) -> bool - Searches a linked list of temporary variable symbols to see if any match the given name.
-
static auto withinClassRandomize(const ASTContext& context,
const syntax::
NameSyntax& syntax, bitmask<LookupFlags> flags, LookupResult& result) -> bool - Performs a lookup within the given class randomize() scope, respecting the name restrictions provided.
-
static auto findAssertionLocalVar(const ASTContext& context,
const syntax::
NameSyntax& name, LookupResult& result) -> bool - Performs a lookup within an expanding sequence or property to try to find a local variable matching the given name.
Function documentation
static const Symbol* slang:: ast:: Lookup:: unqualified(const Scope& scope,
std:: string_view name,
bitmask<LookupFlags> flags = LookupFlags:: None)
Performs an unqualified lookup in this scope, then recursively up the parent chain until we reach root or the symbol is found.
No errors are reported if no symbol can be found.
static const Symbol* slang:: ast:: Lookup:: unqualifiedAt(const Scope& scope,
std:: string_view name,
LookupLocation location,
SourceRange sourceRange,
bitmask<LookupFlags> flags = LookupFlags:: None)
Performs an unqualified lookup in this scope, then recursively up the parent chain until we reach root or the symbol is found.
Reports an error if the symbol is not found.
static const Symbol* slang:: ast:: Lookup:: selectChild(const Symbol& symbol,
std:: span<const syntax:: ElementSelectSyntax*const> selectors,
const ASTContext& context,
LookupResult& result)
Applies the given selectors to the symbol and returns the selected child.
If any errors occur, diagnostics are issued to result and nullptr is returned.
static void slang:: ast:: Lookup:: selectChild(const Type& virtualInterface,
SourceRange range,
std:: span<LookupResult:: Selector> selectors,
const ASTContext& context,
LookupResult& result)
Applies the given selectors to the virtualInterface type and returns the selected child in.
Returns | – if any errors occur, diagnostics are issued to the result object and nullptr is returned. |
---|
static const ClassType* slang:: ast:: Lookup:: findClass(const syntax:: NameSyntax& name,
const ASTContext& context,
std:: optional<DiagCode> requireInterfaceClass = {})
Searches for a class with the given name within context – if no symbol is found, or if the found symbol is not a class type, appropriate diagnostics are issued.
If requireInterfaceClass is given the resulting class will be required to be an interface class; nullptr will be returned and a diagnostic issued if it's not.
static std:: pair<const ClassType*, bool> slang:: ast:: Lookup:: getContainingClass(const Scope& scope)
Gets the containing class for the given scope.
The return value is a pair, with the first element being the found class or nullptr if the scope is not within a class definition. The second element indicates whether the given scope was found to be within a static method.
static Visibility slang:: ast:: Lookup:: getVisibility(const Symbol& symbol)
If the given symbol is a member of a class, returns its access visibility.
Otherwise, returns Visibility::Public.
static bool slang:: ast:: Lookup:: isAccessibleFrom(const Symbol& target,
const Symbol& sourceScope)
Returns whether the given target instance symbol is accessible from the provided scope, taking into account the class that owns the target (if any) and the class that owns the provided scope (if any).
This is for checking access of instance members and doesn't look at visibility of the symbol.
static bool slang:: ast:: Lookup:: ensureVisible(const Symbol& symbol,
const ASTContext& context,
std:: optional<SourceRange> sourceRange)
If the given symbol is not a class member, returns true without doing any other work.
Otherwise, if the member is visible from the provided context, returns true. If it's not visible, and sourceRange is provided, an appropriate diganostic will be issued and false returned.
static bool slang:: ast:: Lookup:: ensureAccessible(const Symbol& symbol,
const ASTContext& context,
std:: optional<SourceRange> sourceRange)
If the given symbol is not a class member, returns true without doing any other work.
Otherwise, if the member is accessible from the provided context (in terms of static vs instance members), returns true. If it's not accessible, and sourceRange is provided, an appropriate diganostic will be issued and false returned.
static bool slang:: ast:: Lookup:: findTempVar(const Scope& scope,
const TempVarSymbol& symbol,
const syntax:: NameSyntax& name,
LookupResult& result)
Searches a linked list of temporary variable symbols to see if any match the given name.
If one is found, populates result and returns true. Otherwise returns false.
static bool slang:: ast:: Lookup:: withinClassRandomize(const ASTContext& context,
const syntax:: NameSyntax& syntax,
bitmask<LookupFlags> flags,
LookupResult& result)
Performs a lookup within the given class randomize() scope, respecting the name restrictions provided.
If the symbol is not found, or if the name starts with 'local::', it is expected that the caller will then perform a normal lookup in the local scope. Returns true if the symbol is found and false otherwise.
static bool slang:: ast:: Lookup:: findAssertionLocalVar(const ASTContext& context,
const syntax:: NameSyntax& name,
LookupResult& result)
Performs a lookup within an expanding sequence or property to try to find a local variable matching the given name.
If one is found, populates result and returns true. Otherwise returns false.