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

#include <Value.hpp>

Public Types

using Number_t = double
 
using String_t = std::string
 
using List_t = std::vector<Value>
 
using Ref_t = Value*
 
using Dict_t = internal::Dict
 
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 String_t &value) noexcept
 
 Value (const char *value) noexcept
 
 Value (internal::PageAddr_t value) noexcept
 
 Value (Procedure &&value) noexcept
 
 Value (List_t &&value) noexcept
 
 Value (internal::Closure &&value) noexcept
 
 Value (UserType &&value) noexcept
 
 Value (Dict_t &&value) noexcept
 
 Value (Ref_t ref) noexcept
 
ValueType valueType () const noexcept
 
bool isFunction () const noexcept
 
bool isIndexable () const noexcept
 
Number_t number () const
 
const String_tstring () const
 
String_tstringRef ()
 
const List_tconstList () const
 
List_tlist ()
 
const UserTypeusertype () const
 
UserTypeusertypeRef ()
 
const Dict_tdict () const
 
Dict_tdictRef ()
 
Ref_t reference () 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
 
struct std::hash< Ark::Value >
 
ARK_API 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 90 of file Value.hpp.

Member Typedef Documentation

◆ Dict_t

Definition at line 97 of file Value.hpp.

◆ List_t

using Ark::Value::List_t = std::vector<Value>

Definition at line 95 of file Value.hpp.

◆ Number_t

using Ark::Value::Number_t = double

Definition at line 93 of file Value.hpp.

◆ Ref_t

Definition at line 96 of file Value.hpp.

◆ String_t

using Ark::Value::String_t = std::string

Definition at line 94 of file Value.hpp.

◆ Value_t

Initial value:
std::variant<
Procedure,
internal::Closure,
UserType,
std::shared_ptr<Dict_t>,
>
std::string String_t
Definition Value.hpp:94
double Number_t
Definition Value.hpp:93
Value * Ref_t
Definition Value.hpp:96
std::vector< Value > List_t
Definition Value.hpp:95
uint16_t PageAddr_t
Definition Closure.hpp:26

Definition at line 99 of file Value.hpp.

Constructor & Destructor Documentation

◆ Value() [1/14]

Ark::Value::Value ( )
noexcept

Construct a new Value object.

Definition at line 10 of file Value.cpp.

◆ Value() [2/14]

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

Construct a new Value object.

Parameters
typethe value type which is going to be held

Definition at line 14 of file Value.cpp.

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

◆ Value() [3/14]

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

◆ Value() [4/14]

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

Definition at line 23 of file Value.cpp.

◆ Value() [5/14]

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

Definition at line 27 of file Value.cpp.

◆ Value() [6/14]

Ark::Value::Value ( const String_t & value)
explicitnoexcept

Definition at line 31 of file Value.cpp.

◆ Value() [7/14]

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

Definition at line 35 of file Value.cpp.

◆ Value() [8/14]

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

Definition at line 39 of file Value.cpp.

◆ Value() [9/14]

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

Definition at line 43 of file Value.cpp.

◆ Value() [10/14]

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

Definition at line 47 of file Value.cpp.

◆ Value() [11/14]

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

Definition at line 51 of file Value.cpp.

◆ Value() [12/14]

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

Definition at line 55 of file Value.cpp.

◆ Value() [13/14]

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

Definition at line 59 of file Value.cpp.

◆ Value() [14/14]

Ark::Value::Value ( Ref_t ref)
explicitnoexcept

Definition at line 63 of file Value.cpp.

Member Function Documentation

◆ closure()

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

Definition at line 211 of file Value.hpp.

◆ constList()

const List_t & Ark::Value::constList ( ) const
inlinenodiscard

Definition at line 168 of file Value.hpp.

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

◆ dict()

const Dict_t & Ark::Value::dict ( ) const
inlinenodiscard

Definition at line 174 of file Value.hpp.

◆ dictRef()

Dict_t & Ark::Value::dictRef ( )
inlinenodiscard

Definition at line 175 of file Value.hpp.

◆ isFunction()

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

Definition at line 152 of file Value.hpp.

◆ isIndexable()

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

Definition at line 157 of file Value.hpp.

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

◆ list()

List_t & Ark::Value::list ( )
inlinenodiscard

◆ number()

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

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

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

◆ proc()

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

Definition at line 210 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 67 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 72 of file Value.cpp.

References list().

◆ refClosure()

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

Definition at line 212 of file Value.hpp.

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

◆ reference()

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

Definition at line 177 of file Value.hpp.

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

◆ string()

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

◆ stringRef()

String_t & Ark::Value::stringRef ( )
inlinenodiscard

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

◆ usertype()

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

Definition at line 171 of file Value.hpp.

◆ usertypeRef()

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

Definition at line 172 of file Value.hpp.

◆ valueType()

Friends And Related Symbol Documentation

◆ Ark::BytecodeReader

friend class Ark::BytecodeReader
friend

Definition at line 200 of file Value.hpp.

◆ Ark::VM

friend class Ark::VM
friend

Definition at line 199 of file Value.hpp.

◆ operator!

ARK_API_INLINE bool operator! ( const Value & A)
friend

Definition at line 227 of file Value.hpp.

◆ operator<

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

Definition at line 215 of file Value.hpp.

◆ operator==

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

Definition at line 142 of file Value.cpp.

◆ std::hash< Ark::Value >

friend struct std::hash< Ark::Value >
friend

Definition at line 200 of file Value.hpp.

Member Data Documentation

◆ m_type

ValueType Ark::Value::m_type
private

Definition at line 204 of file Value.hpp.

◆ m_value

Value_t Ark::Value::m_value
private

Definition at line 205 of file Value.hpp.


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