sun::semantic_analysis::SemanticScopeBase

sun::semantic_analysis::SemanticScopeBase

struct · Source (opens in a new tab)

struct sun::semantic_analysis::SemanticScopeBase : public std::enable_shared_from_this< SemanticScopeBase >

SemanticScopeBase - Base class for all scope types Contains all fields for backward compatibility during incremental refactor. Inherits enable_shared_from_this to allow weak_ptr references from

GenericClassInfo without creating circular ownership.

Inherits

  • std::enable_shared_from_this< SemanticScopeBase > (public)

Inherited by

Public Functions

accessCtx

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

const AccessContext * sun::semantic_analysis::SemanticScopeBase::accessCtx() const

Returns the scope context used to check declaration visibility.

Related: AccessContext

admitsImport

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

bool sun::semantic_analysis::SemanticScopeBase::admitsImport(SourceFileId sourceFile) const

Whether an import belongs to the source unit performing lookup.

Related: SourceFileId

asBlock

asBlock()

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

BlockScope * sun::semantic_analysis::SemanticScopeBase::asBlock()

Accesses this scope as a block scope when its kind matches.

Related: BlockScope

asBlock() const

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

const BlockScope * sun::semantic_analysis::SemanticScopeBase::asBlock() const

Accesses this scope as a block scope when its kind matches.

Related: BlockScope

asClass

asClass()

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

ClassScope * sun::semantic_analysis::SemanticScopeBase::asClass()

Accesses this scope as a class scope when its kind matches.

Related: ClassScope

asClass() const

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

const ClassScope * sun::semantic_analysis::SemanticScopeBase::asClass() const

Accesses this scope as a class scope when its kind matches.

Related: ClassScope

asFunction

asFunction()

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

FunctionScope * sun::semantic_analysis::SemanticScopeBase::asFunction()

===== Downcasting helpers =====

Related: FunctionScope

asFunction() const

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

const FunctionScope * sun::semantic_analysis::SemanticScopeBase::asFunction() const

Accesses this scope as a function scope when its kind matches.

Related: FunctionScope

asInterface

asInterface()

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

InterfaceScope * sun::semantic_analysis::SemanticScopeBase::asInterface()

Accesses this scope as a interface scope when its kind matches.

Related: InterfaceScope

asInterface() const

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

const InterfaceScope * sun::semantic_analysis::SemanticScopeBase::asInterface() const

Accesses this scope as a interface scope when its kind matches.

Related: InterfaceScope

cloneSymbols

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

std::shared_ptr< SemanticScopeBase > sun::semantic_analysis::SemanticScopeBase::cloneSymbols(SemanticScopeBase *newParent) const

Clone symbol tables (for diamond import handling).

Related: SemanticScopeBase

collectFunctions

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

void sun::semantic_analysis::SemanticScope::collectFunctions(const std::string &name, std::vector< FunctionInfo > &results) const

Appends the visible overloads matching the requested function name.

Related: FunctionInfo

declareClass

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

void sun::semantic_analysis::SemanticScopeBase::declareClass(const std::string &name, std::shared_ptr< sun::types::ClassType > classType, std::optional< sun::support::Position > loc=std::nullopt)

Record a class in the current scope.

A repeated registration of the same name is ignored, which is what a diamond import produces.

Related: sun::types::ClassType, sun::support::Position

declareClassDefinition

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

void sun::semantic_analysis::SemanticScopeBase::declareClassDefinition(const std::string &name, ClassDefinitionAST &definition)

Record the source class body associated with a name.

Related: ClassDefinitionAST

declareEnum

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

void sun::semantic_analysis::SemanticScopeBase::declareEnum(const std::string &name, std::shared_ptr< sun::types::EnumType > enumType)

Record an enum in the current scope.

Related: sun::types::EnumType

declareFunction

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

void sun::semantic_analysis::SemanticScopeBase::declareFunction(const std::string &name, const FunctionInfo &info, std::optional< sun::support::Position > loc=std::nullopt)

Register a function prototype (key = name + param types for overloads).

Related: FunctionInfo, sun::support::Position

declareGenericClass

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

