Array Manipulation Opcodes
This section documents the arrays instructions available in CandleVM.
For operand encodings, see the executable format reference.
Arrays
All array instructions require an ObjectRef to an Array. Array indexes accept Byte values or a non-negative integral Number values representable as usize.
| Opcode byte | Opcode | Operand bytes | Behavior |
|---|---|---|---|
| 37 | NewArray | destination: register | Allocates an empty array and stores its ObjectRef value. |
| 38 | ArrayLen | destination: register, array: register | Stores the number of elements as a numeric value (Byte for lengths 0–255, otherwise Number). |
| 39 | ArrayContains | destination: register, array: register, value: register | Stores whether the array contains a Value equal to the given Value. |
| 40 | ArrayGet | destination: register, array: register, index: register | Loads the element at the index; an index at or beyond length raises ArrayIndexOutOfBounds. |
| 41 | ArraySet | array: register, index: register, value: register | Replaces an existing element. An index equal to or greater than the length raises ArrayIndexOutOfBounds. |
| 42 | ArrayInsert | array: register, index: register, value: register | Inserts before the index; an index equal to the length appends. An index greater than the length raises ArrayIndexOutOfBounds. |
| 43 | ArrayRemove | array: register, index: register | Removes and discards the element at the index; out-of-range indexes raise ArrayIndexOutOfBounds. |