![]() |
Phasor 2.2.0
Stack VM based Programming Language
|
A value in the Phasor VM. More...
#include <Value.hpp>
Classes | |
| struct | StructInstance |
Public Types | |
| using | ArrayInstance = std::vector<Value> |
Public Member Functions | |
| Value () | |
| Default constructor. | |
| Value (bool b) | |
| Boolean constructor. | |
| Value (int64_t i) | |
| Integer constructor. | |
| Value (int i) | |
| Integer constructor. | |
| Value (double d) | |
| Double constructor. | |
| Value (const std::string &s) | |
| String constructor. | |
| Value (const char *s) | |
| String constructor. | |
| Value (std::shared_ptr< StructInstance > s) | |
| Struct constructor. | |
| Value (std::shared_ptr< ArrayInstance > a) | |
| Array constructor. | |
| ValueType | getType () const |
| Get the type of the value. | |
| bool | isNull () const |
| Check if the value is null. | |
| bool | isBool () const |
| Check if the value is a boolean. | |
| bool | isInt () const |
| Check if the value is an integer. | |
| bool | isFloat () const |
| Check if the value is a double. | |
| bool | isString () const |
| Check if the value is a string. | |
| bool | isNumber () const |
| Check if the value is a number. | |
| bool | isArray () const |
| Check if the value is an array. | |
| bool | asBool () const |
| Get the value as a boolean. | |
| int64_t | asInt () const |
| Get the value as an integer. | |
| double | asFloat () const |
| Get the value as a double. | |
| std::string | asString () const |
| Get the value as a string. | |
| std::shared_ptr< ArrayInstance > | asArray () |
| Get the value as an array. | |
| const std::shared_ptr< const ArrayInstance > | asArray () const |
| Get the value as an array (const). | |
| Value | operator+ (const Value &other) const |
| Add two values. | |
| Value | operator- (const Value &other) const |
| Subtract two values. | |
| Value | operator* (const Value &other) const |
| Multiply two values. | |
| Value | operator/ (const Value &other) const |
| Divide two values. | |
| Value | operator% (const Value &other) const |
| Modulo two values. | |
| Value | operator- () const |
| Unary negation. | |
| Value | operator! () const |
| Logical negation. | |
| Value | logicalAnd (const Value &other) const |
| Logical AND. | |
| Value | logicalOr (const Value &other) const |
| Logical OR. | |
| bool | isTruthy () const |
| Helper to determine truthiness. | |
| bool | operator== (const Value &other) const |
| Comparison operations. | |
| bool | operator!= (const Value &other) const |
| Inequality comparison. | |
| bool | operator< (const Value &other) const |
| Less than comparison. | |
| bool | operator> (const Value &other) const |
| Greater than comparison. | |
| bool | operator<= (const Value &other) const |
| Less than or equal to comparison. | |
| bool | operator>= (const Value &other) const |
| Greater than or equal to comparison. | |
| std::string | toString () const |
| Convert to string for printing. | |
| const char * | c_str () const |
| Convert to C Style String. | |
| bool | isStruct () const |
| std::shared_ptr< StructInstance > | asStruct () |
| const std::shared_ptr< const StructInstance > | asStruct () const |
| Value | getField (const std::string &name) const |
| void | setField (const std::string &name, Value value) |
| bool | hasField (const std::string &name) const |
Static Public Member Functions | |
| static Value | createStruct (const std::string &name) |
| static Value | createArray (std::vector< Value > elements={}) |
Private Types | |
| using | DataType |
Private Attributes | |
| DataType | data |
Friends | |
| std::ostream & | operator<< (std::ostream &os, const Value &v) |
| Print to output stream. | |
Uses std::variant for type-safe union
| using Phasor::Value::ArrayInstance = std::vector<Value> |
|
private |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inlinestatic |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
friend |