10 m_vars.emplace(name, name, is_mutable);
14 std::optional<Declaration>
StaticScope::get(
const std::string& name, [[maybe_unused]]
const bool extensive_lookup)
39 m_namespace(std::move(name)),
40 m_with_prefix(with_prefix),
49 if (name.ends_with(
"#hidden"))
51 std::string std_name = name.substr(0, name.find_first_of(
'#'));
52 return m_vars.emplace(name, std_name, is_mutable).first->name;
60 std::string unprefixed_name = starts_with_prefix ? name.substr(name.find_first_of(
':') + 1) : name;
63 return m_vars.emplace(fqn +
"#hidden", fqn, is_mutable).first->name;
64 return m_vars.emplace(fqn, fqn, is_mutable).first->name;
82 else if (!starts_with_prefix)
96 if (
auto maybe_decl = scope->get(name, extensive_lookup); maybe_decl.has_value())
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 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
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.