RValue
This class acts as a proxy for the internal RValue class in YYC.
type
Type: int
The type of this RValue. Possible values are as follows:
const int VALUE_REAL = 0; // Real value
const int VALUE_STRING = 1; // String value
const int VALUE_ARRAY = 2; // Array value
const int VALUE_PTR = 3; // Ptr value
const int VALUE_VEC3 = 4; // Deprecated : unused : Vec3 (x,y,z)
const int VALUE_UNDEFINED = 5; // Undefined value
const int VALUE_OBJECT = 6; // YYObjectBase* value
const int VALUE_INT32 = 7; // Int32 value
const int VALUE_VEC4 = 8; // Deprecated : unused : Vec4 (x,y,z,w)
const int VALUE_VEC44 = 9; // Deprecated : unused : Vec44 (matrix)
const int VALUE_INT64 = 10; // Int64 value
const int VALUE_ACCESSOR = 11; // Actually an accessor
const int VALUE_NULL = 12; // JS Null
const int VALUE_BOOL = 13; // Bool value
const int VALUE_ITERATOR = 14; // JS For-in Iterator
const int VALUE_REF = 15; // Reference value
const int VALUE_UNSET = 0x0ffffff;
toBool
Converts the RValue to a bool. Internally the same as checking if the value is not equal to zero.
Arguments
None
Returns
Type | Description |
---|---|
| The value of the RValue as a bool. |
toString
Gets the value of a VALUE_STRING
RValue.
Arguments
None
Returns
Type | Description |
---|---|
| The value of the string RValue. |
toReal
Gets the value of a VALUE_REAL
RValue.
Arguments
None
Returns
Type | Description |
---|---|
| The value of the real RValue. |
stringify
Turns an RValue of (almost) any type to a string. Useful for printing.
Arguments
None
Returns
Type | Description |
---|---|
| The value of the RValue as a string. |
__add, __sub, __mul, __div
This type also supports arithmetic operations such as +, -, * and /.
Examples
local val = RValue(10)
local val2 = RValue(10)
local result = val + val2
print(result:toReal()) -- Prints: 20
local val = RValue("hello, ")
local val2 = RValue("world!")
local result = val + val2
print(result:toString()) -- Prints: hello, world!
local val = RValue("hello, world! ")
local val2 = RValue(2)
local result = val * val2
print(result:toString()) -- Prints: hello, world! hello, world!
Last modified: 29 March 2025