sun::semantic_analysis::BodyAnalyzer

sun::semantic_analysis::BodyAnalyzer

class · Source (opens in a new tab)

class sun::semantic_analysis::BodyAnalyzer

Check prepared statements and manage function-body scopes.

Public Functions

BodyAnalyzer

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

sun::semantic_analysis::BodyAnalyzer::BodyAnalyzer(SemanticContext &context, SemanticAnalyzer &analyzer)

Borrow the shared context and checking helpers.

Related: SemanticContext, SemanticAnalyzer

analyzeBlock

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

void sun::semantic_analysis::BodyAnalyzer::analyzeBlock(sun::ast::BlockExprAST &block)

Check a prepared block in source order.

Related: sun::ast::BlockExprAST

analyzeCompoundAssignment

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

void sun::semantic_analysis::BodyAnalyzer::analyzeCompoundAssignment(sun::ast::CompoundAssignmentAST &compound)

Resolves declarations and checks types in this compound assignment, recording the results on its syntax nodes.

Related: sun::ast::CompoundAssignmentAST

analyzeForInLoop

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

void sun::semantic_analysis::BodyAnalyzer::analyzeForInLoop(sun::ast::ForInExprAST &forInExpr)

Resolves declarations and checks types in this for in loop, recording the results on its syntax nodes.

Related: sun::ast::ForInExprAST

analyzeForLoop

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

void sun::semantic_analysis::BodyAnalyzer::analyzeForLoop(sun::ast::ForExprAST &forExpr)

Resolves declarations and checks types in this for loop, recording the results on its syntax nodes.

Related: sun::ast::ForExprAST

analyzeFunction

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

void sun::semantic_analysis::BodyAnalyzer::analyzeFunction(sun::ast::FunctionAST &function)

Enter a resolved function's scope and check defaults, parameters, and body.

Related: sun::ast::FunctionAST

analyzeIfExpr

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

void sun::semantic_analysis::BodyAnalyzer::analyzeIfExpr(sun::ast::IfExprAST &ifExpr)

Control flow (analysis_control_flow.cpp).

Related: sun::ast::IfExprAST, analysis_control_flow.cpp

analyzeIndexedAssignment

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

void sun::semantic_analysis::BodyAnalyzer::analyzeIndexedAssignment(sun::ast::IndexedAssignmentAST &assignment)

Resolves declarations and checks types in this indexed assignment, recording the results on its syntax nodes.

Related: sun::ast::IndexedAssignmentAST

analyzeLambda

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

void sun::semantic_analysis::BodyAnalyzer::analyzeLambda(sun::ast::LambdaAST &lambda)

Bind a lambda's parameters and captures before checking its body.

Related: sun::ast::LambdaAST

analyzeMatchExpr

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

void sun::semantic_analysis::BodyAnalyzer::analyzeMatchExpr(sun::ast::MatchExprAST &matchExpr, sun::types::TypePtr expectedType)

Resolves declarations and checks types in this match expression, recording the results on its syntax nodes.

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

analyzeMemberAssignment

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

void sun::semantic_analysis::BodyAnalyzer::analyzeMemberAssignment(sun::ast::MemberAssignmentAST &memberAssign)

Resolves declarations and checks types in this member assignment, recording the results on its syntax nodes.

Related: sun::ast::MemberAssignmentAST

analyzeMethodWithBindings

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

void sun::semantic_analysis::BodyAnalyzer::analyzeMethodWithBindings(sun::ast::FunctionAST &method, std::shared_ptr< sun::types::ClassType > classType, const std::vector< std::string > &typeParams, const std::vector< sun::types::TypePtr > &typeArgs)

Check a specialized class method under its concrete type bindings.

Related: sun::ast::FunctionAST, sun::types::ClassType, sun::types::TypePtr

analyzeReturnExpr

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

void sun::semantic_analysis::BodyAnalyzer::analyzeReturnExpr(sun::ast::ReturnExprAST &returnExpr)

Resolves declarations and checks types in this return expression, recording the results on its syntax nodes.

Related: sun::ast::ReturnExprAST

analyzeThrowExpr

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

void sun::semantic_analysis::BodyAnalyzer::analyzeThrowExpr(sun::ast::ThrowExprAST &throwExpr)

Resolves declarations and checks types in this throw expression, recording the results on its syntax nodes.

Related: sun::ast::ThrowExprAST

analyzeTryCatch

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

void sun::semantic_analysis::BodyAnalyzer::analyzeTryCatch(sun::ast::TryCatchExprAST &tryCatchExpr)

Resolves declarations and checks types in this try catch, recording the results on its syntax nodes.

Related: sun::ast::TryCatchExprAST

analyzeUnsafeBlock

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

void sun::semantic_analysis::BodyAnalyzer::analyzeUnsafeBlock(sun::ast::UnsafeBlockAST &unsafeBlock)

Resolves declarations and checks types in this unsafe block, recording the results on its syntax nodes.

Related: sun::ast::UnsafeBlockAST

analyzeVariableAssignment

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

void sun::semantic_analysis::BodyAnalyzer::analyzeVariableAssignment(sun::ast::VariableAssignmentAST &varAssign)

Resolves declarations and checks types in this variable assignment, recording the results on its syntax nodes.

Related: sun::ast::VariableAssignmentAST

tryAnalyzeStatement

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

bool sun::semantic_analysis::BodyAnalyzer::tryAnalyzeStatement(sun::ast::ExprAST &expr, sun::types::TypePtr expectedType=nullptr)

Checks statement nodes and returns false for value expressions.

Related: sun::ast::ExprAST, sun::types::TypePtr

Private Functions

analyzeModuleGlobalAssignment

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

void sun::semantic_analysis::BodyAnalyzer::analyzeModuleGlobalAssignment(sun::ast::MemberAssignmentAST &assign, const sun::types::Type &objectType)

Check mod.name = value: the target must be a visible, assignable module-level variable, and the value must fit its type.

Also records the global's symbol name on the node for codegen.

Related: sun::ast::MemberAssignmentAST, sun::types::Type

extractTypeGuard

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

std::optional< std::pair< std::string, TypePtr > > sun::semantic_analysis::BodyAnalyzer::extractTypeGuard(const sun::ast::ExprAST &cond)

The variable and resolved type of an _is&lt;T&gt;(var) condition, so the then-branch can narrow the variable to T; nothing for other conditions.

Related: sun::types::TypePtr, sun::ast::ExprAST

Private Fields

ctx_

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

SemanticContext& sun::semantic_analysis::BodyAnalyzer::ctx_

No documentation comment.

Related: SemanticContext

sema_

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

SemanticAnalyzer& sun::semantic_analysis::BodyAnalyzer::sema_

No documentation comment.

Related: SemanticAnalyzer