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

#include <Value.hpp>

Public Types

using ProcType = Value (*)(std::vector<Value>&, VM*)
 
using Iterator = std::vector<Value>::iterator
 
using Value_t
 

Public Member Functions

 Value () noexcept
 Construct a new Value object.
 
 Value (ValueType type) noexcept
 Construct a new Value object.
 
template<typename T >
 Value (const ValueType type, T &&value) noexcept
 Construct a new Value object.
 
 Value (int value) noexcept
 
 Value (double value) noexcept
 
 Value (const std::string &value) noexcept
 
 Value (internal::PageAddr_t value) noexcept
 
 Value (ProcType value) noexcept
 
 Value (std::vector< Value > &&value) noexcept
 
 Value (internal::Closure &&value) noexcept
 
 Value (UserType &&value) noexcept
 
 Value (Value *ref) noexcept
 
ValueType valueType () const noexcept
 
bool isFunction () const noexcept
 
bool isIndexable () const noexcept
 
double number () const
 
const std::string & string () const
 
const std::vector< Value > & constList () const
 
const UserTypeusertype () const
 
std::vector< Value > & list ()
 
std::string & stringRef ()
 
UserTypeusertypeRef ()
 
Valuereference () const
 
void push_back (const Value &value)
 Add an element to the list held by the value (if the value type is set to list)
 
void push_back (Value &&value)
 Add an element to the list held by the value (if the value type is set to list)
 
std::string toString (VM &vm) const noexcept
 

Private Member Functions

constexpr uint8_t typeNum () const noexcept
 
internal::PageAddr_t pageAddr () const
 
const ProcTypeproc () const
 
const internal::Closureclosure () const
 
internal::ClosurerefClosure ()
 

Private Attributes

ValueType m_type
 
Value_t m_value
 

Friends

class Ark::VM
 
class Ark::BytecodeReader
 
ARK_API_INLINE bool operator== (const Value &A, const Value &B)
 
ARK_API_INLINE bool operator< (const Value &A, const Value &B)
 
ARK_API_INLINE bool operator! (const Value &A)
 

Detailed Description

Definition at line 59 of file Value.hpp.

Member Typedef Documentation

◆ Iterator

using Ark::Value::Iterator = std::vector<Value>::iterator

Definition at line 63 of file Value.hpp.

◆ ProcType

using Ark::Value::ProcType = Value (*)(std::vector<Value>&, VM*)

Definition at line 62 of file Value.hpp.

◆ Value_t

Initial value:
std::variant<
double,
std::string,
internal::Closure,
UserType,
std::vector<Value>,
>
Value(*)(std::vector< Value > &, VM *) ProcType
Definition Value.hpp:62
Value() noexcept
Construct a new Value object.
Definition Value.cpp:8
uint16_t PageAddr_t
Definition Closure.hpp:30

Definition at line 65 of file Value.hpp.

Constructor & Destructor Documentation

◆ Value() [1/12]

Ark::Value::Value ( )
noexcept

Construct a new Value object.

Definition at line 8 of file Value.cpp.

◆ Value() [2/12]

Ark::Value::Value ( ValueType type)
explicitnoexcept

Construct a new Value object.

Parameters
typethe value type which is going to be held

Definition at line 12 of file Value.cpp.

References Ark::List, and Ark::String.

◆ Value() [3/12]

template<typename T >
Ark::Value::Value ( const ValueType type,
T && value )
inlinenoexcept

Construct a new Value object.

Use at your own risks. Asking for a value type N and putting a non-matching value will result in errors at runtime.

Template Parameters
T
Parameters
typevalue type wanted
valuevalue needed

Definition at line 100 of file Value.hpp.

◆ Value() [4/12]

Ark::Value::Value ( int value)
explicitnoexcept

Definition at line 21 of file Value.cpp.

◆ Value() [5/12]

Ark::Value::Value ( double value)
explicitnoexcept

Definition at line 25 of file Value.cpp.

◆ Value() [6/12]

Ark::Value::Value ( const std::string & value)
explicitnoexcept

Definition at line 29 of file Value.cpp.

◆ Value() [7/12]

Ark::Value::Value ( internal::PageAddr_t value)
explicitnoexcept

Definition at line 33 of file Value.cpp.

◆ Value() [8/12]

Ark::Value::Value ( Value::ProcType value)
explicitnoexcept

Definition at line 37 of file Value.cpp.

◆ Value() [9/12]

Ark::Value::Value ( std::vector< Value > && value)
explicitnoexcept

Definition at line 41 of file Value.cpp.

◆ Value() [10/12]

