ArkScript
A small, fast, functional and scripting language for video games
Ark::internal::NamespaceScope Class Referencefinal

#include <StaticScope.hpp>

Inheritance diagram for Ark::internal::NamespaceScope:
[legend]
Collaboration diagram for Ark::internal::NamespaceScope:
[legend]

Public Member Functions

 NamespaceScope (std::string name, bool with_prefix, bool is_glob, const std::vector< std::string > &symbols)
 
std::string add (const std::string &name, bool is_mutable) override
 Add a Declaration to the scope, given a mutability status.
 
std::optional< Declarationget (const std::string &name, bool extensive_lookup) override
 Try to return a Declaration from this scope with a given name.
 
std::string fullyQualifiedName (const std::string &name) const override
 Given a Declaration name, compute its fully qualified name.
 
bool saveNamespace (std::unique_ptr< StaticScope > &) override
 Save a namespace scope to help with lookup.
 
bool isNamespace () const override
 
bool withPrefix () const override
 
bool isGlob () const override
 
std::string prefix () const override
 
bool hasSymbol (const std::string &symbol) const override
 
bool recursiveHasSymbol (const std::string &symbol) const override
 
- Public Member Functions inherited from Ark::internal::StaticScope
virtual ~StaticScope ()=default
 

Private Attributes

std::string m_namespace
 
bool m_with_prefix
 
bool m_is_glob
 
std::vector< std::string > m_symbols
 
std::unordered_set< Declarationm_vars {}
 
std::vector< std::unique_ptr< StaticScope > > m_additional_namespaces
 

Detailed Description

Definition at line 91 of file StaticScope.hpp.

Constructor & Destructor Documentation

◆ NamespaceScope()

Ark::internal::NamespaceScope::NamespaceScope ( std::string name,
bool with_prefix,
bool is_glob,
const std::vector< std::string > & symbols )

Definition at line 37 of file StaticScope.cpp.

Member Function Documentation

◆ add()

std::string Ark::internal::NamespaceScope::add ( const std::string & name,
bool is_mutable )
overridevirtual

Add a Declaration to the scope, given a mutability status.

Parameters
name
is_mutable

Reimplemented from Ark::internal::StaticScope.

Definition at line 45 of file StaticScope.cpp.

References fullyQualifiedName(), hasSymbol(), m_is_glob, m_namespace, m_symbols, m_vars, and m_with_prefix.

◆ fullyQualifiedName()

std::string Ark::internal::NamespaceScope::fullyQualifiedName ( const std::string & name) const
nodiscardoverridevirtual

Given a Declaration name, compute its fully qualified name.

Parameters
name
Returns
std::string fully qualified name in the namespace

Reimplemented from Ark::internal::StaticScope.

Definition at line 104 of file StaticScope.cpp.

References m_namespace.

Referenced by add(), and get().

◆ get()

std::optional< Declaration > Ark::internal::NamespaceScope::get ( const std::string & name,
bool extensive_lookup )
nodiscardoverridevirtual

Try to return a Declaration from this scope with a given name.

Parameters
name
extensive_lookupif true, use the additional saved namespaces
Returns
std::optional<Declaration> std::nullopt if the Declaration isn't in scope

Reimplemented from Ark::internal::StaticScope.

Definition at line 67 of file StaticScope.cpp.

References fullyQualifiedName(), hasSymbol(), m_additional_namespaces, m_is_glob, m_namespace, m_symbols, m_vars, m_with_prefix, Ark::internal::Declaration::name, and Ark::internal::Declaration::original_name.

◆ hasSymbol()

bool Ark::internal::NamespaceScope::hasSymbol ( const std::string & symbol) const
inlinenodiscardoverridevirtual

Reimplemented from Ark::internal::StaticScope.

Definition at line 130 of file StaticScope.hpp.

References m_symbols.

Referenced by add(), get(), and recursiveHasSymbol().

◆ isGlob()

bool Ark::internal::NamespaceScope::isGlob ( ) const
inlinenodiscardoverridevirtual

Reimplemented from Ark::internal::StaticScope.

Definition at line 128 of file StaticScope.hpp.

References m_is_glob.

◆ isNamespace()

bool Ark::internal::NamespaceScope::isNamespace ( ) const
nodiscardoverridevirtual

Reimplemented from Ark::internal::StaticScope.

Definition at line 118 of file StaticScope.cpp.

◆ prefix()

std::string Ark::internal::NamespaceScope::prefix ( ) const
inlinenodiscardoverridevirtual

Reimplemented from Ark::internal::StaticScope.

Definition at line 129 of file StaticScope.hpp.

References m_namespace.

◆ recursiveHasSymbol()

bool Ark::internal::NamespaceScope::recursiveHasSymbol ( const std::string & symbol) const
inlinenodiscardoverridevirtual

Reimplemented from Ark::internal::StaticScope.

Definition at line 131 of file StaticScope.hpp.

References hasSymbol(), and m_additional_namespaces.

◆ saveNamespace()

bool Ark::internal::NamespaceScope::saveNamespace ( std::unique_ptr< StaticScope > & scope)
overridevirtual

Save a namespace scope to help with lookup.

Returns
true if the scope was saved, on NamespaceScope
false on StaticScope

Reimplemented from Ark::internal::StaticScope.

Definition at line 112 of file StaticScope.cpp.

References m_additional_namespaces.

◆ withPrefix()

bool Ark::internal::NamespaceScope::withPrefix ( ) const
inlinenodiscardoverridevirtual

Reimplemented from Ark::internal::StaticScope.

Definition at line 127 of file StaticScope.hpp.

References m_with_prefix.

Member Data Documentation

◆ m_additional_namespaces

std::vector<std::unique_ptr<StaticScope> > Ark::internal::NamespaceScope::m_additional_namespaces
private

Definition at line 149 of file StaticScope.hpp.

Referenced by get(), recursiveHasSymbol(), and saveNamespace().

◆ m_is_glob

bool Ark::internal::NamespaceScope::m_is_glob
private

Definition at line 146 of file StaticScope.hpp.

Referenced by add(), get(), and isGlob().

◆ m_namespace

std::string Ark::internal::NamespaceScope::m_namespace
private

Definition at line 144 of file StaticScope.hpp.

Referenced by add(), fullyQualifiedName(), get(), and prefix().

◆ m_symbols

std::vector<std::string> Ark::internal::NamespaceScope::m_symbols
private

Definition at line 147 of file StaticScope.hpp.

Referenced by add(), get(), and hasSymbol().

◆ m_vars

std::unordered_set<Declaration> Ark::internal::NamespaceScope::m_vars {}
private

Definition at line 148 of file StaticScope.hpp.

Referenced by add(), and get().

◆ m_with_prefix

bool Ark::internal::NamespaceScope::m_with_prefix
private

Definition at line 145 of file StaticScope.hpp.

Referenced by add(), get(), and withPrefix().


The documentation for this class was generated from the following files: