summaryrefslogtreecommitdiff
path: root/py/runtime0.h
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2017-10-03 23:34:28 +1100
committerDamien George <damien.p.george@gmail.com>2017-10-05 10:49:44 +1100
commit0864a6957fe4717c3ec40ceeb373b19614a18434 (patch)
treeefe1af227822af824aa82e64195ae7501ab20de3 /py/runtime0.h
parentf869d6b2e339c04469c6c9ea3fb2fabd7bbb2d8c (diff)
py: Clean up unary and binary enum list to keep groups together.
2 non-bytecode binary ops (NOT_IN and IN_NOT) are moved out of the bytecode group, so this change will change the bytecode format.
Diffstat (limited to 'py/runtime0.h')
-rw-r--r--py/runtime0.h36
1 files changed, 21 insertions, 15 deletions
diff --git a/py/runtime0.h b/py/runtime0.h
index f54f62d2c..3edd8918b 100644
--- a/py/runtime0.h
+++ b/py/runtime0.h
@@ -51,41 +51,38 @@ typedef enum {
MP_UNARY_OP_NOT,
// Following ops cannot appear in the bytecode
- MP_UNARY_OP_NON_BYTECODE,
+ MP_UNARY_OP_NUM_BYTECODE,
- MP_UNARY_OP_BOOL = MP_UNARY_OP_NON_BYTECODE, // __bool__
+ MP_UNARY_OP_BOOL = MP_UNARY_OP_NUM_BYTECODE, // __bool__
MP_UNARY_OP_LEN, // __len__
MP_UNARY_OP_HASH, // __hash__; must return a small int
MP_UNARY_OP_ABS, // __abs__
MP_UNARY_OP_SIZEOF, // for sys.getsizeof()
+
+ MP_UNARY_OP_NUM_RUNTIME,
} mp_unary_op_t;
-// Note: the first 35 of these are used in bytecode and changing
+// Note: the first 9+12+12 of these are used in bytecode and changing
// them requires changing the bytecode version.
typedef enum {
- // Relational operations, should return a bool
+ // 9 relational operations, should return a bool
MP_BINARY_OP_LESS,
MP_BINARY_OP_MORE,
MP_BINARY_OP_EQUAL,
MP_BINARY_OP_LESS_EQUAL,
MP_BINARY_OP_MORE_EQUAL,
MP_BINARY_OP_NOT_EQUAL,
-
MP_BINARY_OP_IN,
MP_BINARY_OP_IS,
MP_BINARY_OP_EXCEPTION_MATCH,
- // these are not supported by the runtime and must be synthesised by the emitter
- MP_BINARY_OP_NOT_IN,
- MP_BINARY_OP_IS_NOT,
- // Arithmetic operations
+ // 12 inplace arithmetic operations
MP_BINARY_OP_INPLACE_OR,
MP_BINARY_OP_INPLACE_XOR,
MP_BINARY_OP_INPLACE_AND,
MP_BINARY_OP_INPLACE_LSHIFT,
MP_BINARY_OP_INPLACE_RSHIFT,
MP_BINARY_OP_INPLACE_ADD,
-
MP_BINARY_OP_INPLACE_SUBTRACT,
MP_BINARY_OP_INPLACE_MULTIPLY,
MP_BINARY_OP_INPLACE_FLOOR_DIVIDE,
@@ -93,13 +90,13 @@ typedef enum {
MP_BINARY_OP_INPLACE_MODULO,
MP_BINARY_OP_INPLACE_POWER,
+ // 12 normal arithmetic operations
MP_BINARY_OP_OR,
MP_BINARY_OP_XOR,
MP_BINARY_OP_AND,
MP_BINARY_OP_LSHIFT,
MP_BINARY_OP_RSHIFT,
MP_BINARY_OP_ADD,
-
MP_BINARY_OP_SUBTRACT,
MP_BINARY_OP_MULTIPLY,
MP_BINARY_OP_FLOOR_DIVIDE,
@@ -109,16 +106,16 @@ typedef enum {
// Operations below this line don't appear in bytecode, they
// just identify special methods.
+ MP_BINARY_OP_NUM_BYTECODE,
// MP_BINARY_OP_REVERSE_* must follow immediately after MP_BINARY_OP_*
#if MICROPY_PY_REVERSE_SPECIAL_METHODS
- MP_BINARY_OP_REVERSE_OR,
+ MP_BINARY_OP_REVERSE_OR = MP_BINARY_OP_NUM_BYTECODE,
MP_BINARY_OP_REVERSE_XOR,
MP_BINARY_OP_REVERSE_AND,
MP_BINARY_OP_REVERSE_LSHIFT,
MP_BINARY_OP_REVERSE_RSHIFT,
MP_BINARY_OP_REVERSE_ADD,
-
MP_BINARY_OP_REVERSE_SUBTRACT,
MP_BINARY_OP_REVERSE_MULTIPLY,
MP_BINARY_OP_REVERSE_FLOOR_DIVIDE,
@@ -127,9 +124,18 @@ typedef enum {
MP_BINARY_OP_REVERSE_POWER,
#endif
- MP_BINARY_OP_DIVMOD, // not emitted by the compiler but supported by the runtime
+ // This is not emitted by the compiler but is supported by the runtime
+ MP_BINARY_OP_DIVMOD
+ #if !MICROPY_PY_REVERSE_SPECIAL_METHODS
+ = MP_BINARY_OP_NUM_BYTECODE
+ #endif
+ ,
+
+ MP_BINARY_OP_NUM_RUNTIME,
- MP_BINARY_OP_LAST,
+ // These 2 are not supported by the runtime and must be synthesised by the emitter
+ MP_BINARY_OP_NOT_IN,
+ MP_BINARY_OP_IS_NOT,
} mp_binary_op_t;
typedef enum {