sun::types::EnumType
class · Source (opens in a new tab)
class sun::types::EnumType : public sun::types::NominalTypeEnum type for user-defined enums Enums use an integer representation, with variants as named constants Example: enum Color { Red, Green, Blue }.
Inherits
- sun::types::NominalType (public)
Public Functions
- EnumType
- addVariant
- equals
- getBaseName
- getDisplayName
- getGenericArgs
- getGenericBase
- getGenericQualifiedName
- getKind
- getName
- getNumVariants
- getQualifiedName
- getUnderlyingType
- getVariant
- getVariants
- hasBaseName
- hasPayload
- hasVariant
- isGenericSpecialization
- setBaseName
- setGenericOrigin
- setGenericQualifiedName
- setQualifiedName
- setUnderlyingType
- setVariantPayloadTypes
- toDisplayString
- toLLVMType
- toString
EnumType
EnumType(std::string name_, std::vector< EnumVariant > vars, std::string baseName="")
public · function · Source (opens in a new tab)
sun::types::EnumType::EnumType(std::string name_, std::vector< EnumVariant > vars, std::string baseName="")Creates a semantic enum descriptor with its name and optional variants.
Related: EnumVariant
EnumType(std::string name_, std::string baseName="")
public · function · Source (opens in a new tab)
sun::types::EnumType::EnumType(std::string name_, std::string baseName="")Creates a semantic enum descriptor with its name and optional variants.
addVariant
public · function · Source (opens in a new tab)
void sun::types::EnumType::addVariant(const std::string &variantName, int64_t value, DeclarationId declarationId={})Register a variant once, retaining its declaration identity.
Related: DeclarationId
equals
public · function · Source (opens in a new tab)
bool sun::types::EnumType::equals(const Type &other) const overrideReports whether the other type has the same semantic identity.
Related: Type
getBaseName
public · function · Source (opens in a new tab)
const std::string & sun::types::EnumType::getBaseName() constBase name accessor.
getDisplayName
public · function · Source (opens in a new tab)
std::string sun::types::EnumType::getDisplayName() constGet user-friendly display name for error messages.
getGenericArgs
public · function · Source (opens in a new tab)
const std::vector< TypePtr > & sun::types::EnumType::getGenericArgs() constReturns the generic type arguments.
Related: TypePtr
getGenericBase
public · function · Source (opens in a new tab)
const std::string & sun::types::EnumType::getGenericBase() constReturns the original generic declaration.
getGenericQualifiedName
public · function · Source (opens in a new tab)
const sun::semantic_analysis::QualifiedName & sun::types::EnumType::getGenericQualifiedName() constThe original template name, independent of specialization and source aliases.
Related: sun::semantic_analysis::QualifiedName
getKind
public · function · Source (opens in a new tab)
Kind sun::types::EnumType::getKind() const overrideReturns the type category used for semantic checks and dispatch.
Related: Kind
getName
public · function · Source (opens in a new tab)
const std::string & sun::types::EnumType::getName() constReturns the declared name used to identify this object.
getNumVariants
public · function · Source (opens in a new tab)
size_t sun::types::EnumType::getNumVariants() constGet the number of variants.
getQualifiedName
public · function · Source (opens in a new tab)
const sun::semantic_analysis::QualifiedName & sun::types::EnumType::getQualifiedName() constSource spelling; declaration records carry module ownership.
Related: sun::semantic_analysis::QualifiedName
getUnderlyingType
public · function · Source (opens in a new tab)
const TypePtr & sun::types::EnumType::getUnderlyingType() constReturn the integer type used to store the enum tag.
Related: TypePtr
getVariant
public · function · Source (opens in a new tab)
const EnumVariant * sun::types::EnumType::getVariant(const std::string &variantName) constReturns the variant stored by this object.
Related: EnumVariant
getVariants
public · function · Source (opens in a new tab)
const std::vector< EnumVariant > & sun::types::EnumType::getVariants() constProvides the alternatives declared by this enum.
Related: EnumVariant
hasBaseName
public · function · Source (opens in a new tab)
bool sun::types::EnumType::hasBaseName() constReports whether the unqualified declaration name is available.
hasPayload
public · function · Source (opens in a new tab)
bool sun::types::EnumType::hasPayload() constTrue if any variant carries a payload (tagged-union representation).
hasVariant
public · function · Source (opens in a new tab)
bool sun::types::EnumType::hasVariant(const std::string &variantName) constCheck if a variant exists by name.
isGenericSpecialization
public · function · Source (opens in a new tab)
bool sun::types::EnumType::isGenericSpecialization() constReports whether this type represents generic specialization values.
setBaseName
public · function · Source (opens in a new tab)
void sun::types::EnumType::setBaseName(std::string baseName)Sets the unqualified declaration name without changing its enclosing scopes.
setGenericOrigin
public · function · Source (opens in a new tab)
void sun::types::EnumType::setGenericOrigin(std::string base, std::vector< TypePtr > args)Generic specialization origin (e.g.
Option_i32 records base "Option" and args [i32]); empty for non-generic enums.
Related: TypePtr
setGenericQualifiedName
public · function · Source (opens in a new tab)
void sun::types::EnumType::setGenericQualifiedName(sun::semantic_analysis::QualifiedName name)Record the template that produced this type.
Related: sun::semantic_analysis::QualifiedName
setQualifiedName
public · function · Source (opens in a new tab)
void sun::types::EnumType::setQualifiedName(sun::semantic_analysis::QualifiedName qn)Records the declaration name together with its enclosing scopes.
Related: sun::semantic_analysis::QualifiedName
setUnderlyingType
public · function · Source (opens in a new tab)
void sun::types::EnumType::setUnderlyingType(TypePtr type)Set the integer representation before generating enum storage.
Related: TypePtr
setVariantPayloadTypes
public · function · Source (opens in a new tab)
void sun::types::EnumType::setVariantPayloadTypes(const std::string &variantName, std::vector< TypePtr > payloadTypes)Attach resolved payload types to a variant (full-analysis phase; payload annotations may reference classes not yet registered during declaration collection).
Related: TypePtr
toDisplayString
public · function · Source (opens in a new tab)
std::string sun::types::EnumType::toDisplayString() const overrideReturns a source-facing type name without internal compiler prefixes.
toLLVMType
public · function · Source (opens in a new tab)
llvm::Type * sun::types::EnumType::toLLVMType(llvm::LLVMContext &ctx) const overridePayload-free enums use their integer type.
Payload enums need the module DataLayout for storage sizing: LLVMTypeResolver computes the storage struct and caches it here; afterwards toLLVMType serves the cache (e.g. for class field embedding via ClassType::getStructType).
Related: ClassType::getStructType
toString
public · function · Source (opens in a new tab)
std::string sun::types::EnumType::toString() const overrideReturns a readable representation for diagnostics and debugging.
Public Fields
StaticKind
public · variable · static · Source (opens in a new tab)
Kind sun::types::EnumType::StaticKind = Kind::EnumNo documentation comment.
Related: Kind, Kind::Enum
cachedStorageType
public · variable · Source (opens in a new tab)
llvm::StructType* sun::types::EnumType::cachedStorageType = nullptrNo documentation comment.
cachedVariantStructs
public · variable · Source (opens in a new tab)
std::unordered_map<std::string, llvm::StructType*> sun::types::EnumType::cachedVariantStructsNo documentation comment.
visibility
public · variable · Source (opens in a new tab)
sun::semantic_analysis::Visibility sun::types::EnumType::visibility =
sun::semantic_analysis::Visibility::PrivateNo documentation comment.
Related: sun::semantic_analysis::Visibility, sun::semantic_analysis::Visibility::Private
Public Friends
sun::semantic_analysis::TypeRegistry
public · friend · Source (opens in a new tab)
friend class sun::semantic_analysis::TypeRegistryNo documentation comment.
Related: sun::semantic_analysis::TypeRegistry
Private Fields
- baseName_
- genericArgs_
- genericBase_
- genericQualifiedName_
- name_
- qualifiedName_
- underlyingType_
- variants
baseName_
private · variable · Source (opens in a new tab)
std::string sun::types::EnumType::baseName_No documentation comment.
genericArgs_
private · variable · Source (opens in a new tab)
std::vector<TypePtr> sun::types::EnumType::genericArgs_No documentation comment.
Related: TypePtr
genericBase_
private · variable · Source (opens in a new tab)
std::string sun::types::EnumType::genericBase_No documentation comment.
genericQualifiedName_
private · variable · Source (opens in a new tab)
sun::semantic_analysis::QualifiedName sun::types::EnumType::genericQualifiedName_No documentation comment.
Related: sun::semantic_analysis::QualifiedName
name_
private · variable · Source (opens in a new tab)
std::string sun::types::EnumType::name_No documentation comment.
qualifiedName_
private · variable · Source (opens in a new tab)
sun::semantic_analysis::QualifiedName sun::types::EnumType::qualifiedName_No documentation comment.
Related: sun::semantic_analysis::QualifiedName
underlyingType_
private · variable · Source (opens in a new tab)
TypePtr sun::types::EnumType::underlyingType_ = std::make_shared<PrimitiveType>(Kind::Int32)No documentation comment.
Related: TypePtr, PrimitiveType, Kind::Int32
variants
private · variable · Source (opens in a new tab)
std::vector<EnumVariant> sun::types::EnumType::variantsNo documentation comment.
Related: EnumVariant