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)
 
 NamespaceScope (const NamespaceScope &)=delete
 
NamespaceScopeoperator= (const NamespaceScope &)=delete
 
 NamespaceScope (NamespaceScope &&)=default
 
NamespaceScopeoperator= (NamespaceScope &&)=default
 
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) override
 
- Public Member Functions inherited from Ark::internal::StaticScope
virtual ~StaticScope ()=default
 
 StaticScope ()=default
 
 StaticScope (const StaticScope &)=delete
 
StaticScopeoperator= (const StaticScope &)=delete
 
 StaticScope (StaticScope &&)=default
 
StaticScopeoperator= (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 99 of file StaticScope.hpp.

Constructor & Destructor Documentation

◆ NamespaceScope() [1/3]

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

Definition at line 38 of file StaticScope.cpp.

◆ NamespaceScope() [2/3]

Ark::internal::NamespaceScope::NamespaceScope ( const NamespaceScope & )
delete

◆ NamespaceScope() [3/3]

Ark::internal::NamespaceScope::NamespaceScope ( NamespaceScope && )
default

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 46 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 111 of file StaticScope.cpp.

References m_namespace.

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

◆ 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 68 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 143 of file StaticScope.hpp.

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

◆ isGlob()

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

Reimplemented from Ark::internal::StaticScope.

Definition at line 141 of file StaticScope.hpp.

Referenced by recursiveHasSymbol().

◆ isNamespace()

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

Reimplemented from Ark::internal::StaticScope.

Definition at line 125 of file StaticScope.cpp.

◆ operator=() [1/2]

NamespaceScope & Ark::internal::NamespaceScope::operator= ( const NamespaceScope & )
delete

◆ operator=() [2/2]

NamespaceScope & Ark::internal::NamespaceScope::operator= ( NamespaceScope && )
default

◆ prefix()

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

Reimplemented from Ark::internal::StaticScope.

Definition at line 142 of file StaticScope.hpp.

◆ recursiveHasSymbol()

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

◆ 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 119 of file StaticScope.cpp.

References m_additional_namespaces.

◆ withPrefix()

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

Reimplemented from Ark::internal::StaticScope.

Definition at line 140 of file StaticScope.hpp.

Member Data Documentation

◆ m_additional_namespaces

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

Definition at line 152 of file StaticScope.hpp.

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

◆ m_is_glob

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

Definition at line 149 of file StaticScope.hpp.

Referenced by add(), and get().

◆ m_namespace

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

Definition at line 147 of file StaticScope.hpp.

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

◆ m_symbols

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

Definition at line 150 of file StaticScope.hpp.

Referenced by add(), and get().

◆ m_vars

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

Definition at line 151 of file StaticScope.hpp.

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

◆ m_with_prefix

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

Definition at line 148 of file StaticScope.hpp.

Referenced by add(), and get().


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