cs107-lecture-examples

Example codes used during Harvard CS107 lectures
git clone https://git.0xfab.ch/cs107-lecture-examples.git
Log | Files | Refs | README | LICENSE

opcode.h (11187B)


      1 // Auto-generated by Tools/scripts/generate_opcode_h.py from Lib/opcode.py
      2 
      3 #ifndef Py_OPCODE_H
      4 #define Py_OPCODE_H
      5 #ifdef __cplusplus
      6 extern "C" {
      7 #endif
      8 
      9 
     10 /* Instruction opcodes for compiled code */
     11 #define CACHE                                    0
     12 #define POP_TOP                                  1
     13 #define PUSH_NULL                                2
     14 #define NOP                                      9
     15 #define UNARY_POSITIVE                          10
     16 #define UNARY_NEGATIVE                          11
     17 #define UNARY_NOT                               12
     18 #define UNARY_INVERT                            15
     19 #define BINARY_SUBSCR                           25
     20 #define GET_LEN                                 30
     21 #define MATCH_MAPPING                           31
     22 #define MATCH_SEQUENCE                          32
     23 #define MATCH_KEYS                              33
     24 #define PUSH_EXC_INFO                           35
     25 #define CHECK_EXC_MATCH                         36
     26 #define CHECK_EG_MATCH                          37
     27 #define WITH_EXCEPT_START                       49
     28 #define GET_AITER                               50
     29 #define GET_ANEXT                               51
     30 #define BEFORE_ASYNC_WITH                       52
     31 #define BEFORE_WITH                             53
     32 #define END_ASYNC_FOR                           54
     33 #define STORE_SUBSCR                            60
     34 #define DELETE_SUBSCR                           61
     35 #define GET_ITER                                68
     36 #define GET_YIELD_FROM_ITER                     69
     37 #define PRINT_EXPR                              70
     38 #define LOAD_BUILD_CLASS                        71
     39 #define LOAD_ASSERTION_ERROR                    74
     40 #define RETURN_GENERATOR                        75
     41 #define LIST_TO_TUPLE                           82
     42 #define RETURN_VALUE                            83
     43 #define IMPORT_STAR                             84
     44 #define SETUP_ANNOTATIONS                       85
     45 #define YIELD_VALUE                             86
     46 #define ASYNC_GEN_WRAP                          87
     47 #define PREP_RERAISE_STAR                       88
     48 #define POP_EXCEPT                              89
     49 #define HAVE_ARGUMENT                           90
     50 #define STORE_NAME                              90
     51 #define DELETE_NAME                             91
     52 #define UNPACK_SEQUENCE                         92
     53 #define FOR_ITER                                93
     54 #define UNPACK_EX                               94
     55 #define STORE_ATTR                              95
     56 #define DELETE_ATTR                             96
     57 #define STORE_GLOBAL                            97
     58 #define DELETE_GLOBAL                           98
     59 #define SWAP                                    99
     60 #define LOAD_CONST                             100
     61 #define LOAD_NAME                              101
     62 #define BUILD_TUPLE                            102
     63 #define BUILD_LIST                             103
     64 #define BUILD_SET                              104
     65 #define BUILD_MAP                              105
     66 #define LOAD_ATTR                              106
     67 #define COMPARE_OP                             107
     68 #define IMPORT_NAME                            108
     69 #define IMPORT_FROM                            109
     70 #define JUMP_FORWARD                           110
     71 #define JUMP_IF_FALSE_OR_POP                   111
     72 #define JUMP_IF_TRUE_OR_POP                    112
     73 #define POP_JUMP_FORWARD_IF_FALSE              114
     74 #define POP_JUMP_FORWARD_IF_TRUE               115
     75 #define LOAD_GLOBAL                            116
     76 #define IS_OP                                  117
     77 #define CONTAINS_OP                            118
     78 #define RERAISE                                119
     79 #define COPY                                   120
     80 #define BINARY_OP                              122
     81 #define SEND                                   123
     82 #define LOAD_FAST                              124
     83 #define STORE_FAST                             125
     84 #define DELETE_FAST                            126
     85 #define POP_JUMP_FORWARD_IF_NOT_NONE           128
     86 #define POP_JUMP_FORWARD_IF_NONE               129
     87 #define RAISE_VARARGS                          130
     88 #define GET_AWAITABLE                          131
     89 #define MAKE_FUNCTION                          132
     90 #define BUILD_SLICE                            133
     91 #define JUMP_BACKWARD_NO_INTERRUPT             134
     92 #define MAKE_CELL                              135
     93 #define LOAD_CLOSURE                           136
     94 #define LOAD_DEREF                             137
     95 #define STORE_DEREF                            138
     96 #define DELETE_DEREF                           139
     97 #define JUMP_BACKWARD                          140
     98 #define CALL_FUNCTION_EX                       142
     99 #define EXTENDED_ARG                           144
    100 #define LIST_APPEND                            145
    101 #define SET_ADD                                146
    102 #define MAP_ADD                                147
    103 #define LOAD_CLASSDEREF                        148
    104 #define COPY_FREE_VARS                         149
    105 #define RESUME                                 151
    106 #define MATCH_CLASS                            152
    107 #define FORMAT_VALUE                           155
    108 #define BUILD_CONST_KEY_MAP                    156
    109 #define BUILD_STRING                           157
    110 #define LOAD_METHOD                            160
    111 #define LIST_EXTEND                            162
    112 #define SET_UPDATE                             163
    113 #define DICT_MERGE                             164
    114 #define DICT_UPDATE                            165
    115 #define PRECALL                                166
    116 #define CALL                                   171
    117 #define KW_NAMES                               172
    118 #define POP_JUMP_BACKWARD_IF_NOT_NONE          173
    119 #define POP_JUMP_BACKWARD_IF_NONE              174
    120 #define POP_JUMP_BACKWARD_IF_FALSE             175
    121 #define POP_JUMP_BACKWARD_IF_TRUE              176
    122 #define BINARY_OP_ADAPTIVE                       3
    123 #define BINARY_OP_ADD_FLOAT                      4
    124 #define BINARY_OP_ADD_INT                        5
    125 #define BINARY_OP_ADD_UNICODE                    6
    126 #define BINARY_OP_INPLACE_ADD_UNICODE            7
    127 #define BINARY_OP_MULTIPLY_FLOAT                 8
    128 #define BINARY_OP_MULTIPLY_INT                  13
    129 #define BINARY_OP_SUBTRACT_FLOAT                14
    130 #define BINARY_OP_SUBTRACT_INT                  16
    131 #define BINARY_SUBSCR_ADAPTIVE                  17
    132 #define BINARY_SUBSCR_DICT                      18
    133 #define BINARY_SUBSCR_GETITEM                   19
    134 #define BINARY_SUBSCR_LIST_INT                  20
    135 #define BINARY_SUBSCR_TUPLE_INT                 21
    136 #define CALL_ADAPTIVE                           22
    137 #define CALL_PY_EXACT_ARGS                      23
    138 #define CALL_PY_WITH_DEFAULTS                   24
    139 #define COMPARE_OP_ADAPTIVE                     26
    140 #define COMPARE_OP_FLOAT_JUMP                   27
    141 #define COMPARE_OP_INT_JUMP                     28
    142 #define COMPARE_OP_STR_JUMP                     29
    143 #define EXTENDED_ARG_QUICK                      34
    144 #define JUMP_BACKWARD_QUICK                     38
    145 #define LOAD_ATTR_ADAPTIVE                      39
    146 #define LOAD_ATTR_INSTANCE_VALUE                40
    147 #define LOAD_ATTR_MODULE                        41
    148 #define LOAD_ATTR_SLOT                          42
    149 #define LOAD_ATTR_WITH_HINT                     43
    150 #define LOAD_CONST__LOAD_FAST                   44
    151 #define LOAD_FAST__LOAD_CONST                   45
    152 #define LOAD_FAST__LOAD_FAST                    46
    153 #define LOAD_GLOBAL_ADAPTIVE                    47
    154 #define LOAD_GLOBAL_BUILTIN                     48
    155 #define LOAD_GLOBAL_MODULE                      55
    156 #define LOAD_METHOD_ADAPTIVE                    56
    157 #define LOAD_METHOD_CLASS                       57
    158 #define LOAD_METHOD_MODULE                      58
    159 #define LOAD_METHOD_NO_DICT                     59
    160 #define LOAD_METHOD_WITH_DICT                   62
    161 #define LOAD_METHOD_WITH_VALUES                 63
    162 #define PRECALL_ADAPTIVE                        64
    163 #define PRECALL_BOUND_METHOD                    65
    164 #define PRECALL_BUILTIN_CLASS                   66
    165 #define PRECALL_BUILTIN_FAST_WITH_KEYWORDS      67
    166 #define PRECALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS  72
    167 #define PRECALL_NO_KW_BUILTIN_FAST              73
    168 #define PRECALL_NO_KW_BUILTIN_O                 76
    169 #define PRECALL_NO_KW_ISINSTANCE                77
    170 #define PRECALL_NO_KW_LEN                       78
    171 #define PRECALL_NO_KW_LIST_APPEND               79
    172 #define PRECALL_NO_KW_METHOD_DESCRIPTOR_FAST    80
    173 #define PRECALL_NO_KW_METHOD_DESCRIPTOR_NOARGS  81
    174 #define PRECALL_NO_KW_METHOD_DESCRIPTOR_O      113
    175 #define PRECALL_NO_KW_STR_1                    121
    176 #define PRECALL_NO_KW_TUPLE_1                  127
    177 #define PRECALL_NO_KW_TYPE_1                   141
    178 #define PRECALL_PYFUNC                         143
    179 #define RESUME_QUICK                           150
    180 #define STORE_ATTR_ADAPTIVE                    153
    181 #define STORE_ATTR_INSTANCE_VALUE              154
    182 #define STORE_ATTR_SLOT                        158
    183 #define STORE_ATTR_WITH_HINT                   159
    184 #define STORE_FAST__LOAD_FAST                  161
    185 #define STORE_FAST__STORE_FAST                 167
    186 #define STORE_SUBSCR_ADAPTIVE                  168
    187 #define STORE_SUBSCR_DICT                      169
    188 #define STORE_SUBSCR_LIST_INT                  170
    189 #define UNPACK_SEQUENCE_ADAPTIVE               177
    190 #define UNPACK_SEQUENCE_LIST                   178
    191 #define UNPACK_SEQUENCE_TUPLE                  179
    192 #define UNPACK_SEQUENCE_TWO_TUPLE              180
    193 #define DO_TRACING                             255
    194 
    195 #define HAS_CONST(op) (false\
    196     || ((op) == 100) \
    197     || ((op) == 172) \
    198     )
    199 
    200 #define NB_ADD                                   0
    201 #define NB_AND                                   1
    202 #define NB_FLOOR_DIVIDE                          2
    203 #define NB_LSHIFT                                3
    204 #define NB_MATRIX_MULTIPLY                       4
    205 #define NB_MULTIPLY                              5
    206 #define NB_REMAINDER                             6
    207 #define NB_OR                                    7
    208 #define NB_POWER                                 8
    209 #define NB_RSHIFT                                9
    210 #define NB_SUBTRACT                             10
    211 #define NB_TRUE_DIVIDE                          11
    212 #define NB_XOR                                  12
    213 #define NB_INPLACE_ADD                          13
    214 #define NB_INPLACE_AND                          14
    215 #define NB_INPLACE_FLOOR_DIVIDE                 15
    216 #define NB_INPLACE_LSHIFT                       16
    217 #define NB_INPLACE_MATRIX_MULTIPLY              17
    218 #define NB_INPLACE_MULTIPLY                     18
    219 #define NB_INPLACE_REMAINDER                    19
    220 #define NB_INPLACE_OR                           20
    221 #define NB_INPLACE_POWER                        21
    222 #define NB_INPLACE_RSHIFT                       22
    223 #define NB_INPLACE_SUBTRACT                     23
    224 #define NB_INPLACE_TRUE_DIVIDE                  24
    225 #define NB_INPLACE_XOR                          25
    226 
    227 #define HAS_ARG(op) ((op) >= HAVE_ARGUMENT)
    228 
    229 /* Reserve some bytecodes for internal use in the compiler.
    230  * The value of 240 is arbitrary. */
    231 #define IS_ARTIFICIAL(op) ((op) > 240)
    232 
    233 #ifdef __cplusplus
    234 }
    235 #endif
    236 #endif /* !Py_OPCODE_H */