slang::Scope class

Base class for symbols that represent a name scope; that is, they contain children and can participate in name lookup.

Derived classes

class ClassType
Represents a class definition type.
class ClockingBlockSymbol
Represents a clocking block.
class CompilationUnitSymbol
The root of a single compilation unit.
class ConstraintBlockSymbol
Represents a named constraint block declaration within a class.
class EnumType
Represents an enumerated type.
class GenerateBlockArraySymbol
Represents an array of generate blocks, as generated by a loop generate construct.
class GenerateBlockSymbol
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.

Public functions

void addMember(const Symbol& symbol)
Adds a symbol as a member to the scope.
void addMembers(const 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 -> TimeScale
Gets the time scale for delay values expressed within this scope.
auto isProceduralContext() const -> bool
auto getContainingInstance() const -> const InstanceBodySymbol*
auto isUninstantiated() const -> bool
auto find(string_view name) const -> const Symbol*
template<typename T>
auto find(string_view name) const -> const T&
auto lookupName(string_view name, LookupLocation location = LookupLocation::max, bitmask<LookupFlags> flags = LookupFlags::None) const -> const Symbol*
template<typename T>
auto lookupName(string_view name, LookupLocation location = LookupLocation::max, bitmask<LookupFlags> flags = LookupFlags::None) const -> const T&
template<typename T>
auto memberAt(uint32_t index) const -> const T&
auto empty() const -> bool
Checks whether the scope is empty (has no members).
auto members() const -> iterator_range<iterator>
Gets an iterator to the members contained in the scope.
template<typename T>
auto membersOfType() const -> iterator_range<specific_symbol_iterator<T>>
Gets an iterator to all of the members of the given type contained in the scope.
auto getFirstMember() const -> const Symbol*
auto getLastMember() const -> const Symbol*

Protected functions

void ensureElaborated() const
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

bool slang::Scope::isProceduralContext() const

Returns true if this scope represents a procedural context; that is, a procedural block, or a task/function scope.

const InstanceBodySymbol* slang::Scope::getContainingInstance() const

Gets the instance body that contains this scope, if applicable. Otherwise returns nullptr.

bool slang::Scope::isUninstantiated() const

Returns true if this scope is in an uninstantiated context, like if in a module that is not used in the design.

const Symbol* slang::Scope::find(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::Scope::find(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 expects that the symbol will be found and be of the given type T.

const Symbol* slang::Scope::lookupName(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::Scope::lookupName(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.

template<typename T>
const T& slang::Scope::memberAt(uint32_t index) const

Gets a specific member at the given zero-based index, expecting it to be of the specified type. This expects (and asserts) that the member at the given index is of the specified type T.

const Symbol* slang::Scope::getFirstMember() const

Gets a pointer to the first member in the scope. Note that this does not force elaboration of the scope.

const Symbol* slang::Scope::getLastMember() const

Gets a pointer to the last member in the scope. Note that this does not force elaboration of the scope.

void slang::Scope::ensureElaborated() const protected

Before we access any members to do lookups or return iterators, make sure the scope is fully elaborated.