APX Virtual Machine v1¶
APX virtual machine currently implemented in py-apx. Note that qt-apx implements an even earlier version that was never documented. (Implementation needs to be updated).
Instructions¶
| Opcode Number | Opcode Name | Size | Opcode arguments (additional bytes) | Description |
|---|---|---|---|---|
| 0 | NOP | 1 | No operation | |
| 1 | PACK_PROG_HDR | 5 |
|
pack program header |
| 2 | UNPACK_PROG_HDR | 5 |
|
pack program header |
| 3 | PACK_U8 | 1 | pack single uint8 | |
| 4 | PACK_U16 | 1 | pack single uint16 | |
| 5 | PACK_U32 | 1 | pack single uint32 | |
| 6 | PACK_S8 | 1 | pack single sint8 | |
| 7 | PACK_S16 | 1 | pack single sint16 | |
| 8 | PACK_S32 | 1 | pack single sint32 | |
| 9 | PACK_STR | 3 |
|
pack string |
| 10 | PACK_U8AR | 3 |
|
pack uint8 array |
| 11 | PACK_U16AR | 3 |
|
pack uint16 array |
| 12 | PACK_U32AR | 3 |
|
pack uint32 array |
| 13 | PACK_S8AR | 3 |
|
pack uint8 array |
| 14 | PACK_S16AR | 3 |
|
pack uint16 array |
| 15 | PACK_S32AR | 3 |
|
pack uint32 array |
| 16 | UNPACK_U8 | 1 | unpack single uint8 | |
| 17 | UNPACK_U16 | 1 | unpack single uint16 | |
| 18 | UNPACK_U32 | 1 | unpack single uint32 | |
| 19 | UNPACK_S8 | 1 | unpack single sint8 | |
| 20 | UNPACK_S16 | 1 | unpack single sint16 | |
| 21 | UNPACK_S32 | 1 | unpack single sint32 | |
| 22 | UNPPACK_STR | 3 |
|
unpack string |
| 23 | UNPACK_U8AR | 3 |
|
unpack uint8 array |
| 24 | UNPACK_U16AR | 3 |
|
unpack uint16 array |
| 25 | UNPACK_U32AR | 3 |
|
unpack uint32 array |
| 26 | UNPACK_S8AR | 3 |
|
unpack sint8 array |
| 27 | UNPACK_S16AR | 3 |
|
unpack sint16 array |
| 28 | UNPACK_S32AR | 3 |
|
unpack sint32 array |
| 29 | RECORD_ENTER | 1 | record inside of record | |
| 30 | RECORD_SELECT | VAR | null-terminated utf-8 string | name of record element |
| 31 | RECORD_LEAVE | 1 | ||
| 32 | ARRAY_ENTER | 1 | Used for array of records | |
| 33 | ARRAY_LEAVE | 1 |
APX Variants¶
Variants are variables that can store values of different types. They are supported in one way or another in most programming languages.
Types of variants:
- Scalars (integers, strings)
- Lists (list of variants)
- Maps (key-value map to variants)
Variant types are identified internally using integers according to the following table:
| Value | Name |
|---|---|
| -1 | VTYPE_INVALID |
| 0 | VTYPE_SCALAR |
| 1 | VTYPE_LIST |
| 2 | VTYPE_MAP |
Variant Language Mapping¶
Each APX implementation maps the APX variant according to what is available to the language.
| Programming Language | VTYPE_SCALAR | VTYPE_LIST | VTYPE_MAP |
|---|---|---|---|
| C (with dtl_type library) | dtl_sv_t | dtl_av_t | dtl_hv_t |
| C++ (with Qt variants) | QVariant | QVariantList | QVariantMap |
| Python | (int, str) | list | dict |
| Visual Basic (Excel) | Variant | Variant | Scripting.Dictionary |