class
#include <slang/ast/Scope.h>
Scope Base class for symbols that represent a name scope; that is, they contain children and can participate in name lookup.
Derived classes
- class CheckerSymbol
- Represents a checker declaration.
- class ClassType
- Represents a class definition type.
- class ClockingBlockSymbol
- Represents a clocking block.
- class CompilationUnitSymbol
- The root of a single compilation unit.
- class ConfigBlockSymbol
- Represents a config block declaration.
- class ConstraintBlockSymbol
- Represents a named constraint block declaration within a class.
- class CoverCrossBodySymbol
- Represents the body of a cover cross type, separated out because the members of the cross body can't be accessed outside of the cross itself.
- class CovergroupBodySymbol
- Represents the body of a covergroup type, separated out because the arguments of a covergroup need to live in their own scope so that they can be shadowed by body members.
- class CovergroupType
- Represents a covergroup definition type.
- class EnumType
- Represents an enumerated type.
- class GenerateBlockArraySymbol
- Represents an array of generate blocks, as generated by a loop generate construct.
- class GenerateBlockSymbol
- Represents blocks that are instantiated by a loop generate or conditional generate construct.
- class LetDeclSymbol
- Represents a let declaration.
- class ModportSymbol
- Represents a modport within an interface definition.
- class PackageSymbol
- A SystemVerilog package construct.
- class PackedStructType
- Represents a packed structure of members.
- class PackedUnionType
- Represents a packed union of members.
- class PropertySymbol
- Represents a named property object.
- class RootSymbol
- Represents the entirety of a design, along with all contained compilation units.
- class SequenceSymbol
- Represents a named sequence object.
- class SubroutineSymbol
- Represents a subroutine (task or function).
- class UnpackedStructType
- Represents an unpacked structure of members.
- class UnpackedUnionType
- Represents an unpacked union of members.
Public types
- class iterator
- An iterator for members in the scope.
-
template<typename SpecificType>class specific_symbol_iterator
- An iterator for members in the scope of the specified type.
- class WildcardImportData
- Collection of information about wildcard imports in a scope.
Public functions
- void addMember(const Symbol& symbol)
- Adds a symbol as a member to the scope.
-
void addMembers(const syntax::
SyntaxNode& syntax) - Creates and adds one or more member symbols to the scope from the given syntax node.
- auto getCompilation() const -> Compilation&
- Gets the compilation that contains this scope.
- auto getDefaultNetType() const -> const NetType&
- Gets the default net type for implicit nets in this scope.
-
auto getTimeScale() const -> std::
optional<TimeScale> - Gets the time scale for delay values expressed within this scope.
- auto isProceduralContext() const -> bool
- Returns true if this scope represents a procedural context; that is, a procedural block, or a task/function scope.
- auto getContainingInstance() const -> const InstanceBodySymbol*
- Gets the instance body that contains this scope, if applicable.
- auto getCompilationUnit() const -> const CompilationUnitSymbol*
- Gets the compilation unit that contains this scope, if applicable.
- auto isUninstantiated() const -> bool
- Returns true if this scope is in an uninstantiated context, like if in a module that is not used in the design.
- auto addDiag(DiagCode code, SourceLocation location) const -> Diagnostic&
- Reports a new diagnostic under this scope.
- auto addDiag(DiagCode code, SourceRange sourceRange) const -> Diagnostic&
- Reports a new diagnostic under this scope.
- void addDiags(const Diagnostics& diags) const
- Reports the given set of diagnostics under this scope.
-
auto find(std::
string_view name) const -> const Symbol* - Finds a direct child member with the given name.
-
template<typename T>auto find(std::
string_view name) const -> const T& - Finds a direct child member with the given name.
-
auto lookupName(std::
string_view name, LookupLocation location = LookupLocation:: max, bitmask<LookupFlags> flags = LookupFlags:: None) const -> const Symbol* - Performs a full fledged name lookup starting in the current scope, following all SystemVerilog rules for qualified or unqualified name resolution.
-
template<typename T>auto lookupName(std::
string_view name, LookupLocation location = LookupLocation:: max, bitmask<LookupFlags> flags = LookupFlags:: None) const -> const T& - Performs a full fledged name lookup starting in the current scope, following all SystemVerilog rules for qualified or unqualified name resolution.
-
template<typename T>auto memberAt(uint32_
t index) const -> const T& - Gets a specific member at the given zero-based index, expecting it to be of the specified type.
- auto empty() const -> bool
- Checks whether the scope is empty (has no members).
- auto members() const -> std::ranges::subrange<iterator>
- Gets the range of members contained in the scope.
-
template<typename T>auto membersOfType() const -> std::ranges::subrange<specific_
symbol_ iterator<T>> - Gets the range of members of the given type contained in the scope.
- auto getFirstMember() const -> const Symbol*
- Gets a pointer to the first member in the scope.
- auto getLastMember() const -> const Symbol*
- Gets a pointer to the last member in the scope.
- auto getNameMap() const -> const SymbolMap&
- Gets the map of names for child symbols in this scope.
- auto getUnelaboratedNameMap() const -> const SymbolMap&
- Gets the map of names for child symbols in this scope without forcing elaboration of the scope.
- void reportNameConflict(const Symbol& member, const Symbol& existing) const
- Reports a name conflict between the two given symbols in this scope.
- auto getWildcardImportData() const -> WildcardImportData*
- Gets the wildcard import data declared in this scope.
Protected functions
- void ensureElaborated() const
- Before we access any members to do lookups or return iterators, make sure the scope is fully elaborated.
- void setNeedElaboration()
- Flag the need for this scope to be elaborated before members are accessed.
- void addWildcardImport(const WildcardImportSymbol& item)
- Add a preconstructed wildcard import to this scope.
Function documentation
const InstanceBodySymbol* slang:: ast:: Scope:: getContainingInstance() const
Gets the instance body that contains this scope, if applicable.
Otherwise returns nullptr.
const CompilationUnitSymbol* slang:: ast:: Scope:: getCompilationUnit() const
Gets the compilation unit that contains this scope, if applicable.
Otherwise returns nullptr.
const Symbol* slang:: ast:: Scope:: find(std:: string_view name) const
Finds a direct child member with the given name.
This won't return anything weird like forwarding typedefs or imported symbols, but will return things like transparent enum members. If no symbol is found with the given name, nullptr is returned.
template<typename T>
const T& slang:: ast:: Scope:: find(std:: string_view name) const
Finds a direct child member with the given name.
This won't return anything weird like forwarding typedefs or imported symbols, but will return things like transparent enum members. This method asserts that the symbol is found and is of the given type T
.
const Symbol* slang:: ast:: Scope:: lookupName(std:: string_view name,
LookupLocation location = LookupLocation:: max,
bitmask<LookupFlags> flags = LookupFlags:: None) const
Performs a full fledged name lookup starting in the current scope, following all SystemVerilog rules for qualified or unqualified name resolution.
The name to look up is parsed from the given input string.
template<typename T>
const T& slang:: ast:: Scope:: lookupName(std:: string_view name,
LookupLocation location = LookupLocation:: max,
bitmask<LookupFlags> flags = LookupFlags:: None) const
Performs a full fledged name lookup starting in the current scope, following all SystemVerilog rules for qualified or unqualified name resolution.
The name to look up is parsed from the given input string. This method expects that the symbol will be found and be of the given type T
.
const Symbol* slang:: ast:: Scope:: getFirstMember() const
Gets a pointer to the first member in the scope.
const Symbol* slang:: ast:: Scope:: getLastMember() const
Gets a pointer to the last member in the scope.