12#ifndef ARK_COMPILER_NAMERESOLUTION_SCOPERESOLVER_HPP
13#define ARK_COMPILER_NAMERESOLUTION_SCOPERESOLVER_HPP
56 void createNewNamespace(
const std::string& name,
bool with_prefix,
bool is_glob,
const std::vector<std::string>& symbols);
79 [[nodiscard]] std::optional<bool>
isImmutable(
const std::string& name)
const;
86 [[nodiscard]]
bool isRegistered(
const std::string& name)
const;
94 [[nodiscard]]
bool isInScope(
const std::string& name)
const;
121 std::vector<std::unique_ptr<StaticScope>>
m_scopes;
ScopeResolver & operator=(ScopeResolver &&)=default
ScopeResolver & operator=(const ScopeResolver &)=delete
std::string registerInCurrent(const std::string &name, bool is_mutable)
Register a Declaration in the current (last) scope.
ScopeResolver()
Create a ScopeResolver.
void createNewNamespace(const std::string &name, bool with_prefix, bool is_glob, const std::vector< std::string > &symbols)
Create a new namespace scope.
void saveNamespaceAndRemove()
Save the last scope as a namespace, by attaching it to the nearest namespace scope.
std::string getFullyQualifiedNameInNearestScope(const std::string &name) const
Get a FQN from a variable name in the nearest scope it is declared in.
bool isRegistered(const std::string &name) const
Checks if any scope has 'name', in reverse order.
void createNew()
Create a new scope.
std::vector< std::unique_ptr< StaticScope > > m_scopes
ScopeResolver(ScopeResolver &&)=default
ScopeResolver(const ScopeResolver &)=delete
StaticScope * currentScope() const
Return a non-owning raw pointer to the current scope.
bool isInScope(const std::string &name) const
Checks if 'name' is in the current scope.
void removeLastScope()
Remove the last scope.
std::optional< bool > isImmutable(const std::string &name) const
Checks the scopes in reverse order for 'name' and returns its mutability status.
std::pair< bool, std::string > canFullyQualifyName(const std::string &name)
Checks if a name can be fully qualified (allows only unprefixed names to be resolved by glob namespac...