class
#include <slang/ast/types/DeclaredType.h>
DeclaredType Ties together various syntax nodes that declare the type of some parent symbol along with the logic necessary to resolve that type. Optionally includes an initializer expression as well, which can be necessary when resolving types that are implicitly inferred from the initializer.
Constructors, destructors, conversion operators
-
DeclaredType(const Symbol& parent,
bitmask<DeclaredTypeFlags> flags = DeclaredTypeFlags::
None) explicit
Public functions
- auto getType() const -> const Type&
- Resolves and returns the actual type.
- void setType(const Type& newType)
-
void setTypeSyntax(const syntax::
DataTypeSyntax& newType) - void setLink(const DeclaredType& target)
-
auto getTypeSyntax() const -> const syntax::
DataTypeSyntax* -
void setDimensionSyntax(const syntax::
SyntaxList<syntax:: VariableDimensionSyntax>& newDimensions) -
auto getDimensionSyntax() const -> const syntax::
SyntaxList<syntax:: VariableDimensionSyntax>* - Gets any previously set unpacked dimensions.
- auto getInitializer() const -> const Expression*
- Resolves and returns the initializer expression, if present. Otherwise returns nullptr.
- void setInitializer(const Expression& expr)
-
void setInitializerSyntax(const syntax::
ExpressionSyntax& syntax, SourceLocation loc) -
auto getInitializerSyntax() const -> const syntax::
ExpressionSyntax* - Gets the initializer syntax previously set by setInitializerSyntax.
- auto getInitializerLocation() const -> SourceLocation
- Gets the initializer location previously set by setInitializerSyntax.
-
void setFromDeclarator(const syntax::
DeclaratorSyntax& decl) - auto isEvaluating() const -> bool
- void setOverrideIndex(SymbolIndex index)
- void addFlags(bitmask<DeclaredTypeFlags> toAdd)
- auto getFlags() const -> bitmask<DeclaredTypeFlags>
- Gets the flags associated with this declared type.
-
void mergeImplicitPort(const syntax::
ImplicitTypeSyntax& implicit, SourceLocation location, std::span<const syntax:: VariableDimensionSyntax*const> unpackedDimensions) - void resolveAt(const ASTContext& context) const
- void forceResolveAt(const ASTContext& context) const
Function documentation
slang:: ast:: DeclaredType:: DeclaredType(const Symbol& parent,
bitmask<DeclaredTypeFlags> flags = DeclaredTypeFlags:: None) explicit
Parameters | |
---|---|
parent | The parent symbol that owns the declared type. |
flags | Optional additional flags that constrain type resolution. |
Constructs a new instance of the class.
void slang:: ast:: DeclaredType:: setTypeSyntax(const syntax:: DataTypeSyntax& newType)
Sets the source syntax for the type, which will later be used when resolution is requested.
void slang:: ast:: DeclaredType:: setLink(const DeclaredType& target)
Sets this declared type to link to the given type, taking on whatever type and initializer that target has.
const syntax:: DataTypeSyntax* slang:: ast:: DeclaredType:: getTypeSyntax() const
Gets the type syntax that was previously set via setTypeSyntax – if any. Otherwise returns nullptr.
void slang:: ast:: DeclaredType:: setDimensionSyntax(const syntax:: SyntaxList<syntax:: VariableDimensionSyntax>& newDimensions)
Sets an additional set of dimensions that represent the unpacked portion of the type declaration.
void slang:: ast:: DeclaredType:: setInitializer(const Expression& expr)
Manually sets the resolved initializer expression, overriding anything that may have been resolved previously.
void slang:: ast:: DeclaredType:: setInitializerSyntax(const syntax:: ExpressionSyntax& syntax,
SourceLocation loc)
Parameters | |
---|---|
syntax | The initializer expression syntax. |
loc | The source location to use when reporting diagnostics about the initializer. |
Sets the syntax for the initializer expression, which will be later used when resolution is requested.
void slang:: ast:: DeclaredType:: setFromDeclarator(const syntax:: DeclaratorSyntax& decl)
Sets type and initializer information from the given declarator syntax. This is just convenient shorthand for invoking setTypeSyntax and setInitializerSyntax manually.
bool slang:: ast:: DeclaredType:: isEvaluating() const
Returns true if this declared type is in the process of being resolved. This is used to detect cycles in the the type resolution process.
void slang:: ast:: DeclaredType:: setOverrideIndex(SymbolIndex index)
Sets a separate, later position in the parent scope for creating the declared type and initializer. This is used for merged port symbols because their declared I/O location and symbol location may differ.
void slang:: ast:: DeclaredType:: addFlags(bitmask<DeclaredTypeFlags> toAdd)
Adds additional type resolution flags to constrain resolution behavior. This will clear any resolved type to force resolution again with the new flags set.
void slang:: ast:: DeclaredType:: mergeImplicitPort(const syntax:: ImplicitTypeSyntax& implicit,
SourceLocation location,
std::span<const syntax:: VariableDimensionSyntax*const> unpackedDimensions)
Perform a merge of implicit port information; this facilitates the non-ascii port system permitted by Verilog, where port I/O declarations are separate from the actual symbol declaration but may still carry some type info.
void slang:: ast:: DeclaredType:: resolveAt(const ASTContext& context) const
Resolves the initializer using the given AST context, which could differ from the AST context that is used for type resolution.
void slang:: ast:: DeclaredType:: forceResolveAt(const ASTContext& context) const
Forces resolution of both the type and the initializer using the given AST context instead of using the normal logic built into DeclaredType to determine the context.