void sun::semantic_analysis::SemanticScopeBase::declareGenericClass(const std::string &name, const GenericClassInfo &info, std::optional< sun::support::Position > loc=std::nullopt)

Record a generic class template in the current scope, along with the scope it was declared in, so its bodies resolve names as written there.

Related: GenericClassInfo, sun::support::Position

declareGenericEnum

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

void sun::semantic_analysis::SemanticScopeBase::declareGenericEnum(const std::string &name, GenericEnumInfo info)

Record a generic enum template in the current scope, along with the scope it was declared in.

Related: GenericEnumInfo

declareGenericFunction

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

void sun::semantic_analysis::SemanticScopeBase::declareGenericFunction(FunctionAST &func)

Record a generic function template and its declaration scope.

Repeated registration of the same declaration is allowed; another template with the same name in this scope is rejected.

Related: FunctionAST

declareGenericInterface

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

void sun::semantic_analysis::SemanticScopeBase::declareGenericInterface(const std::string &name, const GenericInterfaceInfo &info, std::optional< sun::support::Position > loc=std::nullopt)

Record a generic interface template in the current scope.

Related: GenericInterfaceInfo, sun::support::Position

declareInterface

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

void sun::semantic_analysis::SemanticScopeBase::declareInterface(const std::string &name, std::shared_ptr< sun::types::InterfaceType > interfaceType, std::optional< sun::support::Position > loc=std::nullopt)

Record an interface in the current scope.

A repeated registration of the same name is ignored, which is what a diamond import produces.

Related: sun::types::InterfaceType, sun::support::Position

declareModule

declareModule(const std::string &name)

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

ModuleScope & sun::semantic_analysis::SemanticScopeBase::declareModule(const std::string &name)

Create or reuse a child module without entering it.

Related: ModuleScope

declareModule(const sun::ast::ModuleAST &module)

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

ModuleScope & sun::semantic_analysis::SemanticScopeBase::declareModule(const sun::ast::ModuleAST &module)

Record a module declaration and validate visibility on reopening.

Related: ModuleScope, sun::ast::ModuleAST

declareModuleVariable

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

void sun::semantic_analysis::SemanticScopeBase::declareModuleVariable(const sun::semantic_analysis::QualifiedName &qualifiedName, sun::types::TypePtr type, sun::semantic_analysis::Visibility visibility, bool isConst=false, bool isCExtern=false, sun::semantic_analysis::DeclarationId declarationId={})

Record a module-level variable by source name with its visibility.

Related: sun::semantic_analysis::QualifiedName, sun::types::TypePtr, sun::semantic_analysis::Visibility, sun::semantic_analysis::DeclarationId

declareTypeAlias

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

void sun::semantic_analysis::SemanticScopeBase::declareTypeAlias(const std::string &name, sun::types::TypePtr type, std::optional< sun::support::Position > loc=std::nullopt)

Record a type alias, rejecting a duplicate in this scope.

Related: sun::types::TypePtr, sun::support::Position

declareTypeParameters

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

void sun::semantic_analysis::SemanticScopeBase::declareTypeParameters(const std::vector< std::string > &params, const std::vector< sun::types::TypePtr > &args)

Bind type parameter names to concrete types in the current scope.

Related: sun::types::TypePtr

declareVariable

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

void sun::semantic_analysis::SemanticScopeBase::declareVariable(const std::string &name, sun::types::TypePtr type, bool isParam=false, bool isConst=false, sun::semantic_analysis::DeclarationId declarationId={})

Record a variable here, checking reserved names and global shadowing.

Related: sun::types::TypePtr, sun::semantic_analysis::DeclarationId

findClass

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

std::shared_ptr< ClassType > sun::semantic_analysis::SemanticScope::findClass(const std::string &name) const

Looks up a visible class by name in the accessible scopes.

Related: sun::types::ClassType

findEnum

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

std::shared_ptr< EnumType > sun::semantic_analysis::SemanticScope::findEnum(const std::string &name) const

Looks up a visible enum by name in the accessible scopes.

Related: sun::types::EnumType

findGenericClass

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

