slang::ast::ClassType class

Represents a class definition type.

Base classes

class Type
Base class for all data types in SystemVerilog.
class Scope
Base class for symbols that represent a name scope; that is, they contain children and can participate in name lookup.

Public functions

auto getBaseClass() const -> const Type*
If this class derives from a base class, returns that type. Otherwise returns null.
auto getImplementedInterfaces() const -> std::span<const Type*const>
Gets the list of interface classes that this class implements.
auto getDeclaredInterfaces() const -> std::span<const Type*const>
Gets the list of interface classes that this class implements, as declared in the class type declaration (i.e.
auto getBaseConstructorCall() const -> const Expression*
If this class has a base class with a constructor, gets the expression used to invoke that method.
auto getConstructor() const -> const SubroutineSymbol*
Gets the class constructor function, if it has an explicit constructor.
auto getBitstreamWidth() const -> uint64_t
Gets $bits of the type. Returns zero if the type does not have a statically known size.
auto hasCycles() const -> bool
Returns true if this class type has recursive cycles in its properties (i.e.
void checkForwardDecls() const
Checks all forward declarations for validity when considering the target type of this alias.

Public variables

const GenericClassDefSymbol* genericClass
If the class type was specialized from a generic class, this is a pointer to that generic class definition.
const VariableSymbol* thisVar
A variable that points to the instance of this class itself, which is used by non-static class property initializers that refers to the special "this" handle.
bool isAbstract
Set to true if the class is an abstract class (declared with the "virtual" keyword).
bool isInterface
Set to true if the class is an interface class.
bool isFinal
Set to true if this class is marked final (i.e. it cannot be extended).

Function documentation

std::span<const Type*const> slang::ast::ClassType::getImplementedInterfaces() const

Gets the list of interface classes that this class implements.

If this class is itself an interface class, this is instead the list of interface classes that it extends from, if any.

Note that this list is flattened from the full set of all interfaces implemented by any base classes or interface class parents, up the inheritance hierarchy.

std::span<const Type*const> slang::ast::ClassType::getDeclaredInterfaces() const

Gets the list of interface classes that this class implements, as declared in the class type declaration (i.e.

it does not include any parent interfaces inherited from the ones in the declaration). If this class is itself an interface class, this is instead the list of interface classes that it extends from, if any.

const Expression* slang::ast::ClassType::getBaseConstructorCall() const

If this class has a base class with a constructor, gets the expression used to invoke that method.

Otherwise returns nullptr.

const SubroutineSymbol* slang::ast::ClassType::getConstructor() const

Gets the class constructor function, if it has an explicit constructor.

Otherwise returns nullptr.

bool slang::ast::ClassType::hasCycles() const

Returns true if this class type has recursive cycles in its properties (i.e.

properties with the same type as this class, directly or indirectly).

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

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

Any inconsistencies will issue diagnostics.

Variable documentation

const VariableSymbol* slang::ast::ClassType::thisVar

A variable that points to the instance of this class itself, which is used by non-static class property initializers that refers to the special "this" handle.

Subroutines and constraint blocks have their own "thisVar" members.