slang::ast::Symbol class

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

Derived classes

class AssertionPortSymbol
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 ContinuousAssignSymbol
Represents a continuous assignment statement.
class CoverCrossBodySymbol
class CovergroupBodySymbol
class DefParamSymbol
Represents a defparam directive.
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 InstanceSymbolBase
Common functionality for module, interface, program, and primitive instances.
class InterfacePortSymbol
class LetDeclSymbol
Represents a let declaration.
class ModportClockingSymbol
Represents a clocking block port.
class ModportSymbol
Represents a modport within an interface definition.
class MultiPortSymbol
class NetType
class PackageSymbol
A SystemVerilog package construct.
class PortSymbol
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 TransparentMemberSymbol
class Type
class UninstantiatedDefSymbol
class ValueSymbol
class WildcardImportSymbol

Public functions

auto getParentScope() const -> const Scope*
Gets the logical parent scope that contains this symbol.
auto getSyntax() const -> const syntax::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 -> std::optional<bool>
auto getDeclaringDefinition() const -> const Definition*
auto getRandMode() const -> RandMode
auto getIndex() const -> SymbolIndex
void setSyntax(const syntax::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.
std::string_view name
SourceLocation location

Function documentation

const syntax::SyntaxNode* slang::ast::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::ast::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::ast::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.

std::optional<bool> slang::ast::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::ast::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::ast::Symbol::getRandMode() const

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

SymbolIndex slang::ast::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::ast::Symbol::setSyntax(const syntax::SyntaxNode& node)

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

Variable documentation

std::string_view slang::ast::Symbol::name

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

SourceLocation slang::ast::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.