const GenericClassInfo * sun::semantic_analysis::SemanticScope::findGenericClass(const std::string &name) const

Looks up a visible generic class by name in the accessible scopes.

Related: GenericClassInfo

findGenericEnum

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

const GenericEnumInfo * sun::semantic_analysis::SemanticScope::findGenericEnum(const std::string &name) const

Looks up a visible generic enum by name in the accessible scopes.

Related: GenericEnumInfo

findGenericInterface

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

const GenericInterfaceInfo * sun::semantic_analysis::SemanticScope::findGenericInterface(const std::string &name) const

Looks up a visible generic interface by name in the accessible scopes.

Related: GenericInterfaceInfo

findInterface

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

std::shared_ptr< InterfaceType > sun::semantic_analysis::SemanticScope::findInterface(const std::string &name) const

Looks up a visible interface by name in the accessible scopes.

Related: sun::types::InterfaceType

findUnanalyzedGlobal

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

UnanalyzedGlobal sun::semantic_analysis::SemanticScopeBase::findUnanalyzedGlobal(const std::string &name, const DeclarationTable &declarations)

The not-yet-analyzed global that name refers to from this scope, and the scope that declares it.

Empty when the name already resolves to a variable or to no global at all. Searches the same scopes lookupVariable does, nearest first, asking declarations which globals each declares.

Related: UnanalyzedGlobal, DeclarationTable

getActiveUsingImports

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

std::vector< UsingImport > sun::semantic_analysis::SemanticScopeBase::getActiveUsingImports() const

Get all active using imports from all enclosing scopes.

Related: UsingImport

getAllFunctions

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

std::vector< FunctionInfo > sun::semantic_analysis::SemanticScopeBase::getAllFunctions(const std::string &name) const

Get all function overloads with the given name.

Related: FunctionInfo

getCurrentScopePath

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

std::vector< std::string > sun::semantic_analysis::SemanticScopeBase::getCurrentScopePath() const

Get the current scope path as a vector of segments.

getType

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

virtual ScopeType sun::semantic_analysis::SemanticScopeBase::getType() const =0

Get the scope type (virtual - each subclass returns its type).

Related: ScopeType

hasAccessibleSymbol

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

bool sun::semantic_analysis::SemanticScope::hasAccessibleSymbol(const std::string &name, class AccessFilter &filter) const

Like hasSymbol, but only counts symbols the filter admits (private ones are recorded on the filter as denied candidates).

Related: AccessFilter

hasSymbol

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

bool sun::semantic_analysis::SemanticScope::hasSymbol(const std::string &name) const

===== Symbol lookup methods (delegate to persistent scope impl) =====

isAtModuleLevel

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

bool sun::semantic_analysis::SemanticScopeBase::isAtModuleLevel() const

Report whether this scope is outside every function body.

isModuleName

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

bool sun::semantic_analysis::SemanticScopeBase::isModuleName(const std::string &name) const

Check if a name refers to a module.

isPersistent

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

bool sun::semantic_analysis::SemanticScopeBase::isPersistent() const

Check if this is a persistent scope type.

lookupClass

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

std::shared_ptr< ClassType > sun::semantic_analysis::SemanticScopeBase::lookupClass(const std::string &name) const

Lookup a class by name in the scope chain.

Related: sun::types::ClassType

lookupEnum

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

std::shared_ptr< EnumType > sun::semantic_analysis::SemanticScopeBase::lookupEnum(const std::string &name) const

Lookup an enum by name in the scope chain.

Related: sun::types::EnumType

lookupFunction

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

std::optional< FunctionInfo > sun::semantic_analysis::SemanticScopeBase::lookupFunction(const std::string &name, const std::vector< FunctionArgumentType > &argTypes, std::optional< sun::support::Position > loc=std::nullopt) const

Select an overload by types, then by supplied alternative types.

Related: FunctionInfo, FunctionArgumentType, sun::support::Position

lookupFunctionLocal

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

std::optional< FunctionInfo > sun::semantic_analysis::SemanticScopeBase::lookupFunctionLocal(const std::string &name, const std::vector< FunctionArgumentType > &argTypes, class AccessFilter *filter=nullptr, bool matchAlternatives=false, std::optional< sun::support::Position > loc=std::nullopt) const

