11 m_vars.emplace(name, name, is_mutable);
15 std::optional<Declaration>
StaticScope::get(
const std::string& name, [[maybe_unused]]
const bool extensive_lookup)
40 m_namespace(std::move(name)),
41 m_with_prefix(with_prefix),
50 if (name.ends_with(
"#hidden"))
52 std::string std_name = name.substr(0, name.find_first_of(
'#'));
53 return m_vars.emplace(name, std_name, is_mutable).first->name;
61 std::string unprefixed_name = starts_with_prefix ? name.substr(name.find_first_of(
':') + 1) : name;
64 return m_vars.emplace(fqn +
"#hidden", fqn, is_mutable).first->name;
65 return m_vars.emplace(fqn, fqn, is_mutable).first->name;
83 else if (!starts_with_prefix)
95 std::optional<Declaration> decl;
98 if (
auto maybe_decl = scope->get(name, extensive_lookup); maybe_decl.has_value())
101 if ((decl.has_value() && decl.value().name.ends_with(
"#hidden")) || !decl.has_value())
137 return std::ranges::any_of(
139 [&symbol](
const auto& saved_scope) {
140 return saved_scope->recursiveHasSymbol(symbol);
Static scopes (for functions, loops) and namespace scopes (for packages) definitions,...
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 isNamespace() const override
NamespaceScope(std::string name, bool with_prefix, bool is_glob, const std::vector< std::string > &symbols)
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
bool recursiveHasSymbol(const std::string &symbol) override
std::unordered_set< Declaration > m_vars
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 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 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.