ArkScript
A small, lisp-inspired, functional scripting language
Ark::Value Class Reference

#include <Value.hpp>

Public Types

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 (const char *value) noexcept
 
 Value (internal::PageAddr_t value) noexcept
 
 Value (Procedure &&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 Procedureproc () 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 69 of file Value.hpp.

Member Typedef Documentation

◆ Iterator

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

Definition at line 72 of file Value.hpp.

◆ Value_t

Initial value:
std::variant<
double,
std::string,
Procedure,
internal::Closure,
UserType,
std::vector<Value>,
>
Value() noexcept
Construct a new Value object.
Definition Value.cpp:9
uint16_t PageAddr_t
Definition Closure.hpp:27

Definition at line 74 of file Value.hpp.

Constructor & Destructor Documentation

◆ Value() [1/13]

Ark::Value::Value ( )
noexcept

Construct a new Value object.

Definition at line 9 of file Value.cpp.

◆ Value() [2/13]

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

Construct a new Value object.

Parameters
typethe value type which is going to be held

Definition at line 13 of file Value.cpp.

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

◆ Value() [3/13]

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 109 of file Value.hpp.

◆ Value() [4/13]

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

Definition at line 22 of file Value.cpp.

◆ Value() [5/13]

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

Definition at line 26 of file Value.cpp.

◆ Value() [6/13]

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

Definition at line 30 of file Value.cpp.

◆ Value() [7/13]

Ark::Value::Value ( const char * value)
explicitnoexcept

Definition at line 34 of file Value.cpp.

◆ Value() [8/13]

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

Definition at line 38 of file Value.cpp.

◆ Value() [9/13]

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

Definition at line 42 of file Value.cpp.

◆ Value() [10/13]

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

Definition at line 46 of file Value.cpp.

◆ Value() [11/13]

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

Definition at line 50 of file Value.cpp.

◆ Value() [12/13]

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

Definition at line 54 of file Value.cpp.

◆ Value() [13/13]

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

Definition at line 58 of file Value.cpp.

Member Function Documentation

◆ closure()

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

Definition at line 175 of file Value.hpp.

◆ constList()

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

Definition at line 137 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 125 of file Value.hpp.

◆ isIndexable()

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

Definition at line 130 of file Value.hpp.

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

◆ list()

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

◆ number()

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

Definition at line 135 of file Value.hpp.

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

◆ pageAddr()

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

Definition at line 173 of file Value.hpp.

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

◆ proc()

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

Definition at line 174 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 62 of file Value.cpp.

References list().

Referenced by Ark::VM::createList(), and Ark::VM::listAppendInPlace().

◆ 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 67 of file Value.cpp.

References list().

◆ refClosure()

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

Definition at line 176 of file Value.hpp.

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

◆ reference()

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

Definition at line 142 of file Value.hpp.

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

◆ string()

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

◆ stringRef()

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

Definition at line 140 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 171 of file Value.hpp.

◆ usertype()

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

Definition at line 138 of file Value.hpp.

◆ usertypeRef()

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

Definition at line 141 of file Value.hpp.

◆ valueType()

Friends And Related Symbol Documentation

◆ Ark::BytecodeReader

friend class Ark::BytecodeReader
friend

Definition at line 165 of file Value.hpp.

◆ Ark::VM

friend class Ark::VM
friend

Definition at line 164 of file Value.hpp.

◆ operator!

ARK_API_INLINE bool operator! ( const Value & A)
friend

Definition at line 203 of file Value.hpp.

◆ operator<

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

Definition at line 191 of file Value.hpp.

◆ operator==

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

Definition at line 179 of file Value.hpp.

Member Data Documentation

◆ m_type

ValueType Ark::Value::m_type
private

Definition at line 168 of file Value.hpp.

◆ m_value

Value_t Ark::Value::m_value
private

Definition at line 169 of file Value.hpp.


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