Select an overload from this scope's own function table.

Record inaccessible candidates on the filter. Setting matchAlternatives enables the fallback pass, which lookupFunction runs only after ordinary lookup finds no match.

Related: FunctionInfo, FunctionArgumentType, AccessFilter, sun::support::Position

lookupGenericClass

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

const GenericClassInfo * sun::semantic_analysis::SemanticScopeBase::lookupGenericClass(const std::string &name) const

Lookup a generic class by name in the scope chain.

Related: GenericClassInfo

lookupGenericEnum

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

const GenericEnumInfo * sun::semantic_analysis::SemanticScopeBase::lookupGenericEnum(const std::string &name) const

Lookup a generic enum by name in the scope chain.

Related: GenericEnumInfo

lookupGenericFunction

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

const GenericFunctionInfo * sun::semantic_analysis::SemanticScopeBase::lookupGenericFunction(const std::string &name) const

Lookup a generic function by name in the scope chain.

Related: GenericFunctionInfo

lookupGenericInterface

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

const GenericInterfaceInfo * sun::semantic_analysis::SemanticScopeBase::lookupGenericInterface(const std::string &name) const

Lookup a generic interface by name in the scope chain.

Related: GenericInterfaceInfo

lookupInChain

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

template <typename ResultT, typename Finder>
ResultT sun::semantic_analysis::SemanticScopeBase::lookupInChain(const std::string &name, Finder finder) const

Generic scope-chain traversal: calls finder(scope) at each scope in chain.

lookupInterface

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

std::shared_ptr< InterfaceType > sun::semantic_analysis::SemanticScopeBase::lookupInterface(const std::string &name) const

Lookup an interface by name in the scope chain.

Related: sun::types::InterfaceType

lookupModuleScope

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

SemanticScopeBase * sun::semantic_analysis::SemanticScopeBase::lookupModuleScope(const std::string &dotPath) const

Lookup module scope by dot-separated path.

Related: SemanticScopeBase

lookupParent

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

SemanticScopeBase * sun::semantic_analysis::SemanticScopeBase::lookupParent() const

Returns the enclosing variable scope, stopping at a library bundle.

Related: SemanticScopeBase

lookupQualifiedFunction

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

const FunctionInfo * sun::semantic_analysis::SemanticScopeBase::lookupQualifiedFunction(const std::string &qualifiedName) const

Lookup a namespaced function (module-qualified).

Related: FunctionInfo

lookupQualifiedVariable

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

VariableInfo * sun::semantic_analysis::SemanticScopeBase::lookupQualifiedVariable(const std::string &qualifiedName)

Lookup a namespaced variable (module-qualified).

Related: VariableInfo

lookupVariable

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

VariableInfo * sun::semantic_analysis::SemanticScopeBase::lookupVariable(const std::string &name)

Lookup a variable by name in the scope chain.

Related: VariableInfo

resolveNameWithUsings

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

QualifiedName sun::semantic_analysis::SemanticScopeBase::resolveNameWithUsings(const std::string &name) const

Resolve a name considering using statements and module scopes.

Related: sun::semantic_analysis::QualifiedName

~SemanticScopeBase

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

virtual sun::semantic_analysis::SemanticScopeBase::~SemanticScopeBase()=default

Destroys this object and releases its owned members.

Public Fields

accessContext

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

const AccessContext* sun::semantic_analysis::SemanticScopeBase::accessContext = nullptr

No documentation comment.

Related: AccessContext

canonicalModules

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

std::map<std::string, SemanticScopeBase*> sun::semantic_analysis::SemanticScopeBase::canonicalModules

Original module paths and nominal declarations, indexed on the root scope.

Related: SemanticScopeBase

catchBinding

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

DeclarationId sun::semantic_analysis::SemanticScopeBase::catchBinding

No documentation comment.

Related: DeclarationId

childModules

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

std::map<std::string, std::shared_ptr<SemanticScopeBase> > sun::semantic_analysis::SemanticScopeBase::childModules

