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

A class to handle the VM scope more efficiently. More...

#include <Scope.hpp>

+ Collaboration diagram for Ark::internal::Scope:

Public Member Functions

 Scope () noexcept
 Construct a new Scope object.
 
void push_back (uint16_t id, Value &&val) noexcept
 Put a value in the scope.
 
void push_back (uint16_t id, const Value &val) noexcept
 Put a value in the scope.
 
bool has (uint16_t id) noexcept
 Check if the scope has a specific symbol in memory.
 
Valueoperator[] (uint16_t id) noexcept
 Get a value from its symbol id.
 
uint16_t idFromValue (const Value &val) const noexcept
 Get the id of a variable based on its value ; used for debug only.
 
std::size_t size () const noexcept
 Return the size of the scope.
 

Private Attributes

std::vector< std::pair< uint16_t, Value > > m_data
 

Friends

class Ark::VM
 
class Ark::internal::Closure
 

Detailed Description

A class to handle the VM scope more efficiently.

Definition at line 27 of file Scope.hpp.

Constructor & Destructor Documentation

◆ Scope()

Ark::internal::Scope::Scope ( )
noexcept

Construct a new Scope object.

Definition at line 7 of file Scope.cpp.

References m_data.

Member Function Documentation

◆ has()

bool Ark::internal::Scope::has ( uint16_t  id)
noexcept

Check if the scope has a specific symbol in memory.

Parameters
idThe id of the symbol
Returns
true On success
false Otherwise

Definition at line 22 of file Scope.cpp.

◆ idFromValue()

uint16_t Ark::internal::Scope::idFromValue ( const Value val) const
noexcept

Get the id of a variable based on its value ; used for debug only.

Parameters
val
Returns
uint16_t

Definition at line 37 of file Scope.cpp.

◆ operator[]()

Value * Ark::internal::Scope::operator[] ( uint16_t  id)
noexcept

Get a value from its symbol id.

Parameters
id
Returns
Value* Returns nullptr if the value can not be found

Definition at line 27 of file Scope.cpp.

◆ push_back() [1/2]

void Ark::internal::Scope::push_back ( uint16_t  id,
const Value val 
)
noexcept

Put a value in the scope.

Parameters
idThe symbol id of the variable
valThe value linked to the symbol

Definition at line 17 of file Scope.cpp.

◆ push_back() [2/2]

void Ark::internal::Scope::push_back ( uint16_t  id,
Value &&  val 
)
noexcept

Put a value in the scope.

Parameters
idThe symbol id of the variable
valThe value linked to the symbol

Definition at line 12 of file Scope.cpp.

◆ size()

std::size_t Ark::internal::Scope::size ( ) const
noexcept

Return the size of the scope.

Returns
const std::size_t

Definition at line 47 of file Scope.cpp.

References m_data.

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

Friends And Related Function Documentation

◆ Ark::internal::Closure

friend class Ark::internal::Closure
friend

Definition at line 85 of file Scope.hpp.

◆ Ark::VM

friend class Ark::VM
friend

Definition at line 84 of file Scope.hpp.

Member Data Documentation

◆ m_data

std::vector<std::pair<uint16_t, Value> > Ark::internal::Scope::m_data
private

Definition at line 88 of file Scope.hpp.

Referenced by Ark::VM::backtrace(), Scope(), and size().


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