sun::ast::EnumDefinitionAST
class · Source (opens in a new tab)
class sun::ast::EnumDefinitionAST : public sun::ast::ExprASTEnum definition: enum Name { Variant1, Variant2(T1, T2), ... } Generic form: enum Option<T> { Some(T), None }.
Inherits
- sun::ast::ExprAST (public)
Public Functions
- EnumDefinitionAST
- addSpecialization
- clearComputedAnalysis
- dotLabel
- getDoc
- getMutableVariants
- getName
- getNumVariants
- getQualifiedName
- getSpecializations
- getType
- getTypeParameterNames
- getTypeParameters
- getUnderlyingType
- getUnderlyingTypeName
- getValueText
- getVariant
- getVariants
- hasAnyPayload
- hasQualifiedName
- isGeneric
- resetAnalysisSession
- setDoc
- setQualifiedName
- toString
EnumDefinitionAST
public · function · Source (opens in a new tab)
sun::ast::EnumDefinitionAST::EnumDefinitionAST(std::string name, std::vector< EnumVariantDecl > variants, bool precompiled=false, std::vector< TypeParameter > typeParams={}, std::string underlyingType={})Creates this syntax node and takes ownership of any supplied child expressions.
Related: EnumVariantDecl, TypeParameter
addSpecialization
public · function · Source (opens in a new tab)
void sun::ast::EnumDefinitionAST::addSpecialization(DeclarationId id, std::shared_ptr< sun::types::EnumType > specialized) constSpecialization storage for generic enums, mirroring generic classes.
Enums carry no per-specialization code, so the artifact is the resolved EnumType itself (payload types substituted). Called by the semantic analyzer when the generic enum is instantiated; codegen walks these to build the storage structs.
Related: DeclarationId, sun::types::EnumType, EnumType
clearComputedAnalysis
public · function · Source (opens in a new tab)
void sun::ast::EnumDefinitionAST::clearComputedAnalysis() const overrideDrop computed enum instances while retaining the declaration identity.
dotLabel
public · function · Source (opens in a new tab)
std::string sun::ast::EnumDefinitionAST::dotLabel() const overrideReturns the node label used in syntax-tree graph visualizations.
getDoc
public · function · Source (opens in a new tab)
const std::string & sun::ast::EnumDefinitionAST::getDoc() constComment written above the enum (see doc_comments.h).
Related: doc_comments.h
getMutableVariants
public · function · Source (opens in a new tab)
std::vector< EnumVariantDecl > & sun::ast::EnumDefinitionAST::getMutableVariants()Returns the modifiable enum alternatives.
Related: EnumVariantDecl
getName
public · function · Source (opens in a new tab)
const std::string & sun::ast::EnumDefinitionAST::getName() constReturns the declared name used to identify this object.
getNumVariants
public · function · Source (opens in a new tab)
size_t sun::ast::EnumDefinitionAST::getNumVariants() constGet the number of variants.
getQualifiedName
public · function · Source (opens in a new tab)
const QualifiedName & sun::ast::EnumDefinitionAST::getQualifiedName() constThe original declaration name, retained by imported enums.
Related: QualifiedName
getSpecializations
public · function · Source (opens in a new tab)
const std::map< DeclarationId, std::shared_ptr< sun::types::EnumType > > & sun::ast::EnumDefinitionAST::getSpecializations() constProvides the concrete instances created from this generic declaration.
Related: DeclarationId, sun::types::EnumType
getType
public · function · Source (opens in a new tab)
ASTNodeType sun::ast::EnumDefinitionAST::getType() const overrideReturns the syntax-node kind used to dispatch tree visitors.
Related: ASTNodeType
getTypeParameterNames
public · function · Source (opens in a new tab)
std::vector< std::string > sun::ast::EnumDefinitionAST::getTypeParameterNames() constReturns the names used to bind generic arguments during specialization.
getTypeParameters
public · function · Source (opens in a new tab)
const std::vector< TypeParameter > & sun::ast::EnumDefinitionAST::getTypeParameters() constProvides the generic parameters declared by this type or function.
Related: TypeParameter
getUnderlyingType
public · function · Source (opens in a new tab)
const std::string & sun::ast::EnumDefinitionAST::getUnderlyingType() constReturn the written integer type, or an empty string for the default.
getUnderlyingTypeName
public · function · Source (opens in a new tab)
std::string sun::ast::EnumDefinitionAST::getUnderlyingTypeName() constReturn the integer representation used for this enum.
getValueText
public · function · Source (opens in a new tab)
std::string sun::ast::EnumDefinitionAST::getValueText(const EnumVariantDecl &variant) constFormat a tag according to the enum's signedness.
Related: EnumVariantDecl
getVariant
public · function · Source (opens in a new tab)
const EnumVariantDecl * sun::ast::EnumDefinitionAST::getVariant(const std::string &variantName) constGet a variant by name.
Related: EnumVariantDecl
getVariants
public · function · Source (opens in a new tab)
const std::vector< EnumVariantDecl > & sun::ast::EnumDefinitionAST::getVariants() constProvides the alternatives declared by this enum.
Related: EnumVariantDecl
hasAnyPayload
public · function · Source (opens in a new tab)
bool sun::ast::EnumDefinitionAST::hasAnyPayload() constTrue if any variant carries a payload (tagged-union representation).
hasQualifiedName
public · function · Source (opens in a new tab)
bool sun::ast::EnumDefinitionAST::hasQualifiedName() constWhether this enum already carries its defining name.
isGeneric
public · function · Source (opens in a new tab)
bool sun::ast::EnumDefinitionAST::isGeneric() constReports whether this declaration still has unbound type parameters.
resetAnalysisSession
public · function · Source (opens in a new tab)
void sun::ast::EnumDefinitionAST::resetAnalysisSession() const overrideDrop instances and annotations belonging to the discarded session.
setDoc
public · function · Source (opens in a new tab)
void sun::ast::EnumDefinitionAST::setDoc(std::string doc)Stores the source documentation comment for this declaration.
setQualifiedName
public · function · Source (opens in a new tab)
void sun::ast::EnumDefinitionAST::setQualifiedName(QualifiedName name)Record the defining name independently of visible aliases.
Related: QualifiedName
toString
public · function · Source (opens in a new tab)
std::string sun::ast::EnumDefinitionAST::toString() const overrideReturns a readable representation for diagnostics and debugging.
Public Fields
qualifiedName
public · variable · Source (opens in a new tab)
QualifiedName sun::ast::EnumDefinitionAST::qualifiedNameNo documentation comment.
Related: QualifiedName
Private Fields
doc_
private · variable · Source (opens in a new tab)
std::string sun::ast::EnumDefinitionAST::doc_No documentation comment.
name
private · variable · Source (opens in a new tab)
std::string sun::ast::EnumDefinitionAST::nameNo documentation comment.
specializations_
private · variable · Source (opens in a new tab)
std::map<DeclarationId, std::shared_ptr<sun::types::EnumType> > sun::ast::EnumDefinitionAST::specializations_No documentation comment.
Related: DeclarationId, sun::types::EnumType
typeParameters
private · variable · Source (opens in a new tab)
std::vector<TypeParameter> sun::ast::EnumDefinitionAST::typeParametersNo documentation comment.
Related: TypeParameter
underlyingType
private · variable · Source (opens in a new tab)
std::string sun::ast::EnumDefinitionAST::underlyingTypeNo documentation comment.
variants
private · variable · Source (opens in a new tab)
std::vector<EnumVariantDecl> sun::ast::EnumDefinitionAST::variantsNo documentation comment.
Related: EnumVariantDecl