diff options
| author | Damien <damien.p.george@gmail.com> | 2013-11-05 22:06:08 +0000 |
|---|---|---|
| committer | Damien <damien.p.george@gmail.com> | 2013-11-05 22:06:08 +0000 |
| commit | 03c9cfb01554d8b5f9468cda3748d49eb6fd94b4 (patch) | |
| tree | 8d5000b0974ae6ea7f7e3e9aac3bb1efb40de6bf /py/bc.h | |
| parent | 1c62d04e2eda24cb07565eb4380ece44e17ee839 (diff) | |
Make byte code jumps relative.
Diffstat (limited to 'py/bc.h')
| -rw-r--r-- | py/bc.h | 29 |
1 files changed, 15 insertions, 14 deletions
@@ -1,7 +1,7 @@ #define PYBC_LOAD_CONST_FALSE (0x10) #define PYBC_LOAD_CONST_NONE (0x11) #define PYBC_LOAD_CONST_TRUE (0x12) -#define PYBC_LOAD_CONST_SMALL_INT (0x13) // int +#define PYBC_LOAD_CONST_SMALL_INT (0x13) // 24-bit, in excess #define PYBC_LOAD_CONST_INT (0x14) // qstr #define PYBC_LOAD_CONST_DEC (0x15) // qstr #define PYBC_LOAD_CONST_ID (0x16) // qstr @@ -39,21 +39,22 @@ #define PYBC_POP_TOP (0x42) #define PYBC_ROT_TWO (0x43) #define PYBC_ROT_THREE (0x44) -#define PYBC_JUMP (0x45) // pos -#define PYBC_POP_JUMP_IF_TRUE (0x46) // pos -#define PYBC_POP_JUMP_IF_FALSE (0x47) // pos -#define PYBC_JUMP_IF_TRUE_OR_POP (0x48) // pos -#define PYBC_JUMP_IF_FALSE_OR_POP (0x49) // pos -#define PYBC_SETUP_LOOP (0x4a) // pos -#define PYBC_BREAK_LOOP (0x4b) // pos -#define PYBC_CONTINUE_LOOP (0x4c) // pos -#define PYBC_SETUP_WITH (0x4d) // pos + +#define PYBC_JUMP (0x45) // rel byte code offset, 16-bit signed, in excess +#define PYBC_POP_JUMP_IF_TRUE (0x46) // rel byte code offset, 16-bit signed, in excess +#define PYBC_POP_JUMP_IF_FALSE (0x47) // rel byte code offset, 16-bit signed, in excess +#define PYBC_JUMP_IF_TRUE_OR_POP (0x48) // rel byte code offset, 16-bit signed, in excess +#define PYBC_JUMP_IF_FALSE_OR_POP (0x49) // rel byte code offset, 16-bit signed, in excess +#define PYBC_SETUP_LOOP (0x4a) // rel byte code offset, 16-bit unsigned +#define PYBC_BREAK_LOOP (0x4b) // rel byte code offset, 16-bit unsigned +#define PYBC_CONTINUE_LOOP (0x4c) // rel byte code offset, 16-bit unsigned +#define PYBC_SETUP_WITH (0x4d) // rel byte code offset, 16-bit unsigned #define PYBC_WITH_CLEANUP (0x4e) -#define PYBC_SETUP_EXCEPT (0x4f) // pos -#define PYBC_SETUP_FINALLY (0x50) // pos +#define PYBC_SETUP_EXCEPT (0x4f) // rel byte code offset, 16-bit unsigned +#define PYBC_SETUP_FINALLY (0x50) // rel byte code offset, 16-bit unsigned #define PYBC_END_FINALLY (0x51) #define PYBC_GET_ITER (0x52) -#define PYBC_FOR_ITER (0x53) // pos +#define PYBC_FOR_ITER (0x53) // rel byte code offset, 16-bit unsigned #define PYBC_POP_BLOCK (0x54) #define PYBC_POP_EXCEPT (0x55) @@ -94,4 +95,4 @@ #define PYBC_IMPORT_STAR (0xe2) py_obj_t py_execute_byte_code(const byte *code, const py_obj_t *args, uint n_args); -bool py_execute_byte_code_2(const byte *code, const byte **ip_in_out, py_obj_t *fastn, py_obj_t **sp_in_out); +bool py_execute_byte_code_2(const byte **ip_in_out, py_obj_t *fastn, py_obj_t **sp_in_out); |
