sun::semantic_analysis::passes::DeclarationCollectionPass

sun::semantic_analysis::passes::DeclarationCollectionPass

class · Source (opens in a new tab)

class sun::semantic_analysis::passes::DeclarationCollectionPass

Resolve declarations before bodies, using bookkeeping in SemanticContext.

TypeRegistrationPass supplies types and templates first. This pass binds imports, fills class shapes, and resolves concrete signatures. While it runs (see SemanticContext::isCollectingDeclarations), a global reached through a type annotation may not call a function, because its callee has no analyzed body yet, and a class specialization registers its signatures but queues its method bodies for an explicit body-analysis pass.

Types

Public Functions

DeclarationCollectionPass

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

sun::semantic_analysis::passes::DeclarationCollectionPass::DeclarationCollectionPass(SemanticContext &ctx, SemanticAnalyzer &sema)

Share declaration state and signature-checking helpers with analysis.

Related: SemanticContext, SemanticAnalyzer

collectExternVariable

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

void sun::semantic_analysis::passes::DeclarationCollectionPass::collectExternVariable(sun::ast::VariableCreationAST &varCreate)

Register one C extern global before any function body is analyzed.

Related: sun::ast::VariableCreationAST

collectFunctionSignature

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

void sun::semantic_analysis::passes::DeclarationCollectionPass::collectFunctionSignature(sun::ast::FunctionAST &func)

Register one named function's signature in the current scope.

Related: sun::ast::FunctionAST

registerClassShape

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

void sun::semantic_analysis::passes::DeclarationCollectionPass::registerClassShape(sun::ast::ClassDefinitionAST &classDef, const sun::semantic_analysis::QualifiedName &qualifiedClass, std::shared_ptr< sun::types::ClassType > classType)

Register a non-generic class's fields and method signatures on its ClassType so that any body analyzed afterwards — including bodies of generic specializations triggered from function signatures — can call its methods regardless of declaration order.

Related: sun::ast::ClassDefinitionAST, sun::semantic_analysis::QualifiedName, sun::types::ClassType, ClassType

registerPrecompiledModuleVariable

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

void sun::semantic_analysis::passes::DeclarationCollectionPass::registerPrecompiledModuleVariable(sun::ast::VariableCreationAST &varCreate)

Register a module-level variable imported from a .moon bundle.

The stub carries a type annotation and a content-hash-scoped qualified name, but no initializer — the storage is in the bundle.

Related: sun::ast::VariableCreationAST

registerUsing

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

void sun::semantic_analysis::passes::DeclarationCollectionPass::registerUsing(sun::ast::UsingAST &usingDecl)

Bind a using declaration in the current scope (idempotent).

Related: sun::ast::UsingAST

run

run(BlockExprAST &block)

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

void sun::semantic_analysis::passes::DeclarationCollectionPass::run(BlockExprAST &block)

Bind imports and resolve class shapes and concrete function signatures in the scopes prepared by TypeRegistrationPass before checking bodies.

This allows forward references between declarations at the same scope level, and lets a using anywhere in the block serve every declaration in it. Imported bundle wrappers are skipped; import preparation invokes this same collector directly on their contents.

Related: BlockExprAST, TypeRegistrationPass

run(const std::vector< sun::ast::MoonScopeAST * > &imports)

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

void sun::semantic_analysis::passes::DeclarationCollectionPass::run(const std::vector< sun::ast::MoonScopeAST * > &imports)

Run this stage across all borrowed imported bundles before the next stage.

Related: sun::ast::MoonScopeAST

Private Functions

registerNativeFunction

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

void sun::semantic_analysis::passes::DeclarationCollectionPass::registerNativeFunction(const sun::ast::PrototypeAST &proto, const std::vector< sun::types::TypePtr > &params, sun::types::TypePtr returnType)

Reject incompatible declarations of one native symbol across all scopes.

Related: sun::ast::PrototypeAST, sun::types::TypePtr

Private Fields

ctx_

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

SemanticContext& sun::semantic_analysis::passes::DeclarationCollectionPass::ctx_

No documentation comment.

Related: SemanticContext

nativeFunctions_

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

std::map<std::string, NativeFunctionSignature> sun::semantic_analysis::passes::DeclarationCollectionPass::nativeFunctions_

No documentation comment.

Related: NativeFunctionSignature

sema_

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

SemanticAnalyzer& sun::semantic_analysis::passes::DeclarationCollectionPass::sema_

No documentation comment.

Related: SemanticAnalyzer