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

Closure management. More...

#include <Closure.hpp>

Collaboration diagram for Ark::internal::Closure:
[legend]

Public Member Functions

 Closure (const Scope &scope, PageAddr_t pa) noexcept
 Construct a new Closure object.
 
 Closure (const std::shared_ptr< Scope > &scope_ptr, PageAddr_t pa) noexcept
 Construct a new Closure object.
 
const Scopescope () const noexcept
 
ScoperefScope () const noexcept
 
const std::shared_ptr< Scope > & scopePtr () const
 
PageAddr_t pageAddr () const
 
bool hasFieldEndingWith (const std::string &end, VM &vm) const
 Used when generating error messages in the VM, to see if a symbol might have been wrongly fully qualified.
 
std::string toString (VM &vm) const noexcept
 Print the closure to a string.
 

Private Attributes

std::shared_ptr< Scopem_scope
 
PageAddr_t m_page_addr
 

Friends

ARK_API bool operator== (const Closure &A, const Closure &B)
 
ARK_API_INLINE bool operator< (const Closure &A, const Closure &B)
 

Detailed Description

Closure management.

Definition at line 36 of file Closure.hpp.

Constructor & Destructor Documentation

◆ Closure() [1/2]

Ark::internal::Closure::Closure ( const Scope & scope,
PageAddr_t pa )
noexcept

Construct a new Closure object.

Parameters
scopethe scope of the function turned into a closure
pathe current page address of the function turned into a closure

Definition at line 11 of file Closure.cpp.

◆ Closure() [2/2]

Ark::internal::Closure::Closure ( const std::shared_ptr< Scope > & scope_ptr,
PageAddr_t pa )
noexcept

Construct a new Closure object.

Parameters
scope_ptra shared pointer to the scope of the function turned into a closure
pathe current page address of the function turned into a closure

Definition at line 16 of file Closure.cpp.

Member Function Documentation

◆ hasFieldEndingWith()

bool Ark::internal::Closure::hasFieldEndingWith ( const std::string & end,
VM & vm ) const
nodiscard

Used when generating error messages in the VM, to see if a symbol might have been wrongly fully qualified.

Parameters
end
vm
Returns
true if the closure has a field which is the end of 'end'

Definition at line 21 of file Closure.cpp.

References m_scope, Ark::VM::m_state, and Ark::State::m_symbols.

Referenced by Ark::VM::safeRun().

◆ pageAddr()

PageAddr_t Ark::internal::Closure::pageAddr ( ) const
inlinenodiscard
Returns
PageAddr_t the bytecode page address this closure refers to

Definition at line 62 of file Closure.hpp.

References m_page_addr.

◆ refScope()

Scope & Ark::internal::Closure::refScope ( ) const
inlinenodiscardnoexcept

Definition at line 55 of file Closure.hpp.

References m_scope.

Referenced by Ark::VM::safeRun().

◆ scope()

const Scope & Ark::internal::Closure::scope ( ) const
inlinenodiscardnoexcept

Definition at line 54 of file Closure.hpp.

References m_scope.

◆ scopePtr()

const std::shared_ptr< Scope > & Ark::internal::Closure::scopePtr ( ) const
inlinenodiscard

Definition at line 56 of file Closure.hpp.

References m_scope.

Referenced by Ark::VM::safeRun().

◆ toString()

std::string Ark::internal::Closure::toString ( VM & vm) const
noexcept

Print the closure to a string.

Parameters
vm

Definition at line 31 of file Closure.cpp.

Referenced by Ark::VM::safeRun().

Friends And Related Symbol Documentation

◆ operator<

ARK_API_INLINE bool operator< ( const Closure & A,
const Closure & B )
friend

Definition at line 89 of file Closure.hpp.

◆ operator==

ARK_API bool operator== ( const Closure & A,
const Closure & B )
friend

Definition at line 45 of file Closure.cpp.

Member Data Documentation

◆ m_page_addr

PageAddr_t Ark::internal::Closure::m_page_addr
private

Definition at line 86 of file Closure.hpp.

Referenced by pageAddr().

◆ m_scope

std::shared_ptr<Scope> Ark::internal::Closure::m_scope
private

Definition at line 84 of file Closure.hpp.

Referenced by hasFieldEndingWith(), refScope(), scope(), and scopePtr().


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