sun::semantic_analysis::EnumAnalyzer

sun::semantic_analysis::EnumAnalyzer

class · Source (opens in a new tab)

class sun::semantic_analysis::EnumAnalyzer

Checks enum definitions, variant construction, and match patterns.

Public Functions

EnumAnalyzer

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

sun::semantic_analysis::EnumAnalyzer::EnumAnalyzer(SemanticContext &ctx, SemanticAnalyzer &sema, GenericSpecializer &generics, type_analysis::TypeResolver &types)

Share the context and analysis helpers for this compilation.

Related: SemanticContext, SemanticAnalyzer, GenericSpecializer, type_analysis::TypeResolver

analyzeEnumDefinition

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

void sun::semantic_analysis::EnumAnalyzer::analyzeEnumDefinition(sun::ast::EnumDefinitionAST &enumDef)

Enum definition analysis: validation, payload resolution, registration (generic enums register as templates).

Related: sun::ast::EnumDefinitionAST

analyzeEnumMatch

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

void sun::semantic_analysis::EnumAnalyzer::analyzeEnumMatch(sun::ast::MatchExprAST &matchExpr, const std::shared_ptr< sun::types::EnumType > &enumType, sun::types::TypePtr expectedType)

Match analysis on enum discriminants: variant patterns, payload bindings, exhaustiveness.

Related: sun::ast::MatchExprAST, sun::types::EnumType, sun::types::TypePtr

tryAnalyzeEnumConstruction

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

bool sun::semantic_analysis::EnumAnalyzer::tryAnalyzeEnumConstruction(sun::ast::CallExprAST &callExpr, sun::types::TypePtr expectedType)

Call interception for EnumName.Variant(args...) on concrete and generic enums; returns true when the call was an enum construction.

Related: sun::ast::CallExprAST, sun::types::TypePtr

tryAnalyzeGenericEnumUnitVariant

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

bool sun::semantic_analysis::EnumAnalyzer::tryAnalyzeGenericEnumUnitVariant(sun::ast::MemberAccessAST &memberAccess, sun::types::TypePtr expectedType)

Member-access interception for generic enum unit variants (Option.None); returns true when handled (type arguments taken from the expected type).

Related: sun::ast::MemberAccessAST, sun::types::TypePtr

Private Functions

analyzeEnumVariantConstruction

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

void sun::semantic_analysis::EnumAnalyzer::analyzeEnumVariantConstruction(sun::ast::CallExprAST &callExpr, sun::ast::MemberAccessAST &memberAccess, const std::shared_ptr< sun::types::EnumType > &enumType)

Check a concrete enum variant construction, EnumName.Variant(args...), against the payload the variant declares.

Related: sun::ast::CallExprAST, sun::ast::MemberAccessAST, sun::types::EnumType

analyzeGenericEnumConstruction

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

void sun::semantic_analysis::EnumAnalyzer::analyzeGenericEnumConstruction(sun::ast::CallExprAST &callExpr, sun::ast::MemberAccessAST &memberAccess, const std::string &genericName, const GenericEnumInfo &genericInfo, sun::types::TypePtr expectedType)

Option.Some(42): infer type arguments from payload args (falling back to the expected type), instantiate, then check like a concrete construction.

Related: sun::ast::CallExprAST, sun::ast::MemberAccessAST, GenericEnumInfo, sun::types::TypePtr

enumPathOf

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

std::string sun::semantic_analysis::EnumAnalyzer::enumPathOf(const sun::ast::ExprAST &object)

The enum name an expression spells, bare ("E") or through its module path ("a.b.E"); empty when it is not such a path or a local variable shadows its head.

Related: sun::ast::ExprAST

Private Fields

ctx_

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

SemanticContext& sun::semantic_analysis::EnumAnalyzer::ctx_

No documentation comment.

Related: SemanticContext

generics_

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

GenericSpecializer& sun::semantic_analysis::EnumAnalyzer::generics_

No documentation comment.

Related: GenericSpecializer

resolver_

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

type_analysis::TypeResolver& sun::semantic_analysis::EnumAnalyzer::resolver_

No documentation comment.

Related: type_analysis::TypeResolver

sema_

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

SemanticAnalyzer& sun::semantic_analysis::EnumAnalyzer::sema_

No documentation comment.

Related: SemanticAnalyzer