12#ifndef ARK_COMPILER_NAMERESOLUTION_STATICSCOPE_HPP
13#define ARK_COMPILER_NAMERESOLUTION_STATICSCOPE_HPP
20#include <unordered_set>
35struct std::hash<
Ark::internal::Declaration>
39 return std::hash<std::string> {}(x.original_name);
55 virtual std::string
add(
const std::string& name,
bool is_mutable);
63 [[nodiscard]]
virtual std::optional<Declaration>
get(
const std::string& name,
bool extensive_lookup);
81 [[nodiscard]]
inline virtual bool withPrefix()
const {
return false; }
82 [[nodiscard]]
inline virtual bool isGlob()
const {
return false; }
83 [[nodiscard]]
inline virtual std::string
prefix()
const {
return ""; }
84 [[nodiscard]]
inline virtual bool hasSymbol(
const std::string&)
const {
return false; }
88 std::unordered_set<Declaration>
m_vars {};
94 NamespaceScope(std::string name,
bool with_prefix,
bool is_glob,
const std::vector<std::string>& symbols);
101 std::string
add(
const std::string& name,
bool is_mutable)
override;
109 [[nodiscard]] std::optional<Declaration>
get(
const std::string& name,
bool extensive_lookup)
override;
137 if (saved_scope->recursiveHasSymbol(symbol))
148 std::unordered_set<Declaration>
m_vars {};
bool recursiveHasSymbol(const std::string &symbol) const override
bool saveNamespace(std::unique_ptr< StaticScope > &) override
Save a namespace scope to help with lookup.
std::string fullyQualifiedName(const std::string &name) const override
Given a Declaration name, compute its fully qualified name.
std::unordered_set< Declaration > m_vars
bool isGlob() const override
bool hasSymbol(const std::string &symbol) const override
std::optional< Declaration > get(const std::string &name, bool extensive_lookup) override
Try to return a Declaration from this scope with a given name.
bool withPrefix() const override
bool isNamespace() const override
NamespaceScope(std::string name, bool with_prefix, bool is_glob, const std::vector< std::string > &symbols)
std::string prefix() const override
std::vector< std::string > m_symbols
std::string add(const std::string &name, bool is_mutable) override
Add a Declaration to the scope, given a mutability status.
std::vector< std::unique_ptr< StaticScope > > m_additional_namespaces
std::unordered_set< Declaration > m_vars
virtual bool withPrefix() const
virtual std::string prefix() const
virtual bool hasSymbol(const std::string &) const
virtual std::optional< Declaration > get(const std::string &name, bool extensive_lookup)
Try to return a Declaration from this scope with a given name.
virtual bool recursiveHasSymbol(const std::string &) const
virtual bool saveNamespace(std::unique_ptr< StaticScope > &)
Save a namespace scope to help with lookup.
virtual bool isNamespace() const
virtual std::string add(const std::string &name, bool is_mutable)
Add a Declaration to the scope, given a mutability status.
virtual ~StaticScope()=default
virtual bool isGlob() const
virtual std::string fullyQualifiedName(const std::string &name) const
Given a Declaration name, compute its fully qualified name.
std::string name
End name, can be modified to be hidden.
std::string original_name
Original name, with the prefix, without hidden namespaces.
bool operator==(const Declaration &other) const =default
size_t operator()(const Ark::internal::Declaration &x) const noexcept