bc.h 4.31 KB
Newer Older
Damien's avatar
Damien committed
1
2
3
#define PYBC_LOAD_CONST_FALSE   (0x10)
#define PYBC_LOAD_CONST_NONE    (0x11)
#define PYBC_LOAD_CONST_TRUE    (0x12)
Damien's avatar
Damien committed
4
#define PYBC_LOAD_CONST_SMALL_INT   (0x13) // 24-bit, in excess
Damien's avatar
Damien committed
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#define PYBC_LOAD_CONST_INT     (0x14) // qstr
#define PYBC_LOAD_CONST_DEC     (0x15) // qstr
#define PYBC_LOAD_CONST_ID      (0x16) // qstr
#define PYBC_LOAD_CONST_BYTES   (0x17) // qstr
#define PYBC_LOAD_CONST_STRING  (0x18) // qstr

#define PYBC_LOAD_FAST_0        (0x20)
#define PYBC_LOAD_FAST_1        (0x21)
#define PYBC_LOAD_FAST_2        (0x22)
#define PYBC_LOAD_FAST_N        (0x23) // uint
#define PYBC_LOAD_NAME          (0x24) // qstr
#define PYBC_LOAD_GLOBAL        (0x25) // qstr
#define PYBC_LOAD_ATTR          (0x26) // qstr
#define PYBC_LOAD_METHOD        (0x27) // qstr
#define PYBC_LOAD_BUILD_CLASS   (0x28)

#define PYBC_STORE_FAST_0       (0x30)
#define PYBC_STORE_FAST_1       (0x31)
#define PYBC_STORE_FAST_2       (0x32)
#define PYBC_STORE_FAST_N       (0x33) // uint
#define PYBC_STORE_NAME         (0x34) // qstr
#define PYBC_STORE_GLOBAL       (0x35) // qstr
#define PYBC_STORE_ATTR         (0x36) // qstr
28
#define PYBC_STORE_SUBSCR       (0x37)
Damien's avatar
Damien committed
29
30
31
32
33
34
35
36
37
38
39
40
41

#define PYBC_DELETE_FAST_N      (0x39) // uint
#define PYBC_DELETE_NAME        (0x3a) // qstr
#define PYBC_DELETE_GLOBAL      (0x3b) // qstr
#define PYBC_DELETE_DEREF       (0x3c) // qstr
#define PYBC_DELETE_ATTR        (0x3d) // qstr
#define PYBC_DELETE_SUBSCR      (0x3e)

#define PYBC_DUP_TOP            (0x40)
#define PYBC_DUP_TOP_TWO        (0x41)
#define PYBC_POP_TOP            (0x42)
#define PYBC_ROT_TWO            (0x43)
#define PYBC_ROT_THREE          (0x44)
Damien's avatar
Damien committed
42
43
44
45
46
47
48
49
50
51

#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
Damien's avatar
Damien committed
52
#define PYBC_WITH_CLEANUP       (0x4e)
Damien's avatar
Damien committed
53
54
#define PYBC_SETUP_EXCEPT       (0x4f) // rel byte code offset, 16-bit unsigned
#define PYBC_SETUP_FINALLY      (0x50) // rel byte code offset, 16-bit unsigned
Damien's avatar
Damien committed
55
56
#define PYBC_END_FINALLY        (0x51)
#define PYBC_GET_ITER           (0x52)
Damien's avatar
Damien committed
57
#define PYBC_FOR_ITER           (0x53) // rel byte code offset, 16-bit unsigned
Damien's avatar
Damien committed
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#define PYBC_POP_BLOCK          (0x54)
#define PYBC_POP_EXCEPT         (0x55)

#define PYBC_UNARY_OP           (0x60) // byte
#define PYBC_BINARY_OP          (0x61) // byte
#define PYBC_COMPARE_OP         (0x62) // byte

#define PYBC_BUILD_TUPLE        (0x70) // uint
#define PYBC_BUILD_LIST         (0x71) // uint
#define PYBC_LIST_APPEND        (0x72) // uint
#define PYBC_BUILD_MAP          (0x73) // uint
#define PYBC_STORE_MAP          (0x74)
#define PYBC_MAP_ADD            (0x75) // uint
#define PYBC_BUILD_SET          (0x76) // uint
#define PYBC_SET_ADD            (0x77) // uint
#define PYBC_BUILD_SLICE        (0x78) // uint
#define PYBC_UNPACK_SEQUENCE    (0x79) // uint
#define PYBC_UNPACK_EX          (0x7a) // uint

#define PYBC_RETURN_VALUE       (0x80)
#define PYBC_RAISE_VARARGS      (0x81) // uint
#define PYBC_YIELD_VALUE        (0x82)
#define PYBC_YIELD_FROM         (0x83)

#define PYBC_MAKE_FUNCTION      (0x90) // uint
#define PYBC_MAKE_CLOSURE       (0x91) // uint?
#define PYBC_CALL_FUNCTION      (0x92) // uint
#define PYBC_CALL_FUNCTION_VAR  (0x93) // uint
#define PYBC_CALL_FUNCTION_KW   (0x94) // uint
#define PYBC_CALL_FUNCTION_VAR_KW   (0x95) // uint
#define PYBC_CALL_METHOD        (0x96) // uint
#define PYBC_CALL_METHOD_VAR    (0x97) // uint
#define PYBC_CALL_METHOD_KW     (0x98) // uint
#define PYBC_CALL_METHOD_VAR_KW (0x99) // uint

#define PYBC_IMPORT_NAME (0xe0)
#define PYBC_IMPORT_FROM (0xe1)
#define PYBC_IMPORT_STAR (0xe2)

97
py_obj_t py_execute_byte_code(const byte *code, const py_obj_t *args, uint n_args, uint n_state);
Damien's avatar
Damien committed
98
bool py_execute_byte_code_2(const byte **ip_in_out, py_obj_t *fastn, py_obj_t **sp_in_out);