aboutsummaryrefslogtreecommitdiff
path: root/py/bc.h
diff options
context:
space:
mode:
Diffstat (limited to 'py/bc.h')
-rw-r--r--py/bc.h156
1 files changed, 78 insertions, 78 deletions
diff --git a/py/bc.h b/py/bc.h
index a96d17a0d..65af40700 100644
--- a/py/bc.h
+++ b/py/bc.h
@@ -72,94 +72,94 @@
// constN : obj
#define MP_BC_PRELUDE_SIG_ENCODE(S, E, scope, out_byte, out_env) \
-do { \
- /*// Get values to store in prelude */ \
- size_t F = scope->scope_flags & MP_SCOPE_FLAG_ALL_SIG; \
- size_t A = scope->num_pos_args; \
- size_t K = scope->num_kwonly_args; \
- size_t D = scope->num_def_pos_args; \
+ do { \
+ /*// Get values to store in prelude */ \
+ size_t F = scope->scope_flags & MP_SCOPE_FLAG_ALL_SIG; \
+ size_t A = scope->num_pos_args; \
+ size_t K = scope->num_kwonly_args; \
+ size_t D = scope->num_def_pos_args; \
\
- /* Adjust S to shrink range, to compress better */ \
- S -= 1; \
+ /* Adjust S to shrink range, to compress better */ \
+ S -= 1; \
\
- /* Encode prelude */ \
- /* xSSSSEAA */ \
- uint8_t z = (S & 0xf) << 3 | (E & 1) << 2 | (A & 3); \
- S >>= 4; \
- E >>= 1; \
- A >>= 2; \
- while (S | E | F | A | K | D) { \
- out_byte(out_env, 0x80 | z); \
- /* xFSSKAED */ \
- z = (F & 1) << 6 | (S & 3) << 4 | (K & 1) << 3 \
- | (A & 1) << 2 | (E & 1) << 1 | (D & 1); \
- S >>= 2; \
- E >>= 1; \
- F >>= 1; \
- A >>= 1; \
- K >>= 1; \
- D >>= 1; \
- } \
- out_byte(out_env, z); \
-} while (0)
+ /* Encode prelude */ \
+ /* xSSSSEAA */ \
+ uint8_t z = (S & 0xf) << 3 | (E & 1) << 2 | (A & 3); \
+ S >>= 4; \
+ E >>= 1; \
+ A >>= 2; \
+ while (S | E | F | A | K | D) { \
+ out_byte(out_env, 0x80 | z); \
+ /* xFSSKAED */ \
+ z = (F & 1) << 6 | (S & 3) << 4 | (K & 1) << 3 \
+ | (A & 1) << 2 | (E & 1) << 1 | (D & 1); \
+ S >>= 2; \
+ E >>= 1; \
+ F >>= 1; \
+ A >>= 1; \
+ K >>= 1; \
+ D >>= 1; \
+ } \
+ out_byte(out_env, z); \
+ } while (0)
#define MP_BC_PRELUDE_SIG_DECODE_INTO(ip, S, E, F, A, K, D) \
-do { \
- uint8_t z = *(ip)++; \
- /* xSSSSEAA */ \
- S = (z >> 3) & 0xf; \
- E = (z >> 2) & 0x1; \
- F = 0; \
- A = z & 0x3; \
- K = 0; \
- D = 0; \
- for (unsigned n = 0; z & 0x80; ++n) { \
- z = *(ip)++; \
- /* xFSSKAED */ \
- S |= (z & 0x30) << (2 * n); \
- E |= (z & 0x02) << n; \
- F |= ((z & 0x40) >> 6) << n; \
- A |= (z & 0x4) << n; \
- K |= ((z & 0x08) >> 3) << n; \
- D |= (z & 0x1) << n; \
- } \
- S += 1; \
-} while (0)
+ do { \
+ uint8_t z = *(ip)++; \
+ /* xSSSSEAA */ \
+ S = (z >> 3) & 0xf; \
+ E = (z >> 2) & 0x1; \
+ F = 0; \
+ A = z & 0x3; \
+ K = 0; \
+ D = 0; \
+ for (unsigned n = 0; z & 0x80; ++n) { \
+ z = *(ip)++; \
+ /* xFSSKAED */ \
+ S |= (z & 0x30) << (2 * n); \
+ E |= (z & 0x02) << n; \
+ F |= ((z & 0x40) >> 6) << n; \
+ A |= (z & 0x4) << n; \
+ K |= ((z & 0x08) >> 3) << n; \
+ D |= (z & 0x1) << n; \
+ } \
+ S += 1; \
+ } while (0)
#define MP_BC_PRELUDE_SIG_DECODE(ip) \
size_t n_state, n_exc_stack, scope_flags, n_pos_args, n_kwonly_args, n_def_pos_args; \
MP_BC_PRELUDE_SIG_DECODE_INTO(ip, n_state, n_exc_stack, scope_flags, n_pos_args, n_kwonly_args, n_def_pos_args)
#define MP_BC_PRELUDE_SIZE_ENCODE(I, C, out_byte, out_env) \
-do { \
- /* Encode bit-wise as: xIIIIIIC */ \
- uint8_t z = 0; \
- do { \
- z = (I & 0x3f) << 1 | (C & 1); \
- C >>= 1; \
- I >>= 6; \
- if (C | I) { \
- z |= 0x80; \
- } \
- out_byte(out_env, z); \
- } while (C | I); \
-} while (0)
+ do { \
+ /* Encode bit-wise as: xIIIIIIC */ \
+ uint8_t z = 0; \
+ do { \
+ z = (I & 0x3f) << 1 | (C & 1); \
+ C >>= 1; \
+ I >>= 6; \
+ if (C | I) { \
+ z |= 0x80; \
+ } \
+ out_byte(out_env, z); \
+ } while (C | I); \
+ } while (0)
#define MP_BC_PRELUDE_SIZE_DECODE_INTO(ip, I, C) \
-do { \
- uint8_t z; \
- C = 0; \
- I = 0; \
- for (unsigned n = 0;; ++n) { \
- z = *(ip)++; \
- /* xIIIIIIC */ \
- C |= (z & 1) << n; \
- I |= ((z & 0x7e) >> 1) << (6 * n); \
- if (!(z & 0x80)) { \
- break; \
- } \
- } \
-} while (0)
+ do { \
+ uint8_t z; \
+ C = 0; \
+ I = 0; \
+ for (unsigned n = 0;; ++n) { \
+ z = *(ip)++; \
+ /* xIIIIIIC */ \
+ C |= (z & 1) << n; \
+ I |= ((z & 0x7e) >> 1) << (6 * n); \
+ if (!(z & 0x80)) { \
+ break; \
+ } \
+ } \
+ } while (0)
#define MP_BC_PRELUDE_SIZE_DECODE(ip) \
size_t n_info, n_cell; \
@@ -232,10 +232,10 @@ const byte *mp_bytecode_print_str(const byte *ip);
#define mp_bytecode_print_inst(code, const_table) mp_bytecode_print2(code, 1, const_table)
// Helper macros to access pointer with least significant bits holding flags
-#define MP_TAGPTR_PTR(x) ((void*)((uintptr_t)(x) & ~((uintptr_t)3)))
+#define MP_TAGPTR_PTR(x) ((void *)((uintptr_t)(x) & ~((uintptr_t)3)))
#define MP_TAGPTR_TAG0(x) ((uintptr_t)(x) & 1)
#define MP_TAGPTR_TAG1(x) ((uintptr_t)(x) & 2)
-#define MP_TAGPTR_MAKE(ptr, tag) ((void*)((uintptr_t)(ptr) | (tag)))
+#define MP_TAGPTR_MAKE(ptr, tag) ((void *)((uintptr_t)(ptr) | (tag)))
#if MICROPY_PERSISTENT_CODE_LOAD || MICROPY_PERSISTENT_CODE_SAVE