@@ -51,55 +51,52 @@ typedef enum {
5151 MP_UNARY_OP_NOT ,
5252
5353 // Following ops cannot appear in the bytecode
54- MP_UNARY_OP_NON_BYTECODE ,
54+ MP_UNARY_OP_NUM_BYTECODE ,
5555
56- MP_UNARY_OP_BOOL = MP_UNARY_OP_NON_BYTECODE , // __bool__
56+ MP_UNARY_OP_BOOL = MP_UNARY_OP_NUM_BYTECODE , // __bool__
5757 MP_UNARY_OP_LEN , // __len__
5858 MP_UNARY_OP_HASH , // __hash__; must return a small int
5959 MP_UNARY_OP_ABS , // __abs__
6060 MP_UNARY_OP_SIZEOF , // for sys.getsizeof()
61+
62+ MP_UNARY_OP_NUM_RUNTIME ,
6163} mp_unary_op_t ;
6264
63- // Note: the first 35 of these are used in bytecode and changing
65+ // Note: the first 9+12+12 of these are used in bytecode and changing
6466// them requires changing the bytecode version.
6567typedef enum {
66- // Relational operations, should return a bool
68+ // 9 relational operations, should return a bool
6769 MP_BINARY_OP_LESS ,
6870 MP_BINARY_OP_MORE ,
6971 MP_BINARY_OP_EQUAL ,
7072 MP_BINARY_OP_LESS_EQUAL ,
7173 MP_BINARY_OP_MORE_EQUAL ,
7274 MP_BINARY_OP_NOT_EQUAL ,
73-
7475 MP_BINARY_OP_IN ,
7576 MP_BINARY_OP_IS ,
7677 MP_BINARY_OP_EXCEPTION_MATCH ,
77- // these are not supported by the runtime and must be synthesised by the emitter
78- MP_BINARY_OP_NOT_IN ,
79- MP_BINARY_OP_IS_NOT ,
8078
81- // Arithmetic operations
79+ // 12 inplace arithmetic operations
8280 MP_BINARY_OP_INPLACE_OR ,
8381 MP_BINARY_OP_INPLACE_XOR ,
8482 MP_BINARY_OP_INPLACE_AND ,
8583 MP_BINARY_OP_INPLACE_LSHIFT ,
8684 MP_BINARY_OP_INPLACE_RSHIFT ,
8785 MP_BINARY_OP_INPLACE_ADD ,
88-
8986 MP_BINARY_OP_INPLACE_SUBTRACT ,
9087 MP_BINARY_OP_INPLACE_MULTIPLY ,
9188 MP_BINARY_OP_INPLACE_FLOOR_DIVIDE ,
9289 MP_BINARY_OP_INPLACE_TRUE_DIVIDE ,
9390 MP_BINARY_OP_INPLACE_MODULO ,
9491 MP_BINARY_OP_INPLACE_POWER ,
9592
93+ // 12 normal arithmetic operations
9694 MP_BINARY_OP_OR ,
9795 MP_BINARY_OP_XOR ,
9896 MP_BINARY_OP_AND ,
9997 MP_BINARY_OP_LSHIFT ,
10098 MP_BINARY_OP_RSHIFT ,
10199 MP_BINARY_OP_ADD ,
102-
103100 MP_BINARY_OP_SUBTRACT ,
104101 MP_BINARY_OP_MULTIPLY ,
105102 MP_BINARY_OP_FLOOR_DIVIDE ,
@@ -109,16 +106,16 @@ typedef enum {
109106
110107 // Operations below this line don't appear in bytecode, they
111108 // just identify special methods.
109+ MP_BINARY_OP_NUM_BYTECODE ,
112110
113111 // MP_BINARY_OP_REVERSE_* must follow immediately after MP_BINARY_OP_*
114112#if MICROPY_PY_REVERSE_SPECIAL_METHODS
115- MP_BINARY_OP_REVERSE_OR ,
113+ MP_BINARY_OP_REVERSE_OR = MP_BINARY_OP_NUM_BYTECODE ,
116114 MP_BINARY_OP_REVERSE_XOR ,
117115 MP_BINARY_OP_REVERSE_AND ,
118116 MP_BINARY_OP_REVERSE_LSHIFT ,
119117 MP_BINARY_OP_REVERSE_RSHIFT ,
120118 MP_BINARY_OP_REVERSE_ADD ,
121-
122119 MP_BINARY_OP_REVERSE_SUBTRACT ,
123120 MP_BINARY_OP_REVERSE_MULTIPLY ,
124121 MP_BINARY_OP_REVERSE_FLOOR_DIVIDE ,
@@ -127,9 +124,18 @@ typedef enum {
127124 MP_BINARY_OP_REVERSE_POWER ,
128125#endif
129126
130- MP_BINARY_OP_DIVMOD , // not emitted by the compiler but supported by the runtime
127+ // This is not emitted by the compiler but is supported by the runtime
128+ MP_BINARY_OP_DIVMOD
129+ #if !MICROPY_PY_REVERSE_SPECIAL_METHODS
130+ = MP_BINARY_OP_NUM_BYTECODE
131+ #endif
132+ ,
133+
134+ MP_BINARY_OP_NUM_RUNTIME ,
131135
132- MP_BINARY_OP_LAST ,
136+ // These 2 are not supported by the runtime and must be synthesised by the emitter
137+ MP_BINARY_OP_NOT_IN ,
138+ MP_BINARY_OP_IS_NOT ,
133139} mp_binary_op_t ;
134140
135141typedef enum {
0 commit comments