ArkScript
A small, fast, functional and scripting language for video games
|
#include <Value.hpp>
Public Types | |
using | ProcType = Value(*)(std::vector< Value > &, VM *) |
using | Iterator = std::vector< Value >::iterator |
using | ConstIterator = std::vector< Value >::const_iterator |
using | Value_t = std::variant< double, String, internal::PageAddr_t, ProcType, internal::Closure, UserType, std::vector< Value >, Value * > |
Public Member Functions | |
Value () noexcept | |
Construct a new Value object. | |
Value (ValueType type) noexcept | |
Construct a new Value object. | |
template<typename T > | |
Value (ValueType type, T &&value) noexcept | |
Construct a new Value object. | |
Value (int value) noexcept | |
Construct a new Value object as a Number. | |
Value (float value) noexcept | |
Construct a new Value object as a Number. | |
Value (double value) noexcept | |
Construct a new Value object as a Number. | |
Value (const std::string &value) noexcept | |
Construct a new Value object as a String. | |
Value (const String &value) noexcept | |
Construct a new Value object as a String. | |
Value (const char *value) noexcept | |
Construct a new Value object as a String. | |
Value (internal::PageAddr_t value) noexcept | |
Construct a new Value object as a Function. | |
Value (Value::ProcType value) noexcept | |
Construct a new Value object from a C++ function. | |
Value (std::vector< Value > &&value) noexcept | |
Construct a new Value object as a List. | |
Value (internal::Closure &&value) noexcept | |
Construct a new Value object as a Closure. | |
Value (UserType &&value) noexcept | |
Construct a new Value object as a UserType. | |
Value (Value *ref) noexcept | |
Construct a new Value object as a reference to an internal object. | |
ValueType | valueType () const noexcept |
Return the value type. | |
bool | isFunction () const noexcept |
Check if a function is held. | |
double | number () const |
Return the stored number. | |
const String & | string () const |
Return the stored string. | |
const std::vector< Value > & | constList () const |
Return the stored list. | |
const UserType & | usertype () const |
Return the stored user type. | |
std::vector< Value > & | list () |
Return the stored list as a reference. | |
String & | stringRef () |
Return the stored string as a reference. | |
UserType & | usertypeRef () |
Return the stored user type as a reference. | |
Value * | reference () const |
Return the stored internal object reference. | |
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) | |
void | toString (std::ostream &os, VM &vm) const noexcept |
Private Member Functions | |
internal::PageAddr_t | pageAddr () const |
Return the page address held by the value. | |
const ProcType & | proc () const |
Return the C Function held by the value. | |
const internal::Closure & | closure () const |
Return the closure held by the value. | |
internal::Closure & | refClosure () |
Return a reference to the closure held by the value. | |
bool | isConst () const noexcept |
Check if the value is const or not. | |
void | setConst (bool value) noexcept |
Set the Const object. | |
Private Attributes | |
uint8_t | m_const_type |
First bit if for constness, right most bits are for type. | |
Value_t | m_value |
Friends | |
class | Ark::VM |
ARK_API_INLINE bool | operator== (const Value &A, const Value &B) noexcept |
ARK_API_INLINE bool | operator< (const Value &A, const Value &B) noexcept |
ARK_API_INLINE bool | operator! (const Value &A) noexcept |
using Ark::Value::ConstIterator = std::vector<Value>::const_iterator |
using Ark::Value::Iterator = std::vector<Value>::iterator |
using Ark::Value::ProcType = Value (*)(std::vector<Value>&, VM*) |
using Ark::Value::Value_t = std::variant< double, String, internal::PageAddr_t, ProcType, internal::Closure, UserType, std::vector<Value>, Value* > |
|
noexcept |
|
explicitnoexcept |
Construct a new Value object.
type | the value type which is going to be held |
Definition at line 15 of file Value.cpp.
References Ark::List, and Ark::String.
|
inlinenoexcept |
|
explicitnoexcept |
|
explicitnoexcept |
|
explicitnoexcept |
|
explicitnoexcept |
|
explicitnoexcept |
|
explicitnoexcept |
|
explicitnoexcept |
|
explicitnoexcept |
|
explicitnoexcept |
|
explicitnoexcept |
|
explicitnoexcept |
|
explicitnoexcept |
|
inlineprivate |
Return the closure held by the value.
|
inline |
|
inlineprivatenoexcept |
|
inlinenoexcept |
Check if a function is held.
std::vector< Value > & Ark::Value::list | ( | ) |
Return the stored list as a reference.
Definition at line 112 of file Value.cpp.
References m_value.
Referenced by push_back(), and Ark::VM::safeRun().
|
inline |
|
inlineprivate |
Return the page address held by the value.
Referenced by Ark::VM::backtrace(), and Ark::VM::safeRun().
|
inlineprivate |
Return the C Function held by the value.
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)
value |
Definition at line 139 of file Value.cpp.
References list().
Referenced by Ark::VM::safeRun(), and Ark::State::setArgs().
void Ark::Value::push_back | ( | Value && | value | ) |
|
private |
Return a reference to the closure held by the value.
Definition at line 117 of file Value.cpp.
References m_value.
Referenced by Ark::VM::safeRun().
Value * Ark::Value::reference | ( | ) | const |
Return the stored internal object reference.
Definition at line 132 of file Value.cpp.
References m_value.
Referenced by Ark::VM::safeRun().
|
inlineprivatenoexcept |
|
inline |
String & Ark::Value::stringRef | ( | ) |
Return the stored string as a reference.
Definition at line 122 of file Value.cpp.
References m_value.
Referenced by Ark::VM::safeRun().
|
noexcept |
Definition at line 150 of file Value.cpp.
References Ark::Closure, Ark::CProc, Ark::Utils::decPlaces(), Ark::Utils::digPlaces(), Ark::False, Ark::InstPtr, Ark::List, Ark::Nil, Ark::Number, Ark::PageAddr, Ark::Reference, Ark::String, Ark::True, Ark::Undefined, and Ark::User.
Referenced by Ark::VM::safeRun().
|
inline |
Return the stored user type.
UserType & Ark::Value::usertypeRef | ( | ) |
|
inlinenoexcept |
|
friend |
|
friend |
|
friend |
|
private |
|
private |
Definition at line 302 of file Value.hpp.
Referenced by list(), refClosure(), reference(), stringRef(), and usertypeRef().