slang::Symbol class

Base class for all symbols (logical code constructs) such as modules, types, functions, variables, etc.

Derived classes

class CompilationUnitSymbol
The root of a single compilation unit.
class ContinuousAssignSymbol
Represents a continuous assignment statement.
class ElabSystemTaskSymbol
Represents an elaboration system task, such as $error or $warning.
class EmptyMemberSymbol
class ExplicitImportSymbol
Represents an explicit import from a package.
class ForwardingTypedefSymbol
class GenerateBlockArraySymbol
Represents an array of generate blocks, as generated by a loop generate construct.
class GenerateBlockSymbol
class GenericClassDefSymbol
class GenvarSymbol
Represents a genvar declaration.
class InstanceSymbol
Base class for module, interface, and program instance symbols.
class InterfacePortSymbol
class ModportSymbol
Represents a modport within an interface definition.
class NetType
class PackageSymbol
A SystemVerilog package construct.
class RootSymbol
Represents the entirety of a design, along with all contained compilation units.
class SubroutineSymbol
Represents a subroutine (task or function).
class TransparentMemberSymbol
class Type
class UnknownModuleSymbol
class ValueSymbol
class WildcardImportSymbol

Public functions

auto getParentScope() const -> const Scope*
Gets the logical parent scope that contains this symbol.
auto getSyntax() const -> const SyntaxNode*
auto isScope() const -> bool
Determines whether this symbol also represents a scope.
auto isType() const -> bool
Determines whether this symbol represents a type.
auto isValue() const -> bool
Determines whether this symbol represents a value.
auto getDeclaredType() const -> const DeclaredType*
If the symbol has a declared type, returns a pointer to it. Otherwise returns nullptr.
void getHierarchicalPath(std::string& buffer) const
void getLexicalPath(std::string& buffer) const
auto isDeclaredBefore(const Symbol& symbol) const -> optional<bool>
auto getDeclaringDefinition() const -> const Definition*
auto getRandMode() const -> RandMode
auto getIndex() const -> SymbolIndex
void setSyntax(const SyntaxNode& node)
auto getNextSibling() const -> const Symbol*
Returns the next sibling symbol in the parent scope, if one exists.

Public variables

SymbolKind kind
The type of symbol.
string_view name
SourceLocation location

Function documentation

const SyntaxNode* slang::Symbol::getSyntax() const

Gets the syntax node that was used to create this symbol, if any. Symbols can be created without any originating syntax; in those cases, this returns nullptr.

void slang::Symbol::getHierarchicalPath(std::string& buffer) const

Gets the symbol's hierarchical path by walking up to the root node and appending each parent's name.

void slang::Symbol::getLexicalPath(std::string& buffer) const

Gets the symbol's lexical path by walking up to the compilation unit and appending each parent's name.

optional<bool> slang::Symbol::isDeclaredBefore(const Symbol& symbol) const

Determines whether this symbol is considered to be declared before the given symbol, in the same compilation unit. If it is, this method returns true. Otherwise it returns false. If the given symbol is not even in the same compilation unit as this one, returns std::nullopt.

const Definition* slang::Symbol::getDeclaringDefinition() const

Gets the definition in which this symbol is declared. If the symbol isn't declared in a definition, returns nullptr.

RandMode slang::Symbol::getRandMode() const

If this symbol is a random variable, returns its mode. Otherwise returns RandMode::None.

SymbolIndex slang::Symbol::getIndex() const

Gets the index of the symbol within its parent scope, which can be used to determine the relative ordering of scope members.

void slang::Symbol::setSyntax(const SyntaxNode& node)

Sets the syntax that was used to create this symbol. Mostly called by various factory functions.

Variable documentation

string_view slang::Symbol::name

The name of the symbol; if the symbol does not have a name, this will be an empty string.

SourceLocation slang::Symbol::location

The declared location of the symbol in the source code, or an empty location if it was not explicitly declared in the source text. This is mainly used for reporting errors.