No documentation comment.

Related: SemanticScopeBase

children

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

std::vector<std::shared_ptr<SemanticScopeBase> > sun::semantic_analysis::SemanticScopeBase::children

No documentation comment.

Related: SemanticScopeBase

classDefinitions

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

std::map<std::string, ClassDefinitionAST*> sun::semantic_analysis::SemanticScopeBase::classDefinitions

No documentation comment.

Related: ClassDefinitionAST

classes

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

std::map<std::string, std::shared_ptr<sun::types::ClassType> > sun::semantic_analysis::SemanticScopeBase::classes

No documentation comment.

Related: sun::types::ClassType

enums

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

std::map<std::string, std::shared_ptr<sun::types::EnumType> > sun::semantic_analysis::SemanticScopeBase::enums

No documentation comment.

Related: sun::types::EnumType

functions

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

FunctionTable sun::semantic_analysis::SemanticScopeBase::functions

No documentation comment.

Related: FunctionTable

genericClasses

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

std::map<std::string, GenericClassInfo> sun::semantic_analysis::SemanticScopeBase::genericClasses

No documentation comment.

Related: GenericClassInfo

genericEnums

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

std::map<std::string, GenericEnumInfo> sun::semantic_analysis::SemanticScopeBase::genericEnums

No documentation comment.

Related: GenericEnumInfo

genericFunctions

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

std::map<std::string, GenericFunctionInfo> sun::semantic_analysis::SemanticScopeBase::genericFunctions

No documentation comment.

Related: GenericFunctionInfo

genericInterfaces

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

std::map<std::string, GenericInterfaceInfo> sun::semantic_analysis::SemanticScopeBase::genericInterfaces

No documentation comment.

Related: GenericInterfaceInfo

importBindings

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

std::vector<ImportBinding> sun::semantic_analysis::SemanticScopeBase::importBindings

No documentation comment.

Related: ImportBinding

inUnsafeContext

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

bool sun::semantic_analysis::SemanticScopeBase::inUnsafeContext = false

No documentation comment.

interfaces

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

std::map<std::string, std::shared_ptr<sun::types::InterfaceType> > sun::semantic_analysis::SemanticScopeBase::interfaces

No documentation comment.

Related: sun::types::InterfaceType

isExternal

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

bool sun::semantic_analysis::SemanticScopeBase::isExternal = false

No documentation comment.

namespacedVariables

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

std::map<std::string, VariableInfo> sun::semantic_analysis::SemanticScopeBase::namespacedVariables

No documentation comment.

Related: VariableInfo

narrowedTypes

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

std::map<std::string, sun::types::TypePtr> sun::semantic_analysis::SemanticScopeBase::narrowedTypes

No documentation comment.

Related: sun::types::TypePtr

parent

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

SemanticScopeBase* sun::semantic_analysis::SemanticScopeBase::parent = nullptr

No documentation comment.

Related: SemanticScopeBase

scopeName

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

std::string sun::semantic_analysis::SemanticScopeBase::scopeName

No documentation comment.

scopePath

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

std::vector<std::string> sun::semantic_analysis::SemanticScopeBase::scopePath

No documentation comment.

tryBlockDepth

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

int sun::semantic_analysis::SemanticScopeBase::tryBlockDepth = 0

No documentation comment.

typeAliases

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

std::map<std::string, sun::types::TypePtr> sun::semantic_analysis::SemanticScopeBase::typeAliases

No documentation comment.

Related: sun::types::TypePtr

typeParameters

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

std::map<std::string, sun::types::TypePtr> sun::semantic_analysis::SemanticScopeBase::typeParameters

No documentation comment.

Related: sun::types::TypePtr

unsafeBlockDepth

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

int sun::semantic_analysis::SemanticScopeBase::unsafeBlockDepth = 0

No documentation comment.

usingImports

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

std::vector<UsingImport> sun::semantic_analysis::SemanticScopeBase::usingImports

No documentation comment.

Related: UsingImport

variables

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

std::map<std::string, VariableInfo> sun::semantic_analysis::SemanticScopeBase::variables

No documentation comment.

Related: VariableInfo