sun::ast::EnumDefinitionAST

sun::ast::EnumDefinitionAST

class · Source (opens in a new tab)

class sun::ast::EnumDefinitionAST : public sun::ast::ExprAST

Enum definition: enum Name { Variant1, Variant2(T1, T2), ... } Generic form: enum Option<T> { Some(T), None }.

Inherits

Public Functions

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) const

Specialization 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 override

Drop computed enum instances while retaining the declaration identity.

dotLabel

public · function · Source (opens in a new tab)

std::string sun::ast::EnumDefinitionAST::dotLabel() const override

Returns 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() const

Comment 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() const

Returns the declared name used to identify this object.

getNumVariants

public · function · Source (opens in a new tab)

size_t sun::ast::EnumDefinitionAST::getNumVariants() const

Get the number of variants.

getQualifiedName

public · function · Source (opens in a new tab)

const QualifiedName & sun::ast::EnumDefinitionAST::getQualifiedName() const

The 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() const

Provides 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 override

Returns 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() const

Returns 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() const

Provides 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() const

Return 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() const

Return 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) const

Format 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) const

Get a variant by name.

Related: EnumVariantDecl

getVariants

public · function · Source (opens in a new tab)

const std::vector< EnumVariantDecl > & sun::ast::EnumDefinitionAST::getVariants() const

Provides the alternatives declared by this enum.

Related: EnumVariantDecl

hasAnyPayload

public · function · Source (opens in a new tab)

bool sun::ast::EnumDefinitionAST::hasAnyPayload() const

True if any variant carries a payload (tagged-union representation).

hasQualifiedName

public · function · Source (opens in a new tab)

bool sun::ast::EnumDefinitionAST::hasQualifiedName() const

Whether this enum already carries its defining name.

isGeneric

public · function · Source (opens in a new tab)

bool sun::ast::EnumDefinitionAST::isGeneric() const

Reports whether this declaration still has unbound type parameters.

resetAnalysisSession

public · function · Source (opens in a new tab)

void sun::ast::EnumDefinitionAST::resetAnalysisSession() const override

Drop 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 override

Returns a readable representation for diagnostics and debugging.

Public Fields

qualifiedName

public · variable · Source (opens in a new tab)

QualifiedName sun::ast::EnumDefinitionAST::qualifiedName

No 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::name

No 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::typeParameters

No documentation comment.

Related: TypeParameter

underlyingType

private · variable · Source (opens in a new tab)

std::string sun::ast::EnumDefinitionAST::underlyingType

No documentation comment.

variants

private · variable · Source (opens in a new tab)

std::vector<EnumVariantDecl> sun::ast::EnumDefinitionAST::variants

No documentation comment.

Related: EnumVariantDecl