Map Manipulation Opcodes
This section documents the maps instructions available in CandleVM.
For operand encodings, see the executable format reference.
Maps
All map instructions require an ObjectRef value to a Map. Map keys and values can be of all types.
| Opcode byte | Opcode | Operand bytes | Behavior |
|---|---|---|---|
| 44 | NewMap | destination: register | Allocates an empty map and stores its ObjectRef value. |
| 45 | MapLen | destination: register, map: register | Stores the number of key/value pairs as a numeric value (Byte for lengths 0–255, otherwise Number). |
| 46 | MapContains | destination: register, map: register, key: register | Stores whether the map contains the key. For ObjectRef values this is reference-ID equality. |
| 47 | MapGet | destination: register, map: register, key: register | Loads the mapped value; a missing key raises MapKeyNotFound. |
| 48 | MapSet | map: register, key: register, value: register | Inserts or replaces the key's value. |
| 49 | MapRemove | map: register, key: register | Removes the key and discards its value; a missing key raises MapKeyNotFound. |