slang::ast::GenericClassDefSymbol class

Represents a generic class definition, which is a parameterized class that has not yet had its parameter values specified.

This is a not a type – the generic class must first be specialized in order to be a type usable in expressions and declarations.

Base classes

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

Public functions

auto getDefaultSpecialization() const -> const Type*
Gets the default specialization for the class, or nullptr if the generic class has no default specialization (because some parameters are not defaulted).
auto getSpecialization(const ASTContext& context, const syntax::ParameterValueAssignmentSyntax& syntax) const -> const Type&
Gets the specialization for the class given the specified parameter value assignments.
auto getInvalidSpecialization() const -> const Type&
Forces a specialization with all parameters set to invalid values.
auto numSpecializations() const -> size_t
Gets the number of specializations that have been made for this generic class.
auto specializations() const -> auto
Gets an iterator to the specializations created for the generic class.
void checkForwardDecls() const
Checks all forward declarations for validity when considering the target type of this alias.
void addParameterDecl(const DefinitionSymbol::ParameterDecl& decl)
Adds a new parameter declaration to the generic class.

Public variables

bool isInterface
Set to true if the generic class is an interface class.

Function documentation

const Type& slang::ast::GenericClassDefSymbol::getSpecialization(const ASTContext& context, const syntax::ParameterValueAssignmentSyntax& syntax) const

Gets the specialization for the class given the specified parameter value assignments.

The result is cached and reused if requested more than once.

const Type& slang::ast::GenericClassDefSymbol::getInvalidSpecialization() const

Forces a specialization with all parameters set to invalid values.

This allows determining members that aren't dependent on parameters.

void slang::ast::GenericClassDefSymbol::checkForwardDecls() const

Checks all forward declarations for validity when considering the target type of this alias.

Any inconsistencies will issue diagnostics.

void slang::ast::GenericClassDefSymbol::addParameterDecl(const DefinitionSymbol::ParameterDecl& decl)

Adds a new parameter declaration to the generic class.

This is only used for programmatically constructed generic classes (not sourced from syntax). Behavior is undefined if this generic class has already been instantiated and used.