Ark::Value::Value ( internal::Closure && value)
explicitnoexcept

Definition at line 45 of file Value.cpp.

◆ Value() [11/12]

Ark::Value::Value ( UserType && value)
explicitnoexcept

Definition at line 49 of file Value.cpp.

◆ Value() [12/12]

Ark::Value::Value ( Value * ref)
explicitnoexcept

Definition at line 53 of file Value.cpp.

Member Function Documentation

◆ closure()

const internal::Closure & Ark::Value::closure ( ) const
inlinenodiscardprivate

Definition at line 165 of file Value.hpp.

◆ constList()

const std::vector< Value > & Ark::Value::constList ( ) const
inlinenodiscard

Definition at line 127 of file Value.hpp.

Referenced by Ark::helper::head(), Ark::VM::safeRun(), and Ark::helper::tail().

◆ isFunction()

bool Ark::Value::isFunction ( ) const
inlinenodiscardnoexcept

Definition at line 115 of file Value.hpp.

◆ isIndexable()

bool Ark::Value::isIndexable ( ) const
inlinenodiscardnoexcept

Definition at line 120 of file Value.hpp.

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

◆ list()

std::vector< Value > & Ark::Value::list ( )
inlinenodiscard

Definition at line 129 of file Value.hpp.

Referenced by push_back(), push_back(), Ark::VM::safeRun(), and Ark::State::setArgs().

◆ number()

double Ark::Value::number ( ) const
inlinenodiscard

Definition at line 125 of file Value.hpp.

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

◆ pageAddr()

internal::PageAddr_t Ark::Value::pageAddr ( ) const
inlinenodiscardprivate

Definition at line 163 of file Value.hpp.

Referenced by Ark::VM::backtrace(), and Ark::VM::safeRun().

◆ proc()

const ProcType & Ark::Value::proc ( ) const
inlinenodiscardprivate

Definition at line 164 of file Value.hpp.

◆ push_back() [1/2]

void Ark::Value::push_back ( const Value & value)

Add an element to the list held by the value (if the value type is set to list)

Parameters
value

Definition at line 57 of file Value.cpp.

References list().

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

◆ push_back() [2/2]

void Ark::Value::push_back ( Value && value)

Add an element to the list held by the value (if the value type is set to list)

Parameters
value

Definition at line 62 of file Value.cpp.

References list().

◆ refClosure()

internal::Closure & Ark::Value::refClosure ( )
inlinenodiscardprivate

Definition at line 166 of file Value.hpp.

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

◆ reference()

Value * Ark::Value::reference ( ) const
inlinenodiscard

Definition at line 132 of file Value.hpp.

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

◆ string()

const std::string & Ark::Value::string ( ) const
inlinenodiscard

Definition at line 126 of file Value.hpp.

Referenced by Ark::helper::head(), Ark::VM::safeRun(), and Ark::helper::tail().

◆ stringRef()

std::string & Ark::Value::stringRef ( )
inlinenodiscard

Definition at line 130 of file Value.hpp.

Referenced by Ark::helper::head(), Ark::VM::safeRun(), and Ark::helper::tail().

◆ toString()

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

◆ typeNum()

uint8_t Ark::Value::typeNum ( ) const
inlinenodiscardconstexprprivatenoexcept

Definition at line 161 of file Value.hpp.

◆ usertype()

const UserType & Ark::Value::usertype ( ) const
inlinenodiscard

Definition at line 128 of file Value.hpp.

◆ usertypeRef()

UserType & Ark::Value::usertypeRef ( )
inlinenodiscard

Definition at line 131 of file Value.hpp.

◆ valueType()

ValueType Ark::Value::valueType ( ) const
inlinenodiscardnoexcept

Friends And Related Symbol Documentation

◆ Ark::BytecodeReader

friend class Ark::BytecodeReader
friend

Definition at line 155 of file Value.hpp.

◆ Ark::VM

friend class Ark::VM
friend

Definition at line 154 of file Value.hpp.

◆ operator!

ARK_API_INLINE bool operator! ( const Value & A)
friend

Definition at line 193 of file Value.hpp.

◆ operator<

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

Definition at line 181 of file Value.hpp.

◆ operator==

ARK_API_INLINE bool operator== ( const Value & A,
const Value & B )
friend

Definition at line 169 of file Value.hpp.

Member Data Documentation

◆ m_type

ValueType Ark::Value::m_type
private

Definition at line 158 of file Value.hpp.

◆ m_value

Value_t Ark::Value::m_value
private

Definition at line 159 of file Value.hpp.


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