Skip to content

CandleVM Values ​

Values are the data types used by the virutal machine to represent values manipulated during program execution. Each value has a specific type and an associated data representation, which determines how it is stored and interpreted by the virtual machine.

Encoding ​

To encode a Value, write its type discriminator first as an unsigned 8-bit integer (u8), followed by the data held by the value, if any. Null has no associated data, so only its type discriminator is written.

Value types ​

Null ​

Null value represents the absence of value. It does not hold any data.

Its type discriminator is 0.

Byte ​

Byte represents an unsigned 8-bit integer (u8).

Its type discriminator is 1.

Number ​

Number represents a 64-bit floating-point value (f64). It holds an unsigned 64-bit integer (u64) bit representation of its floating-point value.

Its type discriminator is 2.

Bool ​

Bool represents a boolean value. It holds an unsigned 8-bit integer (u8) representing its value: 0 represents false, while any other value is interpreted as true.

Its type discriminator is 3.

Char ​

Char represents a character. It holds an unsigned 32-bit integer (u32) representing its Unicode scalar value (char).

Its type discriminator is 4.

ModuleRef Not serializable ​

ModuleRef represents a reference to a Candle module. It holds an unsigned 16-bit integer (u16) representing its module id.

Its type discriminator is 5.

FunctionRef Not serializable ​

FunctionRef represents a reference to a Candle function. It holds two consecutive unsigned 16-bit integers (u16) representing respectively its parent module id and its function id.

Its type discriminator is 6.

ObjectRef Not serializable ​

ObjectRef represents a reference to an Object from the heap. It holds an unsigned 32-bit integer (u32) representing its object id.

Its type discriminator is 7.

Built for the Candle ecosystem · Powered by VitePress.