Oliver Fabel 1 год назад
Родитель
Сommit
dcf290ef61
100 измененных файлов с 1630 добавлено и 2143 удалено
  1. 16 16
      extmod/modjson.c
  2. 32 32
      extmod/modrandom.c
  3. 15 15
      extmod/modtime.c
  4. 1 2
      genhdr/mpversion.h
  5. 317 317
      genhdr/qstrdefs.generated.h
  6. 15 37
      py/asmarm.c
  7. 0 4
      py/asmarm.h
  8. 3 3
      py/asmthumb.c
  9. 0 2
      py/asmthumb.h
  10. 13 23
      py/asmx64.c
  11. 0 4
      py/asmx64.h
  12. 16 26
      py/asmx86.c
  13. 0 4
      py/asmx86.h
  14. 2 4
      py/asmxtensa.c
  15. 2 8
      py/asmxtensa.h
  16. 4 4
      py/bc.c
  17. 4 4
      py/bc.h
  18. 2 107
      py/binary.c
  19. 10 14
      py/builtinevex.c
  20. 6 6
      py/builtinhelp.c
  21. 19 20
      py/builtinimport.c
  22. 113 120
      py/compile.c
  23. 0 5
      py/compile.h
  24. 5 12
      py/dynruntime.h
  25. 19 23
      py/emitbc.c
  26. 31 47
      py/emitglue.c
  27. 22 60
      py/emitglue.h
  28. 21 21
      py/emitinlinethumb.c
  29. 13 13
      py/emitinlinextensa.c
  30. 131 147
      py/emitnative.c
  31. 2 2
      py/emitnx86.c
  32. 7 7
      py/gc.c
  33. 29 29
      py/lexer.c
  34. 2 2
      py/malloc.c
  35. 4 4
      py/map.c
  36. 7 0
      py/misc.h
  37. 2 2
      py/modarray.c
  38. 34 34
      py/modbuiltins.c
  39. 20 20
      py/modcmath.c
  40. 2 2
      py/modcollections.c
  41. 4 4
      py/moderrno.c
  42. 9 9
      py/modgc.c
  43. 20 20
      py/modio.c
  44. 32 32
      py/modmath.c
  45. 28 28
      py/modmicropython.c
  46. 10 10
      py/modstruct.c
  47. 19 19
      py/modsys.c
  48. 41 28
      py/modthread.c
  49. 11 51
      py/mpconfig.h
  50. 2 2
      py/mpprint.c
  51. 1 0
      py/mpstate.h
  52. 19 19
      py/mpz.c
  53. 11 15
      py/nativeglue.c
  54. 2 7
      py/nativeglue.h
  55. 1 1
      py/nlraarch64.c
  56. 1 1
      py/nlrmips.c
  57. 2 2
      py/nlrpowerpc.c
  58. 1 1
      py/nlrthumb.c
  59. 1 1
      py/nlrx64.c
  60. 1 1
      py/nlrx86.c
  61. 1 1
      py/nlrxtensa.c
  62. 0 9
      py/obj.c
  63. 1 14
      py/obj.h
  64. 21 21
      py/objarray.c
  65. 4 4
      py/objattrtuple.c
  66. 4 4
      py/objbool.c
  67. 5 5
      py/objboundmeth.c
  68. 2 2
      py/objcell.c
  69. 4 4
      py/objclosure.c
  70. 5 5
      py/objcomplex.c
  71. 28 175
      py/objdeque.c
  72. 45 45
      py/objdict.c
  73. 3 3
      py/objenumerate.c
  74. 3 3
      py/objexcept.c
  75. 2 2
      py/objfilter.c
  76. 5 5
      py/objfloat.c
  77. 51 45
      py/objfun.c
  78. 2 63
      py/objfun.h
  79. 30 21
      py/objgenerator.c
  80. 2 2
      py/objgetitemiter.c
  81. 10 10
      py/objint.c
  82. 2 2
      py/objint_mpz.c
  83. 35 35
      py/objlist.c
  84. 3 3
      py/objmap.c
  85. 7 7
      py/objmodule.c
  86. 7 7
      py/objnamedtuple.c
  87. 1 1
      py/objnone.c
  88. 12 12
      py/objobject.c
  89. 5 5
      py/objpolyiter.c
  90. 9 9
      py/objproperty.c
  91. 11 11
      py/objrange.c
  92. 2 2
      py/objreversed.c
  93. 52 52
      py/objset.c
  94. 1 1
      py/objsingleton.c
  95. 7 7
      py/objslice.c
  96. 60 60
      py/objstr.c
  97. 0 2
      py/objstr.h
  98. 14 14
      py/objstringio.c
  99. 7 7
      py/objstrunicode.c
  100. 10 10
      py/objtuple.c

+ 16 - 16
extmod/modjson.c

@@ -41,7 +41,7 @@ enum {
     DUMP_MODE_TO_STREAM = 2,
 };
 
-static mp_obj_t mod_json_dump_helper(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args, unsigned int mode) {
+STATIC mp_obj_t mod_json_dump_helper(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args, unsigned int mode) {
     enum { ARG_separators };
     static const mp_arg_t allowed_args[] = {
         { MP_QSTR_separators, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_rom_obj = MP_ROM_NONE} },
@@ -78,34 +78,34 @@ static mp_obj_t mod_json_dump_helper(size_t n_args, const mp_obj_t *pos_args, mp
     }
 }
 
-static mp_obj_t mod_json_dump(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
+STATIC mp_obj_t mod_json_dump(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
     return mod_json_dump_helper(n_args, pos_args, kw_args, DUMP_MODE_TO_STREAM);
 }
-static MP_DEFINE_CONST_FUN_OBJ_KW(mod_json_dump_obj, 2, mod_json_dump);
+STATIC MP_DEFINE_CONST_FUN_OBJ_KW(mod_json_dump_obj, 2, mod_json_dump);
 
-static mp_obj_t mod_json_dumps(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
+STATIC mp_obj_t mod_json_dumps(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
     return mod_json_dump_helper(n_args, pos_args, kw_args, DUMP_MODE_TO_STRING);
 }
-static MP_DEFINE_CONST_FUN_OBJ_KW(mod_json_dumps_obj, 1, mod_json_dumps);
+STATIC MP_DEFINE_CONST_FUN_OBJ_KW(mod_json_dumps_obj, 1, mod_json_dumps);
 
 #else
 
-static mp_obj_t mod_json_dump(mp_obj_t obj, mp_obj_t stream) {
+STATIC mp_obj_t mod_json_dump(mp_obj_t obj, mp_obj_t stream) {
     mp_get_stream_raise(stream, MP_STREAM_OP_WRITE);
     mp_print_t print = {MP_OBJ_TO_PTR(stream), mp_stream_write_adaptor};
     mp_obj_print_helper(&print, obj, PRINT_JSON);
     return mp_const_none;
 }
-static MP_DEFINE_CONST_FUN_OBJ_2(mod_json_dump_obj, mod_json_dump);
+STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_json_dump_obj, mod_json_dump);
 
-static mp_obj_t mod_json_dumps(mp_obj_t obj) {
+STATIC mp_obj_t mod_json_dumps(mp_obj_t obj) {
     vstr_t vstr;
     mp_print_t print;
     vstr_init_print(&vstr, 8, &print);
     mp_obj_print_helper(&print, obj, PRINT_JSON);
     return mp_obj_new_str_from_utf8_vstr(&vstr);
 }
-static MP_DEFINE_CONST_FUN_OBJ_1(mod_json_dumps_obj, mod_json_dumps);
+STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_json_dumps_obj, mod_json_dumps);
 
 #endif
 
@@ -134,7 +134,7 @@ typedef struct _json_stream_t {
 #define S_CUR(s) ((s).cur)
 #define S_NEXT(s) (json_stream_next(&(s)))
 
-static byte json_stream_next(json_stream_t *s) {
+STATIC byte json_stream_next(json_stream_t *s) {
     mp_uint_t ret = s->read(s->stream_obj, &s->cur, 1, &s->errcode);
     if (s->errcode != 0) {
         mp_raise_OSError(s->errcode);
@@ -145,7 +145,7 @@ static byte json_stream_next(json_stream_t *s) {
     return s->cur;
 }
 
-static mp_obj_t mod_json_load(mp_obj_t stream_obj) {
+STATIC mp_obj_t mod_json_load(mp_obj_t stream_obj) {
     const mp_stream_p_t *stream_p = mp_get_stream_raise(stream_obj, MP_STREAM_OP_READ);
     json_stream_t s = {stream_obj, stream_p->read, 0, 0};
     vstr_t vstr;
@@ -355,18 +355,18 @@ success:
 fail:
     mp_raise_ValueError(MP_ERROR_TEXT("syntax error in JSON"));
 }
-static MP_DEFINE_CONST_FUN_OBJ_1(mod_json_load_obj, mod_json_load);
+STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_json_load_obj, mod_json_load);
 
-static mp_obj_t mod_json_loads(mp_obj_t obj) {
+STATIC mp_obj_t mod_json_loads(mp_obj_t obj) {
     mp_buffer_info_t bufinfo;
     mp_get_buffer_raise(obj, &bufinfo, MP_BUFFER_READ);
     vstr_t vstr = {bufinfo.len, bufinfo.len, (char *)bufinfo.buf, true};
     mp_obj_stringio_t sio = {{&mp_type_stringio}, &vstr, 0, MP_OBJ_NULL};
     return mod_json_load(MP_OBJ_FROM_PTR(&sio));
 }
-static MP_DEFINE_CONST_FUN_OBJ_1(mod_json_loads_obj, mod_json_loads);
+STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_json_loads_obj, mod_json_loads);
 
-static const mp_rom_map_elem_t mp_module_json_globals_table[] = {
+STATIC const mp_rom_map_elem_t mp_module_json_globals_table[] = {
     { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_json) },
     { MP_ROM_QSTR(MP_QSTR_dump), MP_ROM_PTR(&mod_json_dump_obj) },
     { MP_ROM_QSTR(MP_QSTR_dumps), MP_ROM_PTR(&mod_json_dumps_obj) },
@@ -374,7 +374,7 @@ static const mp_rom_map_elem_t mp_module_json_globals_table[] = {
     { MP_ROM_QSTR(MP_QSTR_loads), MP_ROM_PTR(&mod_json_loads_obj) },
 };
 
-static MP_DEFINE_CONST_DICT(mp_module_json_globals, mp_module_json_globals_table);
+STATIC MP_DEFINE_CONST_DICT(mp_module_json_globals, mp_module_json_globals_table);
 
 const mp_obj_module_t mp_module_json = {
     .base = { &mp_type_module },

+ 32 - 32
extmod/modrandom.c

@@ -46,16 +46,16 @@
 #if !MICROPY_ENABLE_DYNRUNTIME
 #if SEED_ON_IMPORT
 // If the state is seeded on import then keep these variables in the BSS.
-static uint32_t yasmarang_pad, yasmarang_n, yasmarang_d;
-static uint8_t yasmarang_dat;
+STATIC uint32_t yasmarang_pad, yasmarang_n, yasmarang_d;
+STATIC uint8_t yasmarang_dat;
 #else
 // Without seed-on-import these variables must be initialised via the data section.
-static uint32_t yasmarang_pad = 0xeda4baba, yasmarang_n = 69, yasmarang_d = 233;
-static uint8_t yasmarang_dat = 0;
+STATIC uint32_t yasmarang_pad = 0xeda4baba, yasmarang_n = 69, yasmarang_d = 233;
+STATIC uint8_t yasmarang_dat = 0;
 #endif
 #endif
 
-static uint32_t yasmarang(void) {
+STATIC uint32_t yasmarang(void) {
     yasmarang_pad += yasmarang_dat + yasmarang_d * yasmarang_n;
     yasmarang_pad = (yasmarang_pad << 3) + (yasmarang_pad >> 29);
     yasmarang_n = yasmarang_pad | 2;
@@ -71,7 +71,7 @@ static uint32_t yasmarang(void) {
 
 // returns an unsigned integer below the given argument
 // n must not be zero
-static uint32_t yasmarang_randbelow(uint32_t n) {
+STATIC uint32_t yasmarang_randbelow(uint32_t n) {
     uint32_t mask = 1;
     while ((n & mask) < n) {
         mask = (mask << 1) | 1;
@@ -85,8 +85,8 @@ static uint32_t yasmarang_randbelow(uint32_t n) {
 
 #endif
 
-static mp_obj_t mod_random_getrandbits(mp_obj_t num_in) {
-    mp_int_t n = mp_obj_get_int(num_in);
+STATIC mp_obj_t mod_random_getrandbits(mp_obj_t num_in) {
+    int n = mp_obj_get_int(num_in);
     if (n > 32 || n < 0) {
         mp_raise_ValueError(MP_ERROR_TEXT("bits must be 32 or less"));
     }
@@ -98,9 +98,9 @@ static mp_obj_t mod_random_getrandbits(mp_obj_t num_in) {
     mask >>= (32 - n);
     return mp_obj_new_int_from_uint(yasmarang() & mask);
 }
-static MP_DEFINE_CONST_FUN_OBJ_1(mod_random_getrandbits_obj, mod_random_getrandbits);
+STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_random_getrandbits_obj, mod_random_getrandbits);
 
-static mp_obj_t mod_random_seed(size_t n_args, const mp_obj_t *args) {
+STATIC mp_obj_t mod_random_seed(size_t n_args, const mp_obj_t *args) {
     mp_uint_t seed;
     if (n_args == 0 || args[0] == mp_const_none) {
         #ifdef MICROPY_PY_RANDOM_SEED_INIT_FUNC
@@ -111,22 +111,22 @@ static mp_obj_t mod_random_seed(size_t n_args, const mp_obj_t *args) {
     } else {
         seed = mp_obj_get_int_truncated(args[0]);
     }
-    yasmarang_pad = (uint32_t)seed;
+    yasmarang_pad = seed;
     yasmarang_n = 69;
     yasmarang_d = 233;
     yasmarang_dat = 0;
     return mp_const_none;
 }
-static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_random_seed_obj, 0, 1, mod_random_seed);
+STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_random_seed_obj, 0, 1, mod_random_seed);
 
 #if MICROPY_PY_RANDOM_EXTRA_FUNCS
 
-static mp_obj_t mod_random_randrange(size_t n_args, const mp_obj_t *args) {
+STATIC mp_obj_t mod_random_randrange(size_t n_args, const mp_obj_t *args) {
     mp_int_t start = mp_obj_get_int(args[0]);
     if (n_args == 1) {
         // range(stop)
         if (start > 0) {
-            return mp_obj_new_int(yasmarang_randbelow((uint32_t)start));
+            return mp_obj_new_int(yasmarang_randbelow(start));
         } else {
             goto error;
         }
@@ -135,7 +135,7 @@ static mp_obj_t mod_random_randrange(size_t n_args, const mp_obj_t *args) {
         if (n_args == 2) {
             // range(start, stop)
             if (start < stop) {
-                return mp_obj_new_int(start + yasmarang_randbelow((uint32_t)(stop - start)));
+                return mp_obj_new_int(start + yasmarang_randbelow(stop - start));
             } else {
                 goto error;
             }
@@ -151,7 +151,7 @@ static mp_obj_t mod_random_randrange(size_t n_args, const mp_obj_t *args) {
                 goto error;
             }
             if (n > 0) {
-                return mp_obj_new_int(start + step * yasmarang_randbelow((uint32_t)n));
+                return mp_obj_new_int(start + step * yasmarang_randbelow(n));
             } else {
                 goto error;
             }
@@ -161,33 +161,33 @@ static mp_obj_t mod_random_randrange(size_t n_args, const mp_obj_t *args) {
 error:
     mp_raise_ValueError(NULL);
 }
-static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_random_randrange_obj, 1, 3, mod_random_randrange);
+STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_random_randrange_obj, 1, 3, mod_random_randrange);
 
-static mp_obj_t mod_random_randint(mp_obj_t a_in, mp_obj_t b_in) {
+STATIC mp_obj_t mod_random_randint(mp_obj_t a_in, mp_obj_t b_in) {
     mp_int_t a = mp_obj_get_int(a_in);
     mp_int_t b = mp_obj_get_int(b_in);
     if (a <= b) {
-        return mp_obj_new_int(a + yasmarang_randbelow((uint32_t)(b - a + 1)));
+        return mp_obj_new_int(a + yasmarang_randbelow(b - a + 1));
     } else {
         mp_raise_ValueError(NULL);
     }
 }
-static MP_DEFINE_CONST_FUN_OBJ_2(mod_random_randint_obj, mod_random_randint);
+STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_random_randint_obj, mod_random_randint);
 
-static mp_obj_t mod_random_choice(mp_obj_t seq) {
+STATIC mp_obj_t mod_random_choice(mp_obj_t seq) {
     mp_int_t len = mp_obj_get_int(mp_obj_len(seq));
     if (len > 0) {
-        return mp_obj_subscr(seq, mp_obj_new_int(yasmarang_randbelow((uint32_t)len)), MP_OBJ_SENTINEL);
+        return mp_obj_subscr(seq, mp_obj_new_int(yasmarang_randbelow(len)), MP_OBJ_SENTINEL);
     } else {
         mp_raise_type(&mp_type_IndexError);
     }
 }
-static MP_DEFINE_CONST_FUN_OBJ_1(mod_random_choice_obj, mod_random_choice);
+STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_random_choice_obj, mod_random_choice);
 
 #if MICROPY_PY_BUILTINS_FLOAT
 
 // returns a number in the range [0..1) using Yasmarang to fill in the fraction bits
-static mp_float_t yasmarang_float(void) {
+STATIC mp_float_t yasmarang_float(void) {
     mp_float_union_t u;
     u.p.sgn = 0;
     u.p.exp = (1 << (MP_FLOAT_EXP_BITS - 1)) - 1;
@@ -199,24 +199,24 @@ static mp_float_t yasmarang_float(void) {
     return u.f - 1;
 }
 
-static mp_obj_t mod_random_random(void) {
+STATIC mp_obj_t mod_random_random(void) {
     return mp_obj_new_float(yasmarang_float());
 }
-static MP_DEFINE_CONST_FUN_OBJ_0(mod_random_random_obj, mod_random_random);
+STATIC MP_DEFINE_CONST_FUN_OBJ_0(mod_random_random_obj, mod_random_random);
 
-static mp_obj_t mod_random_uniform(mp_obj_t a_in, mp_obj_t b_in) {
+STATIC mp_obj_t mod_random_uniform(mp_obj_t a_in, mp_obj_t b_in) {
     mp_float_t a = mp_obj_get_float(a_in);
     mp_float_t b = mp_obj_get_float(b_in);
     return mp_obj_new_float(a + (b - a) * yasmarang_float());
 }
-static MP_DEFINE_CONST_FUN_OBJ_2(mod_random_uniform_obj, mod_random_uniform);
+STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_random_uniform_obj, mod_random_uniform);
 
 #endif
 
 #endif // MICROPY_PY_RANDOM_EXTRA_FUNCS
 
 #if SEED_ON_IMPORT
-static mp_obj_t mod_random___init__(void) {
+STATIC mp_obj_t mod_random___init__(void) {
     // This module may be imported by more than one name so need to ensure
     // that it's only ever seeded once.
     static bool seeded = false;
@@ -226,11 +226,11 @@ static mp_obj_t mod_random___init__(void) {
     }
     return mp_const_none;
 }
-static MP_DEFINE_CONST_FUN_OBJ_0(mod_random___init___obj, mod_random___init__);
+STATIC MP_DEFINE_CONST_FUN_OBJ_0(mod_random___init___obj, mod_random___init__);
 #endif
 
 #if !MICROPY_ENABLE_DYNRUNTIME
-static const mp_rom_map_elem_t mp_module_random_globals_table[] = {
+STATIC const mp_rom_map_elem_t mp_module_random_globals_table[] = {
     { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_random) },
     #if SEED_ON_IMPORT
     { MP_ROM_QSTR(MP_QSTR___init__), MP_ROM_PTR(&mod_random___init___obj) },
@@ -248,7 +248,7 @@ static const mp_rom_map_elem_t mp_module_random_globals_table[] = {
     #endif
 };
 
-static MP_DEFINE_CONST_DICT(mp_module_random_globals, mp_module_random_globals_table);
+STATIC MP_DEFINE_CONST_DICT(mp_module_random_globals, mp_module_random_globals_table);
 
 const mp_obj_module_t mp_module_random = {
     .base = { &mp_type_module },

+ 15 - 15
extmod/modtime.c

@@ -52,7 +52,7 @@
 // - second  is 0-59
 // - weekday is 0-6 for Mon-Sun
 // - yearday is 1-366
-static mp_obj_t time_localtime(size_t n_args, const mp_obj_t *args) {
+STATIC mp_obj_t time_localtime(size_t n_args, const mp_obj_t *args) {
     if (n_args == 0 || args[0] == mp_const_none) {
         // Get current date and time.
         return mp_time_localtime_get();
@@ -80,7 +80,7 @@ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_time_localtime_obj, 0, 1, time_localtime)
 // This is the inverse function of localtime. Its argument is a full 8-tuple
 // which expresses a time as per localtime. It returns an integer which is
 // the number of seconds since the Epoch (eg 1st Jan 1970, or 1st Jan 2000).
-static mp_obj_t time_mktime(mp_obj_t tuple) {
+STATIC mp_obj_t time_mktime(mp_obj_t tuple) {
     size_t len;
     mp_obj_t *elem;
     mp_obj_get_array(tuple, &len, &elem);
@@ -102,21 +102,21 @@ MP_DEFINE_CONST_FUN_OBJ_1(mp_time_mktime_obj, time_mktime);
 
 // time()
 // Return the number of seconds since the Epoch.
-static mp_obj_t time_time(void) {
+STATIC mp_obj_t time_time(void) {
     return mp_time_time_get();
 }
-static MP_DEFINE_CONST_FUN_OBJ_0(mp_time_time_obj, time_time);
+STATIC MP_DEFINE_CONST_FUN_OBJ_0(mp_time_time_obj, time_time);
 
 // time_ns()
 // Returns the number of nanoseconds since the Epoch, as an integer.
-static mp_obj_t time_time_ns(void) {
+STATIC mp_obj_t time_time_ns(void) {
     return mp_obj_new_int_from_ull(mp_hal_time_ns());
 }
 MP_DEFINE_CONST_FUN_OBJ_0(mp_time_time_ns_obj, time_time_ns);
 
 #endif // MICROPY_PY_TIME_TIME_TIME_NS
 
-static mp_obj_t time_sleep(mp_obj_t seconds_o) {
+STATIC mp_obj_t time_sleep(mp_obj_t seconds_o) {
     #ifdef MICROPY_PY_TIME_CUSTOM_SLEEP
     mp_time_sleep(seconds_o);
     #else
@@ -130,7 +130,7 @@ static mp_obj_t time_sleep(mp_obj_t seconds_o) {
 }
 MP_DEFINE_CONST_FUN_OBJ_1(mp_time_sleep_obj, time_sleep);
 
-static mp_obj_t time_sleep_ms(mp_obj_t arg) {
+STATIC mp_obj_t time_sleep_ms(mp_obj_t arg) {
     mp_int_t ms = mp_obj_get_int(arg);
     if (ms >= 0) {
         mp_hal_delay_ms(ms);
@@ -139,7 +139,7 @@ static mp_obj_t time_sleep_ms(mp_obj_t arg) {
 }
 MP_DEFINE_CONST_FUN_OBJ_1(mp_time_sleep_ms_obj, time_sleep_ms);
 
-static mp_obj_t time_sleep_us(mp_obj_t arg) {
+STATIC mp_obj_t time_sleep_us(mp_obj_t arg) {
     mp_int_t us = mp_obj_get_int(arg);
     if (us > 0) {
         mp_hal_delay_us(us);
@@ -148,22 +148,22 @@ static mp_obj_t time_sleep_us(mp_obj_t arg) {
 }
 MP_DEFINE_CONST_FUN_OBJ_1(mp_time_sleep_us_obj, time_sleep_us);
 
-static mp_obj_t time_ticks_ms(void) {
+STATIC mp_obj_t time_ticks_ms(void) {
     return MP_OBJ_NEW_SMALL_INT(mp_hal_ticks_ms() & (MICROPY_PY_TIME_TICKS_PERIOD - 1));
 }
 MP_DEFINE_CONST_FUN_OBJ_0(mp_time_ticks_ms_obj, time_ticks_ms);
 
-static mp_obj_t time_ticks_us(void) {
+STATIC mp_obj_t time_ticks_us(void) {
     return MP_OBJ_NEW_SMALL_INT(mp_hal_ticks_us() & (MICROPY_PY_TIME_TICKS_PERIOD - 1));
 }
 MP_DEFINE_CONST_FUN_OBJ_0(mp_time_ticks_us_obj, time_ticks_us);
 
-static mp_obj_t time_ticks_cpu(void) {
+STATIC mp_obj_t time_ticks_cpu(void) {
     return MP_OBJ_NEW_SMALL_INT(mp_hal_ticks_cpu() & (MICROPY_PY_TIME_TICKS_PERIOD - 1));
 }
 MP_DEFINE_CONST_FUN_OBJ_0(mp_time_ticks_cpu_obj, time_ticks_cpu);
 
-static mp_obj_t time_ticks_diff(mp_obj_t end_in, mp_obj_t start_in) {
+STATIC mp_obj_t time_ticks_diff(mp_obj_t end_in, mp_obj_t start_in) {
     // we assume that the arguments come from ticks_xx so are small ints
     mp_uint_t start = MP_OBJ_SMALL_INT_VALUE(start_in);
     mp_uint_t end = MP_OBJ_SMALL_INT_VALUE(end_in);
@@ -175,7 +175,7 @@ static mp_obj_t time_ticks_diff(mp_obj_t end_in, mp_obj_t start_in) {
 }
 MP_DEFINE_CONST_FUN_OBJ_2(mp_time_ticks_diff_obj, time_ticks_diff);
 
-static mp_obj_t time_ticks_add(mp_obj_t ticks_in, mp_obj_t delta_in) {
+STATIC mp_obj_t time_ticks_add(mp_obj_t ticks_in, mp_obj_t delta_in) {
     // we assume that first argument come from ticks_xx so is small int
     mp_uint_t ticks = MP_OBJ_SMALL_INT_VALUE(ticks_in);
     mp_uint_t delta = mp_obj_get_int(delta_in);
@@ -196,7 +196,7 @@ static mp_obj_t time_ticks_add(mp_obj_t ticks_in, mp_obj_t delta_in) {
 }
 MP_DEFINE_CONST_FUN_OBJ_2(mp_time_ticks_add_obj, time_ticks_add);
 
-static const mp_rom_map_elem_t mp_module_time_globals_table[] = {
+STATIC const mp_rom_map_elem_t mp_module_time_globals_table[] = {
     { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_time) },
 
     #if MICROPY_PY_TIME_GMTIME_LOCALTIME_MKTIME
@@ -224,7 +224,7 @@ static const mp_rom_map_elem_t mp_module_time_globals_table[] = {
     MICROPY_PY_TIME_EXTRA_GLOBALS
     #endif
 };
-static MP_DEFINE_CONST_DICT(mp_module_time_globals, mp_module_time_globals_table);
+STATIC MP_DEFINE_CONST_DICT(mp_module_time_globals, mp_module_time_globals_table);
 
 const mp_obj_module_t mp_module_time = {
     .base = { &mp_type_module },

+ 1 - 2
genhdr/mpversion.h

@@ -1,4 +1,3 @@
 // This file was generated by py/makeversionhdr.py
-#define MICROPY_GIT_TAG "v1.23.0-preview.322.g5114f2c1e"
-#define MICROPY_GIT_HASH "5114f2c1e"
+#define MICROPY_GIT_TAG "v1.22.2-dirty"
 #define MICROPY_BUILD_DATE "2024-04-16"

+ 317 - 317
genhdr/qstrdefs.generated.h

@@ -1,323 +1,323 @@
 // This file was automatically generated by makeqstrdata.py
 
 QDEF0(MP_QSTRnull, 0, 0, "")
-QDEF0(MP_QSTR_, 5, 0, "")
-QDEF0(MP_QSTR___dir__, 122, 7, "__dir__")
-QDEF0(MP_QSTR__0x0a_, 175, 1, "\x0a")
-QDEF0(MP_QSTR__space_, 133, 1, " ")
-QDEF0(MP_QSTR__star_, 143, 1, "*")
-QDEF0(MP_QSTR__slash_, 138, 1, "/")
-QDEF0(MP_QSTR__lt_module_gt_, 189, 8, "<module>")
-QDEF0(MP_QSTR__, 250, 1, "_")
-QDEF0(MP_QSTR___call__, 167, 8, "__call__")
-QDEF0(MP_QSTR___class__, 43, 9, "__class__")
-QDEF0(MP_QSTR___delitem__, 253, 11, "__delitem__")
-QDEF0(MP_QSTR___enter__, 109, 9, "__enter__")
-QDEF0(MP_QSTR___exit__, 69, 8, "__exit__")
-QDEF0(MP_QSTR___getattr__, 64, 11, "__getattr__")
-QDEF0(MP_QSTR___getitem__, 38, 11, "__getitem__")
-QDEF0(MP_QSTR___hash__, 247, 8, "__hash__")
-QDEF0(MP_QSTR___init__, 95, 8, "__init__")
-QDEF0(MP_QSTR___int__, 22, 7, "__int__")
-QDEF0(MP_QSTR___iter__, 207, 8, "__iter__")
-QDEF0(MP_QSTR___len__, 226, 7, "__len__")
-QDEF0(MP_QSTR___main__, 142, 8, "__main__")
-QDEF0(MP_QSTR___module__, 255, 10, "__module__")
-QDEF0(MP_QSTR___name__, 226, 8, "__name__")
-QDEF0(MP_QSTR___new__, 121, 7, "__new__")
-QDEF0(MP_QSTR___next__, 2, 8, "__next__")
+QDEF0(MP_QSTR_, 5381, 0, "")
+QDEF0(MP_QSTR___dir__, 36730, 7, "__dir__")
+QDEF0(MP_QSTR__0x0a_, 46511, 1, "\x0a")
+QDEF0(MP_QSTR__space_, 46469, 1, " ")
+QDEF0(MP_QSTR__star_, 46479, 1, "*")
+QDEF0(MP_QSTR__slash_, 46474, 1, "/")
+QDEF0(MP_QSTR__lt_module_gt_, 38077, 8, "<module>")
+QDEF0(MP_QSTR__, 46586, 1, "_")
+QDEF0(MP_QSTR___call__, 63911, 8, "__call__")
+QDEF0(MP_QSTR___class__, 50475, 9, "__class__")
+QDEF0(MP_QSTR___delitem__, 13821, 11, "__delitem__")
+QDEF0(MP_QSTR___enter__, 47725, 9, "__enter__")
+QDEF0(MP_QSTR___exit__, 63557, 8, "__exit__")
+QDEF0(MP_QSTR___getattr__, 63552, 11, "__getattr__")
+QDEF0(MP_QSTR___getitem__, 14630, 11, "__getitem__")
+QDEF0(MP_QSTR___hash__, 51447, 8, "__hash__")
+QDEF0(MP_QSTR___init__, 42335, 8, "__init__")
+QDEF0(MP_QSTR___int__, 6934, 7, "__int__")
+QDEF0(MP_QSTR___iter__, 13007, 8, "__iter__")
+QDEF0(MP_QSTR___len__, 45282, 7, "__len__")
+QDEF0(MP_QSTR___main__, 5006, 8, "__main__")
+QDEF0(MP_QSTR___module__, 12543, 10, "__module__")
+QDEF0(MP_QSTR___name__, 14562, 8, "__name__")
+QDEF0(MP_QSTR___new__, 5497, 7, "__new__")
+QDEF0(MP_QSTR___next__, 29442, 8, "__next__")
 QDEF0(MP_QSTR___qualname__, 107, 12, "__qualname__")
-QDEF0(MP_QSTR___repr__, 16, 8, "__repr__")
-QDEF0(MP_QSTR___setitem__, 50, 11, "__setitem__")
-QDEF0(MP_QSTR___str__, 208, 7, "__str__")
-QDEF0(MP_QSTR_ArithmeticError, 45, 15, "ArithmeticError")
-QDEF0(MP_QSTR_AssertionError, 151, 14, "AssertionError")
-QDEF0(MP_QSTR_AttributeError, 33, 14, "AttributeError")
-QDEF0(MP_QSTR_BaseException, 7, 13, "BaseException")
-QDEF0(MP_QSTR_EOFError, 145, 8, "EOFError")
-QDEF0(MP_QSTR_Ellipsis, 240, 8, "Ellipsis")
-QDEF0(MP_QSTR_Exception, 242, 9, "Exception")
-QDEF0(MP_QSTR_GeneratorExit, 22, 13, "GeneratorExit")
-QDEF0(MP_QSTR_ImportError, 32, 11, "ImportError")
-QDEF0(MP_QSTR_IndentationError, 92, 16, "IndentationError")
-QDEF0(MP_QSTR_IndexError, 131, 10, "IndexError")
+QDEF0(MP_QSTR___repr__, 2832, 8, "__repr__")
+QDEF0(MP_QSTR___setitem__, 15922, 11, "__setitem__")
+QDEF0(MP_QSTR___str__, 52688, 7, "__str__")
+QDEF0(MP_QSTR_ArithmeticError, 35885, 15, "ArithmeticError")
+QDEF0(MP_QSTR_AssertionError, 23191, 14, "AssertionError")
+QDEF0(MP_QSTR_AttributeError, 56865, 14, "AttributeError")
+QDEF0(MP_QSTR_BaseException, 37383, 13, "BaseException")
+QDEF0(MP_QSTR_EOFError, 49041, 8, "EOFError")
+QDEF0(MP_QSTR_Ellipsis, 57584, 8, "Ellipsis")
+QDEF0(MP_QSTR_Exception, 10738, 9, "Exception")
+QDEF0(MP_QSTR_GeneratorExit, 25110, 13, "GeneratorExit")
+QDEF0(MP_QSTR_ImportError, 39968, 11, "ImportError")
+QDEF0(MP_QSTR_IndentationError, 8284, 16, "IndentationError")
+QDEF0(MP_QSTR_IndexError, 44419, 10, "IndexError")
 QDEF0(MP_QSTR_KeyError, 234, 8, "KeyError")
-QDEF0(MP_QSTR_KeyboardInterrupt, 175, 17, "KeyboardInterrupt")
-QDEF0(MP_QSTR_LookupError, 255, 11, "LookupError")
-QDEF0(MP_QSTR_MemoryError, 220, 11, "MemoryError")
-QDEF0(MP_QSTR_NameError, 186, 9, "NameError")
-QDEF0(MP_QSTR_NoneType, 23, 8, "NoneType")
-QDEF0(MP_QSTR_NotImplementedError, 198, 19, "NotImplementedError")
-QDEF0(MP_QSTR_OSError, 161, 7, "OSError")
-QDEF0(MP_QSTR_OverflowError, 129, 13, "OverflowError")
-QDEF0(MP_QSTR_RuntimeError, 97, 12, "RuntimeError")
-QDEF0(MP_QSTR_StopIteration, 234, 13, "StopIteration")
-QDEF0(MP_QSTR_SyntaxError, 148, 11, "SyntaxError")
-QDEF0(MP_QSTR_SystemExit, 32, 10, "SystemExit")
-QDEF0(MP_QSTR_TypeError, 37, 9, "TypeError")
-QDEF0(MP_QSTR_ValueError, 150, 10, "ValueError")
-QDEF0(MP_QSTR_ZeroDivisionError, 182, 17, "ZeroDivisionError")
-QDEF0(MP_QSTR_abs, 149, 3, "abs")
-QDEF0(MP_QSTR_all, 68, 3, "all")
-QDEF0(MP_QSTR_any, 19, 3, "any")
-QDEF0(MP_QSTR_append, 107, 6, "append")
-QDEF0(MP_QSTR_args, 194, 4, "args")
-QDEF0(MP_QSTR_bool, 235, 4, "bool")
-QDEF0(MP_QSTR_builtins, 247, 8, "builtins")
-QDEF0(MP_QSTR_bytearray, 118, 9, "bytearray")
-QDEF0(MP_QSTR_bytecode, 34, 8, "bytecode")
-QDEF0(MP_QSTR_bytes, 92, 5, "bytes")
-QDEF0(MP_QSTR_callable, 13, 8, "callable")
-QDEF0(MP_QSTR_chr, 220, 3, "chr")
-QDEF0(MP_QSTR_classmethod, 180, 11, "classmethod")
-QDEF0(MP_QSTR_clear, 124, 5, "clear")
-QDEF0(MP_QSTR_close, 51, 5, "close")
-QDEF0(MP_QSTR_const, 192, 5, "const")
-QDEF0(MP_QSTR_copy, 224, 4, "copy")
-QDEF0(MP_QSTR_count, 166, 5, "count")
-QDEF0(MP_QSTR_dict, 63, 4, "dict")
-QDEF0(MP_QSTR_dir, 250, 3, "dir")
-QDEF0(MP_QSTR_divmod, 184, 6, "divmod")
-QDEF0(MP_QSTR_end, 10, 3, "end")
-QDEF0(MP_QSTR_endswith, 27, 8, "endswith")
-QDEF0(MP_QSTR_eval, 155, 4, "eval")
-QDEF0(MP_QSTR_exec, 30, 4, "exec")
-QDEF0(MP_QSTR_extend, 99, 6, "extend")
-QDEF0(MP_QSTR_find, 1, 4, "find")
-QDEF0(MP_QSTR_format, 38, 6, "format")
-QDEF0(MP_QSTR_from_bytes, 53, 10, "from_bytes")
-QDEF0(MP_QSTR_get, 51, 3, "get")
-QDEF0(MP_QSTR_getattr, 192, 7, "getattr")
-QDEF0(MP_QSTR_globals, 157, 7, "globals")
-QDEF0(MP_QSTR_hasattr, 140, 7, "hasattr")
-QDEF0(MP_QSTR_hash, 183, 4, "hash")
-QDEF0(MP_QSTR_id, 40, 2, "id")
-QDEF0(MP_QSTR_index, 123, 5, "index")
-QDEF0(MP_QSTR_insert, 18, 6, "insert")
-QDEF0(MP_QSTR_int, 22, 3, "int")
-QDEF0(MP_QSTR_isalpha, 235, 7, "isalpha")
-QDEF0(MP_QSTR_isdigit, 168, 7, "isdigit")
-QDEF0(MP_QSTR_isinstance, 182, 10, "isinstance")
-QDEF0(MP_QSTR_islower, 252, 7, "islower")
-QDEF0(MP_QSTR_isspace, 91, 7, "isspace")
-QDEF0(MP_QSTR_issubclass, 181, 10, "issubclass")
-QDEF0(MP_QSTR_isupper, 221, 7, "isupper")
-QDEF0(MP_QSTR_items, 227, 5, "items")
-QDEF0(MP_QSTR_iter, 143, 4, "iter")
-QDEF0(MP_QSTR_join, 167, 4, "join")
-QDEF0(MP_QSTR_key, 50, 3, "key")
-QDEF0(MP_QSTR_keys, 1, 4, "keys")
-QDEF0(MP_QSTR_len, 98, 3, "len")
-QDEF0(MP_QSTR_list, 39, 4, "list")
-QDEF0(MP_QSTR_little, 137, 6, "little")
-QDEF0(MP_QSTR_locals, 59, 6, "locals")
-QDEF0(MP_QSTR_lower, 198, 5, "lower")
-QDEF0(MP_QSTR_lstrip, 229, 6, "lstrip")
-QDEF0(MP_QSTR_main, 206, 4, "main")
-QDEF0(MP_QSTR_map, 185, 3, "map")
-QDEF0(MP_QSTR_micropython, 11, 11, "micropython")
-QDEF0(MP_QSTR_next, 66, 4, "next")
-QDEF0(MP_QSTR_object, 144, 6, "object")
-QDEF0(MP_QSTR_open, 209, 4, "open")
-QDEF0(MP_QSTR_ord, 28, 3, "ord")
-QDEF0(MP_QSTR_pop, 42, 3, "pop")
-QDEF0(MP_QSTR_popitem, 191, 7, "popitem")
-QDEF0(MP_QSTR_pow, 45, 3, "pow")
-QDEF0(MP_QSTR_print, 84, 5, "print")
-QDEF0(MP_QSTR_range, 26, 5, "range")
-QDEF0(MP_QSTR_read, 183, 4, "read")
-QDEF0(MP_QSTR_readinto, 75, 8, "readinto")
-QDEF0(MP_QSTR_readline, 249, 8, "readline")
-QDEF0(MP_QSTR_remove, 99, 6, "remove")
-QDEF0(MP_QSTR_replace, 73, 7, "replace")
-QDEF0(MP_QSTR_repr, 208, 4, "repr")
-QDEF0(MP_QSTR_reverse, 37, 7, "reverse")
-QDEF0(MP_QSTR_rfind, 210, 5, "rfind")
-QDEF0(MP_QSTR_rindex, 233, 6, "rindex")
-QDEF0(MP_QSTR_round, 231, 5, "round")
+QDEF0(MP_QSTR_KeyboardInterrupt, 58031, 17, "KeyboardInterrupt")
+QDEF0(MP_QSTR_LookupError, 27135, 11, "LookupError")
+QDEF0(MP_QSTR_MemoryError, 33756, 11, "MemoryError")
+QDEF0(MP_QSTR_NameError, 11706, 9, "NameError")
+QDEF0(MP_QSTR_NoneType, 26647, 8, "NoneType")
+QDEF0(MP_QSTR_NotImplementedError, 39110, 19, "NotImplementedError")
+QDEF0(MP_QSTR_OSError, 26017, 7, "OSError")
+QDEF0(MP_QSTR_OverflowError, 57729, 13, "OverflowError")
+QDEF0(MP_QSTR_RuntimeError, 61793, 12, "RuntimeError")
+QDEF0(MP_QSTR_StopIteration, 7402, 13, "StopIteration")
+QDEF0(MP_QSTR_SyntaxError, 36756, 11, "SyntaxError")
+QDEF0(MP_QSTR_SystemExit, 65312, 10, "SystemExit")
+QDEF0(MP_QSTR_TypeError, 38437, 9, "TypeError")
+QDEF0(MP_QSTR_ValueError, 34710, 10, "ValueError")
+QDEF0(MP_QSTR_ZeroDivisionError, 10166, 17, "ZeroDivisionError")
+QDEF0(MP_QSTR_abs, 12949, 3, "abs")
+QDEF0(MP_QSTR_all, 13124, 3, "all")
+QDEF0(MP_QSTR_any, 13075, 3, "any")
+QDEF0(MP_QSTR_append, 38763, 6, "append")
+QDEF0(MP_QSTR_args, 50882, 4, "args")
+QDEF0(MP_QSTR_bool, 15595, 4, "bool")
+QDEF0(MP_QSTR_builtins, 12791, 8, "builtins")
+QDEF0(MP_QSTR_bytearray, 41846, 9, "bytearray")
+QDEF0(MP_QSTR_bytecode, 32034, 8, "bytecode")
+QDEF0(MP_QSTR_bytes, 45660, 5, "bytes")
+QDEF0(MP_QSTR_callable, 28685, 8, "callable")
+QDEF0(MP_QSTR_chr, 19676, 3, "chr")
+QDEF0(MP_QSTR_classmethod, 36020, 11, "classmethod")
+QDEF0(MP_QSTR_clear, 41084, 5, "clear")
+QDEF0(MP_QSTR_close, 26419, 5, "close")
+QDEF0(MP_QSTR_const, 65472, 5, "const")
+QDEF0(MP_QSTR_copy, 56288, 4, "copy")
+QDEF0(MP_QSTR_count, 19878, 5, "count")
+QDEF0(MP_QSTR_dict, 64575, 4, "dict")
+QDEF0(MP_QSTR_dir, 7930, 3, "dir")
+QDEF0(MP_QSTR_divmod, 1208, 6, "divmod")
+QDEF0(MP_QSTR_end, 8970, 3, "end")
+QDEF0(MP_QSTR_endswith, 41755, 8, "endswith")
+QDEF0(MP_QSTR_eval, 42651, 4, "eval")
+QDEF0(MP_QSTR_exec, 49182, 4, "exec")
+QDEF0(MP_QSTR_extend, 59491, 6, "extend")
+QDEF0(MP_QSTR_find, 13312, 4, "find")
+QDEF0(MP_QSTR_format, 13094, 6, "format")
+QDEF0(MP_QSTR_from_bytes, 29749, 10, "from_bytes")
+QDEF0(MP_QSTR_get, 15155, 3, "get")
+QDEF0(MP_QSTR_getattr, 6080, 7, "getattr")
+QDEF0(MP_QSTR_globals, 18845, 7, "globals")
+QDEF0(MP_QSTR_hasattr, 45196, 7, "hasattr")
+QDEF0(MP_QSTR_hash, 28855, 4, "hash")
+QDEF0(MP_QSTR_id, 28456, 2, "id")
+QDEF0(MP_QSTR_index, 10363, 5, "index")
+QDEF0(MP_QSTR_insert, 21522, 6, "insert")
+QDEF0(MP_QSTR_int, 21270, 3, "int")
+QDEF0(MP_QSTR_isalpha, 14315, 7, "isalpha")
+QDEF0(MP_QSTR_isdigit, 39592, 7, "isdigit")
+QDEF0(MP_QSTR_isinstance, 48822, 10, "isinstance")
+QDEF0(MP_QSTR_islower, 33020, 7, "islower")
+QDEF0(MP_QSTR_isspace, 63579, 7, "isspace")
+QDEF0(MP_QSTR_issubclass, 32693, 10, "issubclass")
+QDEF0(MP_QSTR_isupper, 42973, 7, "isupper")
+QDEF0(MP_QSTR_items, 21475, 5, "items")
+QDEF0(MP_QSTR_iter, 8591, 4, "iter")
+QDEF0(MP_QSTR_join, 23719, 4, "join")
+QDEF0(MP_QSTR_key, 27954, 3, "key")
+QDEF0(MP_QSTR_keys, 4865, 4, "keys")
+QDEF0(MP_QSTR_len, 16482, 3, "len")
+QDEF0(MP_QSTR_list, 7463, 4, "list")
+QDEF0(MP_QSTR_little, 27273, 6, "little")
+QDEF0(MP_QSTR_locals, 41275, 6, "locals")
+QDEF0(MP_QSTR_lower, 52166, 5, "lower")
+QDEF0(MP_QSTR_lstrip, 47589, 6, "lstrip")
+QDEF0(MP_QSTR_main, 47054, 4, "main")
+QDEF0(MP_QSTR_map, 17337, 3, "map")
+QDEF0(MP_QSTR_micropython, 31755, 11, "micropython")
+QDEF0(MP_QSTR_next, 34882, 4, "next")
+QDEF0(MP_QSTR_object, 36240, 6, "object")
+QDEF0(MP_QSTR_open, 15057, 4, "open")
+QDEF0(MP_QSTR_ord, 24092, 3, "ord")
+QDEF0(MP_QSTR_pop, 29482, 3, "pop")
+QDEF0(MP_QSTR_popitem, 11455, 7, "popitem")
+QDEF0(MP_QSTR_pow, 29485, 3, "pow")
+QDEF0(MP_QSTR_print, 50772, 5, "print")
+QDEF0(MP_QSTR_range, 24090, 5, "range")
+QDEF0(MP_QSTR_read, 63927, 4, "read")
+QDEF0(MP_QSTR_readinto, 48971, 8, "readinto")
+QDEF0(MP_QSTR_readline, 6649, 8, "readline")
+QDEF0(MP_QSTR_remove, 35427, 6, "remove")
+QDEF0(MP_QSTR_replace, 9545, 7, "replace")
+QDEF0(MP_QSTR_repr, 63440, 4, "repr")
+QDEF0(MP_QSTR_reverse, 10789, 7, "reverse")
+QDEF0(MP_QSTR_rfind, 40146, 5, "rfind")
+QDEF0(MP_QSTR_rindex, 11241, 6, "rindex")
+QDEF0(MP_QSTR_round, 9703, 5, "round")
 QDEF0(MP_QSTR_rsplit, 165, 6, "rsplit")
-QDEF0(MP_QSTR_rstrip, 59, 6, "rstrip")
-QDEF0(MP_QSTR_self, 121, 4, "self")
-QDEF0(MP_QSTR_send, 185, 4, "send")
-QDEF0(MP_QSTR_sep, 35, 3, "sep")
-QDEF0(MP_QSTR_set, 39, 3, "set")
-QDEF0(MP_QSTR_setattr, 212, 7, "setattr")
-QDEF0(MP_QSTR_setdefault, 108, 10, "setdefault")
-QDEF0(MP_QSTR_sort, 191, 4, "sort")
-QDEF0(MP_QSTR_sorted, 94, 6, "sorted")
-QDEF0(MP_QSTR_split, 183, 5, "split")
-QDEF0(MP_QSTR_start, 133, 5, "start")
-QDEF0(MP_QSTR_startswith, 116, 10, "startswith")
-QDEF0(MP_QSTR_staticmethod, 98, 12, "staticmethod")
-QDEF0(MP_QSTR_step, 87, 4, "step")
-QDEF0(MP_QSTR_stop, 157, 4, "stop")
-QDEF0(MP_QSTR_str, 80, 3, "str")
-QDEF0(MP_QSTR_strip, 41, 5, "strip")
-QDEF0(MP_QSTR_sum, 46, 3, "sum")
-QDEF0(MP_QSTR_super, 196, 5, "super")
-QDEF0(MP_QSTR_throw, 179, 5, "throw")
-QDEF0(MP_QSTR_to_bytes, 216, 8, "to_bytes")
-QDEF0(MP_QSTR_tuple, 253, 5, "tuple")
-QDEF0(MP_QSTR_type, 157, 4, "type")
-QDEF0(MP_QSTR_update, 180, 6, "update")
-QDEF0(MP_QSTR_upper, 39, 5, "upper")
-QDEF0(MP_QSTR_utf_hyphen_8, 183, 5, "utf-8")
-QDEF0(MP_QSTR_value, 78, 5, "value")
-QDEF0(MP_QSTR_values, 125, 6, "values")
-QDEF0(MP_QSTR_write, 152, 5, "write")
-QDEF0(MP_QSTR_zip, 230, 3, "zip")
-QDEF1(MP_QSTR__percent__hash_o, 108, 3, "%#o")
-QDEF1(MP_QSTR__percent__hash_x, 123, 3, "%#x")
-QDEF0(MP_QSTR__lt_dictcomp_gt_, 204, 10, "<dictcomp>")
-QDEF0(MP_QSTR__lt_genexpr_gt_, 52, 9, "<genexpr>")
-QDEF0(MP_QSTR__lt_lambda_gt_, 128, 8, "<lambda>")
-QDEF0(MP_QSTR__lt_listcomp_gt_, 212, 10, "<listcomp>")
-QDEF0(MP_QSTR__lt_setcomp_gt_, 84, 9, "<setcomp>")
-QDEF1(MP_QSTR__lt_stdin_gt_, 227, 7, "<stdin>")
-QDEF1(MP_QSTR__lt_string_gt_, 82, 8, "<string>")
-QDEF1(MP_QSTR_CANVAS_ALIGN_BEGIN, 167, 18, "CANVAS_ALIGN_BEGIN")
-QDEF1(MP_QSTR_CANVAS_ALIGN_CENTER, 235, 19, "CANVAS_ALIGN_CENTER")
-QDEF1(MP_QSTR_CANVAS_ALIGN_END, 239, 16, "CANVAS_ALIGN_END")
-QDEF1(MP_QSTR_CANVAS_BLACK, 213, 12, "CANVAS_BLACK")
-QDEF1(MP_QSTR_CANVAS_FONT_PRIMARY, 242, 19, "CANVAS_FONT_PRIMARY")
-QDEF1(MP_QSTR_CANVAS_FONT_SECONDARY, 4, 21, "CANVAS_FONT_SECONDARY")
-QDEF1(MP_QSTR_CANVAS_WHITE, 53, 12, "CANVAS_WHITE")
-QDEF1(MP_QSTR_INPUT_BUTTON_BACK, 174, 17, "INPUT_BUTTON_BACK")
-QDEF1(MP_QSTR_INPUT_BUTTON_DOWN, 247, 17, "INPUT_BUTTON_DOWN")
-QDEF1(MP_QSTR_INPUT_BUTTON_LEFT, 94, 17, "INPUT_BUTTON_LEFT")
-QDEF1(MP_QSTR_INPUT_BUTTON_OK, 33, 15, "INPUT_BUTTON_OK")
-QDEF1(MP_QSTR_INPUT_BUTTON_RIGHT, 5, 18, "INPUT_BUTTON_RIGHT")
-QDEF1(MP_QSTR_INPUT_BUTTON_UP, 96, 15, "INPUT_BUTTON_UP")
-QDEF1(MP_QSTR_INPUT_TYPE_LONG, 97, 15, "INPUT_TYPE_LONG")
-QDEF1(MP_QSTR_INPUT_TYPE_PRESS, 108, 16, "INPUT_TYPE_PRESS")
-QDEF1(MP_QSTR_INPUT_TYPE_RELEASE, 34, 18, "INPUT_TYPE_RELEASE")
-QDEF1(MP_QSTR_INPUT_TYPE_REPEAT, 28, 17, "INPUT_TYPE_REPEAT")
-QDEF1(MP_QSTR_INPUT_TYPE_SHORT, 153, 16, "INPUT_TYPE_SHORT")
-QDEF1(MP_QSTR_LIGHT_BACKLIGHT, 17, 15, "LIGHT_BACKLIGHT")
-QDEF1(MP_QSTR_LIGHT_BLUE, 90, 10, "LIGHT_BLUE")
-QDEF1(MP_QSTR_LIGHT_GREEN, 95, 11, "LIGHT_GREEN")
-QDEF1(MP_QSTR_LIGHT_RED, 215, 9, "LIGHT_RED")
-QDEF0(MP_QSTR___add__, 196, 7, "__add__")
-QDEF1(MP_QSTR___bases__, 3, 9, "__bases__")
-QDEF0(MP_QSTR___bool__, 43, 8, "__bool__")
-QDEF1(MP_QSTR___build_class__, 66, 15, "__build_class__")
-QDEF0(MP_QSTR___contains__, 198, 12, "__contains__")
-QDEF1(MP_QSTR___dict__, 127, 8, "__dict__")
-QDEF0(MP_QSTR___eq__, 113, 6, "__eq__")
-QDEF1(MP_QSTR___file__, 3, 8, "__file__")
-QDEF0(MP_QSTR___float__, 53, 9, "__float__")
-QDEF0(MP_QSTR___ge__, 167, 6, "__ge__")
-QDEF1(MP_QSTR___globals__, 157, 11, "__globals__")
-QDEF0(MP_QSTR___gt__, 182, 6, "__gt__")
-QDEF0(MP_QSTR___iadd__, 109, 8, "__iadd__")
-QDEF1(MP_QSTR___import__, 56, 10, "__import__")
-QDEF0(MP_QSTR___isub__, 8, 8, "__isub__")
-QDEF0(MP_QSTR___le__, 204, 6, "__le__")
-QDEF0(MP_QSTR___lt__, 93, 6, "__lt__")
-QDEF0(MP_QSTR___ne__, 14, 6, "__ne__")
-QDEF1(MP_QSTR___path__, 200, 8, "__path__")
-QDEF1(MP_QSTR___repl_print__, 1, 14, "__repl_print__")
-QDEF1(MP_QSTR___reversed__, 97, 12, "__reversed__")
-QDEF0(MP_QSTR___sub__, 33, 7, "__sub__")
-QDEF1(MP_QSTR___traceback__, 79, 13, "__traceback__")
-QDEF1(MP_QSTR__input_trigger_handler, 108, 22, "_input_trigger_handler")
-QDEF1(MP_QSTR_add, 68, 3, "add")
-QDEF1(MP_QSTR_array, 124, 5, "array")
-QDEF1(MP_QSTR_bin, 224, 3, "bin")
-QDEF1(MP_QSTR_bound_method, 151, 12, "bound_method")
-QDEF1(MP_QSTR_canvas_clear, 107, 12, "canvas_clear")
-QDEF1(MP_QSTR_canvas_draw_box, 56, 15, "canvas_draw_box")
-QDEF1(MP_QSTR_canvas_draw_circle, 63, 18, "canvas_draw_circle")
-QDEF1(MP_QSTR_canvas_draw_disc, 176, 16, "canvas_draw_disc")
-QDEF1(MP_QSTR_canvas_draw_dot, 178, 15, "canvas_draw_dot")
-QDEF1(MP_QSTR_canvas_draw_frame, 240, 17, "canvas_draw_frame")
-QDEF1(MP_QSTR_canvas_draw_line, 67, 16, "canvas_draw_line")
-QDEF1(MP_QSTR_canvas_height, 77, 13, "canvas_height")
-QDEF1(MP_QSTR_canvas_set_color, 178, 16, "canvas_set_color")
-QDEF1(MP_QSTR_canvas_set_font, 124, 15, "canvas_set_font")
-QDEF1(MP_QSTR_canvas_set_text, 114, 15, "canvas_set_text")
-QDEF1(MP_QSTR_canvas_set_text_align, 192, 21, "canvas_set_text_align")
-QDEF1(MP_QSTR_canvas_text_height, 239, 18, "canvas_text_height")
-QDEF1(MP_QSTR_canvas_text_width, 86, 17, "canvas_text_width")
-QDEF1(MP_QSTR_canvas_update, 131, 13, "canvas_update")
-QDEF1(MP_QSTR_canvas_width, 180, 12, "canvas_width")
-QDEF1(MP_QSTR_choice, 46, 6, "choice")
-QDEF1(MP_QSTR_closure, 116, 7, "closure")
-QDEF1(MP_QSTR_collect, 155, 7, "collect")
-QDEF1(MP_QSTR_decode, 169, 6, "decode")
-QDEF1(MP_QSTR_default, 206, 7, "default")
-QDEF1(MP_QSTR_delattr, 219, 7, "delattr")
-QDEF1(MP_QSTR_deleter, 110, 7, "deleter")
-QDEF1(MP_QSTR_dict_view, 45, 9, "dict_view")
-QDEF1(MP_QSTR_difference, 114, 10, "difference")
-QDEF1(MP_QSTR_difference_update, 156, 17, "difference_update")
-QDEF1(MP_QSTR_disable, 145, 7, "disable")
-QDEF1(MP_QSTR_discard, 15, 7, "discard")
-QDEF1(MP_QSTR_doc, 45, 3, "doc")
-QDEF1(MP_QSTR_enable, 4, 6, "enable")
-QDEF1(MP_QSTR_encode, 67, 6, "encode")
-QDEF1(MP_QSTR_enumerate, 113, 9, "enumerate")
-QDEF1(MP_QSTR_errno, 193, 5, "errno")
-QDEF1(MP_QSTR_filter, 37, 6, "filter")
-QDEF1(MP_QSTR_flipperzero, 179, 11, "flipperzero")
-QDEF1(MP_QSTR_float, 53, 5, "float")
-QDEF1(MP_QSTR_fromkeys, 55, 8, "fromkeys")
-QDEF1(MP_QSTR_function, 39, 8, "function")
-QDEF1(MP_QSTR_gc, 97, 2, "gc")
-QDEF1(MP_QSTR_generator, 150, 9, "generator")
-QDEF1(MP_QSTR_getrandbits, 102, 11, "getrandbits")
-QDEF1(MP_QSTR_getter, 144, 6, "getter")
-QDEF1(MP_QSTR_heap_lock, 173, 9, "heap_lock")
-QDEF1(MP_QSTR_heap_unlock, 86, 11, "heap_unlock")
-QDEF1(MP_QSTR_hex, 112, 3, "hex")
-QDEF1(MP_QSTR_intersection, 40, 12, "intersection")
-QDEF1(MP_QSTR_intersection_update, 6, 19, "intersection_update")
-QDEF1(MP_QSTR_isdisjoint, 247, 10, "isdisjoint")
-QDEF1(MP_QSTR_isenabled, 154, 9, "isenabled")
-QDEF1(MP_QSTR_issubset, 185, 8, "issubset")
-QDEF1(MP_QSTR_issuperset, 252, 10, "issuperset")
-QDEF1(MP_QSTR_iterable, 37, 8, "iterable")
-QDEF1(MP_QSTR_iterator, 71, 8, "iterator")
-QDEF1(MP_QSTR_light_blink_set_color, 217, 21, "light_blink_set_color")
-QDEF1(MP_QSTR_light_blink_start, 121, 17, "light_blink_start")
-QDEF1(MP_QSTR_light_blink_stop, 33, 16, "light_blink_stop")
-QDEF1(MP_QSTR_light_set, 134, 9, "light_set")
-QDEF1(MP_QSTR_max, 177, 3, "max")
-QDEF1(MP_QSTR_maximum_space_recursion_space_depth_space_exceeded, 115, 32, "maximum recursion depth exceeded")
-QDEF1(MP_QSTR_mem_alloc, 82, 9, "mem_alloc")
-QDEF1(MP_QSTR_mem_free, 203, 8, "mem_free")
-QDEF1(MP_QSTR_min, 175, 3, "min")
-QDEF1(MP_QSTR_module, 191, 6, "module")
-QDEF1(MP_QSTR_oct, 253, 3, "oct")
-QDEF1(MP_QSTR_on_input, 141, 8, "on_input")
-QDEF1(MP_QSTR_opt_level, 135, 9, "opt_level")
-QDEF1(MP_QSTR_property, 194, 8, "property")
-QDEF1(MP_QSTR_randint, 175, 7, "randint")
-QDEF1(MP_QSTR_random, 190, 6, "random")
-QDEF1(MP_QSTR_randrange, 163, 9, "randrange")
-QDEF1(MP_QSTR_rb, 213, 2, "rb")
-QDEF1(MP_QSTR_reversed, 161, 8, "reversed")
-QDEF1(MP_QSTR_schedule, 224, 8, "schedule")
-QDEF1(MP_QSTR_seed, 146, 4, "seed")
-QDEF1(MP_QSTR_setter, 4, 6, "setter")
-QDEF1(MP_QSTR_sleep, 234, 5, "sleep")
-QDEF1(MP_QSTR_sleep_ms, 11, 8, "sleep_ms")
-QDEF1(MP_QSTR_sleep_us, 19, 8, "sleep_us")
-QDEF1(MP_QSTR_slice, 181, 5, "slice")
-QDEF1(MP_QSTR_speaker_set_volume, 116, 18, "speaker_set_volume")
-QDEF1(MP_QSTR_speaker_start, 1, 13, "speaker_start")
-QDEF1(MP_QSTR_speaker_stop, 153, 12, "speaker_stop")
-QDEF1(MP_QSTR_symmetric_difference, 206, 20, "symmetric_difference")
-QDEF1(MP_QSTR_symmetric_difference_update, 96, 27, "symmetric_difference_update")
-QDEF1(MP_QSTR_threshold, 242, 9, "threshold")
-QDEF1(MP_QSTR_ticks_add, 157, 9, "ticks_add")
-QDEF1(MP_QSTR_ticks_cpu, 26, 9, "ticks_cpu")
-QDEF1(MP_QSTR_ticks_diff, 177, 10, "ticks_diff")
-QDEF1(MP_QSTR_ticks_ms, 66, 8, "ticks_ms")
-QDEF1(MP_QSTR_ticks_us, 90, 8, "ticks_us")
-QDEF1(MP_QSTR_time, 240, 4, "time")
-QDEF1(MP_QSTR_time_ns, 114, 7, "time_ns")
-QDEF1(MP_QSTR_uniform, 1, 7, "uniform")
-QDEF1(MP_QSTR_union, 246, 5, "union")
-QDEF1(MP_QSTR_vibro_set, 216, 9, "vibro_set")
-QDEF1(MP_QSTR__brace_open__colon__hash_b_brace_close_, 88, 5, "{:#b}")
+QDEF0(MP_QSTR_rstrip, 38203, 6, "rstrip")
+QDEF0(MP_QSTR_self, 30585, 4, "self")
+QDEF0(MP_QSTR_send, 30393, 4, "send")
+QDEF0(MP_QSTR_sep, 36643, 3, "sep")
+QDEF0(MP_QSTR_set, 36647, 3, "set")
+QDEF0(MP_QSTR_setattr, 43220, 7, "setattr")
+QDEF0(MP_QSTR_setdefault, 41836, 10, "setdefault")
+QDEF0(MP_QSTR_sort, 40383, 4, "sort")
+QDEF0(MP_QSTR_sorted, 5470, 6, "sorted")
+QDEF0(MP_QSTR_split, 13239, 5, "split")
+QDEF0(MP_QSTR_start, 61317, 5, "start")
+QDEF0(MP_QSTR_startswith, 59508, 10, "startswith")
+QDEF0(MP_QSTR_staticmethod, 44898, 12, "staticmethod")
+QDEF0(MP_QSTR_step, 13911, 4, "step")
+QDEF0(MP_QSTR_stop, 13981, 4, "stop")
+QDEF0(MP_QSTR_str, 36176, 3, "str")
+QDEF0(MP_QSTR_strip, 7721, 5, "strip")
+QDEF0(MP_QSTR_sum, 36142, 3, "sum")
+QDEF0(MP_QSTR_super, 45764, 5, "super")
+QDEF0(MP_QSTR_throw, 17587, 5, "throw")
+QDEF0(MP_QSTR_to_bytes, 16088, 8, "to_bytes")
+QDEF0(MP_QSTR_tuple, 16893, 5, "tuple")
+QDEF0(MP_QSTR_type, 32669, 4, "type")
+QDEF0(MP_QSTR_update, 30388, 6, "update")
+QDEF0(MP_QSTR_upper, 37927, 5, "upper")
+QDEF0(MP_QSTR_utf_hyphen_8, 33463, 5, "utf-8")
+QDEF0(MP_QSTR_value, 13390, 5, "value")
+QDEF0(MP_QSTR_values, 48765, 6, "values")
+QDEF0(MP_QSTR_write, 43160, 5, "write")
+QDEF0(MP_QSTR_zip, 44262, 3, "zip")
+QDEF1(MP_QSTR__percent__hash_o, 6764, 3, "%#o")
+QDEF1(MP_QSTR__percent__hash_x, 6779, 3, "%#x")
+QDEF1(MP_QSTR__lt_dictcomp_gt_, 36300, 10, "<dictcomp>")
+QDEF1(MP_QSTR__lt_genexpr_gt_, 27188, 9, "<genexpr>")
+QDEF1(MP_QSTR__lt_lambda_gt_, 35968, 8, "<lambda>")
+QDEF1(MP_QSTR__lt_listcomp_gt_, 5588, 10, "<listcomp>")
+QDEF1(MP_QSTR__lt_setcomp_gt_, 20820, 9, "<setcomp>")
+QDEF1(MP_QSTR__lt_stdin_gt_, 25571, 7, "<stdin>")
+QDEF1(MP_QSTR__lt_string_gt_, 21330, 8, "<string>")
+QDEF1(MP_QSTR_CANVAS_ALIGN_BEGIN, 40103, 18, "CANVAS_ALIGN_BEGIN")
+QDEF1(MP_QSTR_CANVAS_ALIGN_CENTER, 1771, 19, "CANVAS_ALIGN_CENTER")
+QDEF1(MP_QSTR_CANVAS_ALIGN_END, 49391, 16, "CANVAS_ALIGN_END")
+QDEF1(MP_QSTR_CANVAS_BLACK, 34261, 12, "CANVAS_BLACK")
+QDEF1(MP_QSTR_CANVAS_FONT_PRIMARY, 35826, 19, "CANVAS_FONT_PRIMARY")
+QDEF1(MP_QSTR_CANVAS_FONT_SECONDARY, 58372, 21, "CANVAS_FONT_SECONDARY")
+QDEF1(MP_QSTR_CANVAS_WHITE, 11573, 12, "CANVAS_WHITE")
+QDEF1(MP_QSTR_INPUT_BUTTON_BACK, 3502, 17, "INPUT_BUTTON_BACK")
+QDEF1(MP_QSTR_INPUT_BUTTON_DOWN, 53239, 17, "INPUT_BUTTON_DOWN")
+QDEF1(MP_QSTR_INPUT_BUTTON_LEFT, 5982, 17, "INPUT_BUTTON_LEFT")
+QDEF1(MP_QSTR_INPUT_BUTTON_OK, 56353, 15, "INPUT_BUTTON_OK")
+QDEF1(MP_QSTR_INPUT_BUTTON_RIGHT, 39685, 18, "INPUT_BUTTON_RIGHT")
+QDEF1(MP_QSTR_INPUT_BUTTON_UP, 56672, 15, "INPUT_BUTTON_UP")
+QDEF1(MP_QSTR_INPUT_TYPE_LONG, 24161, 15, "INPUT_TYPE_LONG")
+QDEF1(MP_QSTR_INPUT_TYPE_PRESS, 41324, 16, "INPUT_TYPE_PRESS")
+QDEF1(MP_QSTR_INPUT_TYPE_RELEASE, 65058, 18, "INPUT_TYPE_RELEASE")
+QDEF1(MP_QSTR_INPUT_TYPE_REPEAT, 64028, 17, "INPUT_TYPE_REPEAT")
+QDEF1(MP_QSTR_INPUT_TYPE_SHORT, 8601, 16, "INPUT_TYPE_SHORT")
+QDEF1(MP_QSTR_LIGHT_BACKLIGHT, 18705, 15, "LIGHT_BACKLIGHT")
+QDEF1(MP_QSTR_LIGHT_BLUE, 64346, 10, "LIGHT_BLUE")
+QDEF1(MP_QSTR_LIGHT_GREEN, 32095, 11, "LIGHT_GREEN")
+QDEF1(MP_QSTR_LIGHT_RED, 54999, 9, "LIGHT_RED")
+QDEF0(MP_QSTR___add__, 33476, 7, "__add__")
+QDEF1(MP_QSTR___bases__, 12291, 9, "__bases__")
+QDEF0(MP_QSTR___bool__, 25899, 8, "__bool__")
+QDEF1(MP_QSTR___build_class__, 34882, 15, "__build_class__")
+QDEF0(MP_QSTR___contains__, 24518, 12, "__contains__")
+QDEF1(MP_QSTR___dict__, 21631, 8, "__dict__")
+QDEF0(MP_QSTR___eq__, 15985, 6, "__eq__")
+QDEF1(MP_QSTR___file__, 21507, 8, "__file__")
+QDEF0(MP_QSTR___float__, 28725, 9, "__float__")
+QDEF0(MP_QSTR___ge__, 18087, 6, "__ge__")
+QDEF1(MP_QSTR___globals__, 44701, 11, "__globals__")
+QDEF0(MP_QSTR___gt__, 33462, 6, "__gt__")
+QDEF0(MP_QSTR___iadd__, 19053, 8, "__iadd__")
+QDEF1(MP_QSTR___import__, 15928, 10, "__import__")
+QDEF0(MP_QSTR___isub__, 30728, 8, "__isub__")
+QDEF0(MP_QSTR___le__, 5068, 6, "__le__")
+QDEF0(MP_QSTR___lt__, 26717, 6, "__lt__")
+QDEF0(MP_QSTR___ne__, 2830, 6, "__ne__")
+QDEF1(MP_QSTR___path__, 9160, 8, "__path__")
+QDEF1(MP_QSTR___repl_print__, 47872, 14, "__repl_print__")
+QDEF1(MP_QSTR___reversed__, 65377, 12, "__reversed__")
+QDEF0(MP_QSTR___sub__, 2337, 7, "__sub__")
+QDEF1(MP_QSTR___traceback__, 53071, 13, "__traceback__")
+QDEF1(MP_QSTR__input_trigger_handler, 50540, 22, "_input_trigger_handler")
+QDEF1(MP_QSTR_add, 12868, 3, "add")
+QDEF1(MP_QSTR_array, 29308, 5, "array")
+QDEF1(MP_QSTR_bin, 18656, 3, "bin")
+QDEF1(MP_QSTR_bound_method, 41623, 12, "bound_method")
+QDEF1(MP_QSTR_canvas_clear, 30827, 12, "canvas_clear")
+QDEF1(MP_QSTR_canvas_draw_box, 52536, 15, "canvas_draw_box")
+QDEF1(MP_QSTR_canvas_draw_circle, 4671, 18, "canvas_draw_circle")
+QDEF1(MP_QSTR_canvas_draw_disc, 12976, 16, "canvas_draw_disc")
+QDEF1(MP_QSTR_canvas_draw_dot, 42162, 15, "canvas_draw_dot")
+QDEF1(MP_QSTR_canvas_draw_frame, 4592, 17, "canvas_draw_frame")
+QDEF1(MP_QSTR_canvas_draw_line, 4419, 16, "canvas_draw_line")
+QDEF1(MP_QSTR_canvas_height, 65357, 13, "canvas_height")
+QDEF1(MP_QSTR_canvas_set_color, 9394, 16, "canvas_set_color")
+QDEF1(MP_QSTR_canvas_set_font, 57212, 15, "canvas_set_font")
+QDEF1(MP_QSTR_canvas_set_text, 1394, 15, "canvas_set_text")
+QDEF1(MP_QSTR_canvas_set_text_align, 56000, 21, "canvas_set_text_align")
+QDEF1(MP_QSTR_canvas_text_height, 18415, 18, "canvas_text_height")
+QDEF1(MP_QSTR_canvas_text_width, 2390, 17, "canvas_text_width")
+QDEF1(MP_QSTR_canvas_update, 21379, 13, "canvas_update")
+QDEF1(MP_QSTR_canvas_width, 41652, 12, "canvas_width")
+QDEF1(MP_QSTR_choice, 13102, 6, "choice")
+QDEF1(MP_QSTR_closure, 51828, 7, "closure")
+QDEF1(MP_QSTR_collect, 26011, 7, "collect")
+QDEF1(MP_QSTR_decode, 22953, 6, "decode")
+QDEF1(MP_QSTR_default, 32206, 7, "default")
+QDEF1(MP_QSTR_delattr, 51419, 7, "delattr")
+QDEF1(MP_QSTR_deleter, 56174, 7, "deleter")
+QDEF1(MP_QSTR_dict_view, 43309, 9, "dict_view")
+QDEF1(MP_QSTR_difference, 9330, 10, "difference")
+QDEF1(MP_QSTR_difference_update, 64156, 17, "difference_update")
+QDEF1(MP_QSTR_disable, 30353, 7, "disable")
+QDEF1(MP_QSTR_discard, 28943, 7, "discard")
+QDEF1(MP_QSTR_doc, 7981, 3, "doc")
+QDEF1(MP_QSTR_enable, 56836, 6, "enable")
+QDEF1(MP_QSTR_encode, 51779, 6, "encode")
+QDEF1(MP_QSTR_enumerate, 47729, 9, "enumerate")
+QDEF1(MP_QSTR_errno, 4545, 5, "errno")
+QDEF1(MP_QSTR_filter, 48677, 6, "filter")
+QDEF1(MP_QSTR_flipperzero, 60083, 11, "flipperzero")
+QDEF1(MP_QSTR_float, 17461, 5, "float")
+QDEF1(MP_QSTR_fromkeys, 48439, 8, "fromkeys")
+QDEF1(MP_QSTR_function, 551, 8, "function")
+QDEF1(MP_QSTR_gc, 28257, 2, "gc")
+QDEF1(MP_QSTR_generator, 50070, 9, "generator")
+QDEF1(MP_QSTR_getrandbits, 32102, 11, "getrandbits")
+QDEF1(MP_QSTR_getter, 45712, 6, "getter")
+QDEF1(MP_QSTR_heap_lock, 36013, 9, "heap_lock")
+QDEF1(MP_QSTR_heap_unlock, 11606, 11, "heap_unlock")
+QDEF1(MP_QSTR_hex, 20592, 3, "hex")
+QDEF1(MP_QSTR_intersection, 10792, 12, "intersection")
+QDEF1(MP_QSTR_intersection_update, 56582, 19, "intersection_update")
+QDEF1(MP_QSTR_isdisjoint, 26871, 10, "isdisjoint")
+QDEF1(MP_QSTR_isenabled, 58778, 9, "isenabled")
+QDEF1(MP_QSTR_issubset, 49593, 8, "issubset")
+QDEF1(MP_QSTR_issuperset, 60668, 10, "issuperset")
+QDEF1(MP_QSTR_iterable, 37413, 8, "iterable")
+QDEF1(MP_QSTR_iterator, 48711, 8, "iterator")
+QDEF1(MP_QSTR_light_blink_set_color, 17369, 21, "light_blink_set_color")
+QDEF1(MP_QSTR_light_blink_start, 25721, 17, "light_blink_start")
+QDEF1(MP_QSTR_light_blink_stop, 37921, 16, "light_blink_stop")
+QDEF1(MP_QSTR_light_set, 18054, 9, "light_set")
+QDEF1(MP_QSTR_max, 17329, 3, "max")
+QDEF1(MP_QSTR_maximum_space_recursion_space_depth_space_exceeded, 7795, 32, "maximum recursion depth exceeded")
+QDEF1(MP_QSTR_mem_alloc, 11090, 9, "mem_alloc")
+QDEF1(MP_QSTR_mem_free, 25291, 8, "mem_free")
+QDEF1(MP_QSTR_min, 17071, 3, "min")
+QDEF1(MP_QSTR_module, 39359, 6, "module")
+QDEF1(MP_QSTR_oct, 23805, 3, "oct")
+QDEF1(MP_QSTR_on_input, 32141, 8, "on_input")
+QDEF1(MP_QSTR_opt_level, 26503, 9, "opt_level")
+QDEF1(MP_QSTR_property, 10690, 8, "property")
+QDEF1(MP_QSTR_randint, 56495, 7, "randint")
+QDEF1(MP_QSTR_random, 11454, 6, "random")
+QDEF1(MP_QSTR_randrange, 16035, 9, "randrange")
+QDEF1(MP_QSTR_rb, 28885, 2, "rb")
+QDEF1(MP_QSTR_reversed, 28321, 8, "reversed")
+QDEF1(MP_QSTR_schedule, 44256, 8, "schedule")
+QDEF1(MP_QSTR_seed, 30098, 4, "seed")
+QDEF1(MP_QSTR_setter, 22788, 6, "setter")
+QDEF1(MP_QSTR_sleep, 10218, 5, "sleep")
+QDEF1(MP_QSTR_sleep_ms, 25355, 8, "sleep_ms")
+QDEF1(MP_QSTR_sleep_us, 24595, 8, "sleep_us")
+QDEF1(MP_QSTR_slice, 62645, 5, "slice")
+QDEF1(MP_QSTR_speaker_set_volume, 51060, 18, "speaker_set_volume")
+QDEF1(MP_QSTR_speaker_start, 18433, 13, "speaker_start")
+QDEF1(MP_QSTR_speaker_stop, 36249, 12, "speaker_stop")
+QDEF1(MP_QSTR_symmetric_difference, 26574, 20, "symmetric_difference")
+QDEF1(MP_QSTR_symmetric_difference_update, 63584, 27, "symmetric_difference_update")
+QDEF1(MP_QSTR_threshold, 12274, 9, "threshold")
+QDEF1(MP_QSTR_ticks_add, 44701, 9, "ticks_add")
+QDEF1(MP_QSTR_ticks_cpu, 42266, 9, "ticks_cpu")
+QDEF1(MP_QSTR_ticks_diff, 57521, 10, "ticks_diff")
+QDEF1(MP_QSTR_ticks_ms, 12866, 8, "ticks_ms")
+QDEF1(MP_QSTR_ticks_us, 12634, 8, "ticks_us")
+QDEF1(MP_QSTR_time, 49648, 4, "time")
+QDEF1(MP_QSTR_time_ns, 45682, 7, "time_ns")
+QDEF1(MP_QSTR_uniform, 62721, 7, "uniform")
+QDEF1(MP_QSTR_union, 31990, 5, "union")
+QDEF1(MP_QSTR_vibro_set, 11736, 9, "vibro_set")
+QDEF1(MP_QSTR__brace_open__colon__hash_b_brace_close_, 14168, 5, "{:#b}")

+ 15 - 37
py/asmarm.c

@@ -39,7 +39,7 @@
 #define SIGNED_FIT24(x) (((x) & 0xff800000) == 0) || (((x) & 0xff000000) == 0xff000000)
 
 // Insert word into instruction flow
-static void emit(asm_arm_t *as, uint op) {
+STATIC void emit(asm_arm_t *as, uint op) {
     uint8_t *c = mp_asm_base_get_cur_to_write_bytes(&as->base, 4);
     if (c != NULL) {
         *(uint32_t *)c = op;
@@ -47,83 +47,73 @@ static void emit(asm_arm_t *as, uint op) {
 }
 
 // Insert word into instruction flow, add "ALWAYS" condition code
-static void emit_al(asm_arm_t *as, uint op) {
+STATIC void emit_al(asm_arm_t *as, uint op) {
     emit(as, op | ASM_ARM_CC_AL);
 }
 
 // Basic instructions without condition code
-static uint asm_arm_op_push(uint reglist) {
+STATIC uint asm_arm_op_push(uint reglist) {
     // stmfd sp!, {reglist}
     return 0x92d0000 | (reglist & 0xFFFF);
 }
 
-static uint asm_arm_op_pop(uint reglist) {
+STATIC uint asm_arm_op_pop(uint reglist) {
     // ldmfd sp!, {reglist}
     return 0x8bd0000 | (reglist & 0xFFFF);
 }
 
-static uint asm_arm_op_mov_reg(uint rd, uint rn) {
+STATIC uint asm_arm_op_mov_reg(uint rd, uint rn) {
     // mov rd, rn
     return 0x1a00000 | (rd << 12) | rn;
 }
 
-static uint asm_arm_op_mov_imm(uint rd, uint imm) {
+STATIC uint asm_arm_op_mov_imm(uint rd, uint imm) {
     // mov rd, #imm
     return 0x3a00000 | (rd << 12) | imm;
 }
 
-static uint asm_arm_op_mvn_imm(uint rd, uint imm) {
+STATIC uint asm_arm_op_mvn_imm(uint rd, uint imm) {
     // mvn rd, #imm
     return 0x3e00000 | (rd << 12) | imm;
 }
 
-static uint asm_arm_op_mvn_reg(uint rd, uint rm) {
-    // mvn rd, rm
-    return 0x1e00000 | (rd << 12) | rm;
-}
-
-static uint asm_arm_op_add_imm(uint rd, uint rn, uint imm) {
+STATIC uint asm_arm_op_add_imm(uint rd, uint rn, uint imm) {
     // add rd, rn, #imm
     return 0x2800000 | (rn << 16) | (rd << 12) | (imm & 0xFF);
 }
 
-static uint asm_arm_op_add_reg(uint rd, uint rn, uint rm) {
+STATIC uint asm_arm_op_add_reg(uint rd, uint rn, uint rm) {
     // add rd, rn, rm
     return 0x0800000 | (rn << 16) | (rd << 12) | rm;
 }
 
-static uint asm_arm_op_sub_imm(uint rd, uint rn, uint imm) {
+STATIC uint asm_arm_op_sub_imm(uint rd, uint rn, uint imm) {
     // sub rd, rn, #imm
     return 0x2400000 | (rn << 16) | (rd << 12) | (imm & 0xFF);
 }
 
-static uint asm_arm_op_sub_reg(uint rd, uint rn, uint rm) {
+STATIC uint asm_arm_op_sub_reg(uint rd, uint rn, uint rm) {
     // sub rd, rn, rm
     return 0x0400000 | (rn << 16) | (rd << 12) | rm;
 }
 
-static uint asm_arm_op_rsb_imm(uint rd, uint rn, uint imm) {
-    // rsb rd, rn, #imm
-    return 0x2600000 | (rn << 16) | (rd << 12) | (imm & 0xFF);
-}
-
-static uint asm_arm_op_mul_reg(uint rd, uint rm, uint rs) {
+STATIC uint asm_arm_op_mul_reg(uint rd, uint rm, uint rs) {
     // mul rd, rm, rs
     assert(rd != rm);
     return 0x0000090 | (rd << 16) | (rs << 8) | rm;
 }
 
-static uint asm_arm_op_and_reg(uint rd, uint rn, uint rm) {
+STATIC uint asm_arm_op_and_reg(uint rd, uint rn, uint rm) {
     // and rd, rn, rm
     return 0x0000000 | (rn << 16) | (rd << 12) | rm;
 }
 
-static uint asm_arm_op_eor_reg(uint rd, uint rn, uint rm) {
+STATIC uint asm_arm_op_eor_reg(uint rd, uint rn, uint rm) {
     // eor rd, rn, rm
     return 0x0200000 | (rn << 16) | (rd << 12) | rm;
 }
 
-static uint asm_arm_op_orr_reg(uint rd, uint rn, uint rm) {
+STATIC uint asm_arm_op_orr_reg(uint rd, uint rn, uint rm) {
     // orr rd, rn, rm
     return 0x1800000 | (rn << 16) | (rd << 12) | rm;
 }
@@ -238,23 +228,11 @@ void asm_arm_setcc_reg(asm_arm_t *as, uint rd, uint cond) {
     emit(as, asm_arm_op_mov_imm(rd, 0) | (cond ^ (1 << 28))); // mov!COND rd, #0
 }
 
-void asm_arm_mvn_reg_reg(asm_arm_t *as, uint rd, uint rm) {
-    // mvn rd, rm
-    // computes: rd := ~rm
-    emit_al(as, asm_arm_op_mvn_reg(rd, rm));
-}
-
 void asm_arm_add_reg_reg_reg(asm_arm_t *as, uint rd, uint rn, uint rm) {
     // add rd, rn, rm
     emit_al(as, asm_arm_op_add_reg(rd, rn, rm));
 }
 
-void asm_arm_rsb_reg_reg_imm(asm_arm_t *as, uint rd, uint rn, uint imm) {
-    // rsb rd, rn, #imm
-    // computes: rd := #imm - rn
-    emit_al(as, asm_arm_op_rsb_imm(rd, rn, imm));
-}
-
 void asm_arm_sub_reg_reg_reg(asm_arm_t *as, uint rd, uint rn, uint rm) {
     // sub rd, rn, rm
     emit_al(as, asm_arm_op_sub_reg(rd, rn, rm));

+ 0 - 4
py/asmarm.h

@@ -94,10 +94,8 @@ void asm_arm_cmp_reg_i8(asm_arm_t *as, uint rd, int imm);
 void asm_arm_cmp_reg_reg(asm_arm_t *as, uint rd, uint rn);
 
 // arithmetic
-void asm_arm_mvn_reg_reg(asm_arm_t *as, uint rd, uint rm);
 void asm_arm_add_reg_reg_reg(asm_arm_t *as, uint rd, uint rn, uint rm);
 void asm_arm_sub_reg_reg_reg(asm_arm_t *as, uint rd, uint rn, uint rm);
-void asm_arm_rsb_reg_reg_imm(asm_arm_t *as, uint rd, uint rn, uint imm);
 void asm_arm_mul_reg_reg_reg(asm_arm_t *as, uint rd, uint rn, uint rm);
 void asm_arm_and_reg_reg_reg(asm_arm_t *as, uint rd, uint rn, uint rm);
 void asm_arm_eor_reg_reg_reg(asm_arm_t *as, uint rd, uint rn, uint rm);
@@ -190,8 +188,6 @@ void asm_arm_bx_reg(asm_arm_t *as, uint reg_src);
 #define ASM_MOV_REG_LOCAL_ADDR(as, reg_dest, local_num) asm_arm_mov_reg_local_addr((as), (reg_dest), (local_num))
 #define ASM_MOV_REG_PCREL(as, reg_dest, label) asm_arm_mov_reg_pcrel((as), (reg_dest), (label))
 
-#define ASM_NOT_REG(as, reg_dest) asm_arm_mvn_reg_reg((as), (reg_dest), (reg_dest))
-#define ASM_NEG_REG(as, reg_dest) asm_arm_rsb_reg_reg_imm((as), (reg_dest), (reg_dest), 0)
 #define ASM_LSL_REG_REG(as, reg_dest, reg_shift) asm_arm_lsl_reg_reg((as), (reg_dest), (reg_shift))
 #define ASM_LSR_REG_REG(as, reg_dest, reg_shift) asm_arm_lsr_reg_reg((as), (reg_dest), (reg_shift))
 #define ASM_ASR_REG_REG(as, reg_dest, reg_shift) asm_arm_asr_reg_reg((as), (reg_dest), (reg_shift))

+ 3 - 3
py/asmthumb.c

@@ -79,7 +79,7 @@ static inline byte *asm_thumb_get_cur_to_write_bytes(asm_thumb_t *as, int n) {
 }
 
 /*
-static void asm_thumb_write_byte_1(asm_thumb_t *as, byte b1) {
+STATIC void asm_thumb_write_byte_1(asm_thumb_t *as, byte b1) {
     byte *c = asm_thumb_get_cur_to_write_bytes(as, 1);
     c[0] = b1;
 }
@@ -91,7 +91,7 @@ static void asm_thumb_write_byte_1(asm_thumb_t *as, byte b1) {
 #define IMM32_L2(x) (((x) >> 16) & 0xff)
 #define IMM32_L3(x) (((x) >> 24) & 0xff)
 
-static void asm_thumb_write_word32(asm_thumb_t *as, int w32) {
+STATIC void asm_thumb_write_word32(asm_thumb_t *as, int w32) {
     byte *c = asm_thumb_get_cur_to_write_bytes(as, 4);
     c[0] = IMM32_L0(w32);
     c[1] = IMM32_L1(w32);
@@ -216,7 +216,7 @@ void asm_thumb_exit(asm_thumb_t *as) {
     asm_thumb_op16(as, OP_POP_RLIST_PC(as->push_reglist));
 }
 
-static mp_uint_t get_label_dest(asm_thumb_t *as, uint label) {
+STATIC mp_uint_t get_label_dest(asm_thumb_t *as, uint label) {
     assert(label < as->base.max_num_labels);
     return as->base.label_offsets[label];
 }

+ 0 - 2
py/asmthumb.h

@@ -406,8 +406,6 @@ void asm_thumb_b_rel12(asm_thumb_t *as, int rel);
 #define ASM_MOV_REG_LOCAL_ADDR(as, reg_dest, local_num) asm_thumb_mov_reg_local_addr((as), (reg_dest), (local_num))
 #define ASM_MOV_REG_PCREL(as, rlo_dest, label) asm_thumb_mov_reg_pcrel((as), (rlo_dest), (label))
 
-#define ASM_NOT_REG(as, reg_dest) asm_thumb_mvn_rlo_rlo((as), (reg_dest), (reg_dest))
-#define ASM_NEG_REG(as, reg_dest) asm_thumb_neg_rlo_rlo((as), (reg_dest), (reg_dest))
 #define ASM_LSL_REG_REG(as, reg_dest, reg_shift) asm_thumb_format_4((as), ASM_THUMB_FORMAT_4_LSL, (reg_dest), (reg_shift))
 #define ASM_LSR_REG_REG(as, reg_dest, reg_shift) asm_thumb_format_4((as), ASM_THUMB_FORMAT_4_LSR, (reg_dest), (reg_shift))
 #define ASM_ASR_REG_REG(as, reg_dest, reg_shift) asm_thumb_format_4((as), ASM_THUMB_FORMAT_4_ASR, (reg_dest), (reg_shift))

+ 13 - 23
py/asmx64.c

@@ -54,8 +54,6 @@
 #define OPCODE_MOVZX_RM8_TO_R64  (0xb6) /* 0x0f 0xb6/r */
 #define OPCODE_MOVZX_RM16_TO_R64 (0xb7) /* 0x0f 0xb7/r */
 #define OPCODE_LEA_MEM_TO_R64    (0x8d) /* /r */
-#define OPCODE_NOT_RM64          (0xf7) /* /2 */
-#define OPCODE_NEG_RM64          (0xf7) /* /3 */
 #define OPCODE_AND_R64_TO_RM64   (0x21) /* /r */
 #define OPCODE_OR_R64_TO_RM64    (0x09) /* /r */
 #define OPCODE_XOR_R64_TO_RM64   (0x31) /* /r */
@@ -125,14 +123,14 @@ static inline byte *asm_x64_get_cur_to_write_bytes(asm_x64_t *as, int n) {
     return mp_asm_base_get_cur_to_write_bytes(&as->base, n);
 }
 
-static void asm_x64_write_byte_1(asm_x64_t *as, byte b1) {
+STATIC void asm_x64_write_byte_1(asm_x64_t *as, byte b1) {
     byte *c = asm_x64_get_cur_to_write_bytes(as, 1);
     if (c != NULL) {
         c[0] = b1;
     }
 }
 
-static void asm_x64_write_byte_2(asm_x64_t *as, byte b1, byte b2) {
+STATIC void asm_x64_write_byte_2(asm_x64_t *as, byte b1, byte b2) {
     byte *c = asm_x64_get_cur_to_write_bytes(as, 2);
     if (c != NULL) {
         c[0] = b1;
@@ -140,7 +138,7 @@ static void asm_x64_write_byte_2(asm_x64_t *as, byte b1, byte b2) {
     }
 }
 
-static void asm_x64_write_byte_3(asm_x64_t *as, byte b1, byte b2, byte b3) {
+STATIC void asm_x64_write_byte_3(asm_x64_t *as, byte b1, byte b2, byte b3) {
     byte *c = asm_x64_get_cur_to_write_bytes(as, 3);
     if (c != NULL) {
         c[0] = b1;
@@ -149,7 +147,7 @@ static void asm_x64_write_byte_3(asm_x64_t *as, byte b1, byte b2, byte b3) {
     }
 }
 
-static void asm_x64_write_word32(asm_x64_t *as, int w32) {
+STATIC void asm_x64_write_word32(asm_x64_t *as, int w32) {
     byte *c = asm_x64_get_cur_to_write_bytes(as, 4);
     if (c != NULL) {
         c[0] = IMM32_L0(w32);
@@ -159,7 +157,7 @@ static void asm_x64_write_word32(asm_x64_t *as, int w32) {
     }
 }
 
-static void asm_x64_write_word64(asm_x64_t *as, int64_t w64) {
+STATIC void asm_x64_write_word64(asm_x64_t *as, int64_t w64) {
     byte *c = asm_x64_get_cur_to_write_bytes(as, 8);
     if (c != NULL) {
         c[0] = IMM32_L0(w64);
@@ -174,7 +172,7 @@ static void asm_x64_write_word64(asm_x64_t *as, int64_t w64) {
 }
 
 /* unused
-static void asm_x64_write_word32_to(asm_x64_t *as, int offset, int w32) {
+STATIC void asm_x64_write_word32_to(asm_x64_t *as, int offset, int w32) {
     byte* c;
     assert(offset + 4 <= as->code_size);
     c = as->code_base + offset;
@@ -185,7 +183,7 @@ static void asm_x64_write_word32_to(asm_x64_t *as, int offset, int w32) {
 }
 */
 
-static void asm_x64_write_r64_disp(asm_x64_t *as, int r64, int disp_r64, int disp_offset) {
+STATIC void asm_x64_write_r64_disp(asm_x64_t *as, int r64, int disp_r64, int disp_offset) {
     uint8_t rm_disp;
     if (disp_offset == 0 && (disp_r64 & 7) != ASM_X64_REG_RBP) {
         rm_disp = MODRM_RM_DISP0;
@@ -206,7 +204,7 @@ static void asm_x64_write_r64_disp(asm_x64_t *as, int r64, int disp_r64, int dis
     }
 }
 
-static void asm_x64_generic_r64_r64(asm_x64_t *as, int dest_r64, int src_r64, int op) {
+STATIC void asm_x64_generic_r64_r64(asm_x64_t *as, int dest_r64, int src_r64, int op) {
     asm_x64_write_byte_3(as, REX_PREFIX | REX_W | REX_R_FROM_R64(src_r64) | REX_B_FROM_R64(dest_r64), op, MODRM_R64(src_r64) | MODRM_RM_REG | MODRM_RM_R64(dest_r64));
 }
 
@@ -245,7 +243,7 @@ void asm_x64_pop_r64(asm_x64_t *as, int dest_r64) {
     }
 }
 
-static void asm_x64_ret(asm_x64_t *as) {
+STATIC void asm_x64_ret(asm_x64_t *as) {
     asm_x64_write_byte_1(as, OPCODE_RET);
 }
 
@@ -319,7 +317,7 @@ void asm_x64_mov_mem64_to_r64(asm_x64_t *as, int src_r64, int src_disp, int dest
     asm_x64_write_r64_disp(as, dest_r64, src_r64, src_disp);
 }
 
-static void asm_x64_lea_disp_to_r64(asm_x64_t *as, int src_r64, int src_disp, int dest_r64) {
+STATIC void asm_x64_lea_disp_to_r64(asm_x64_t *as, int src_r64, int src_disp, int dest_r64) {
     // use REX prefix for 64 bit operation
     asm_x64_write_byte_2(as, REX_PREFIX | REX_W | REX_R_FROM_R64(dest_r64) | REX_B_FROM_R64(src_r64), OPCODE_LEA_MEM_TO_R64);
     asm_x64_write_r64_disp(as, dest_r64, src_r64, src_disp);
@@ -364,14 +362,6 @@ void asm_x64_mov_i64_to_r64_optimised(asm_x64_t *as, int64_t src_i64, int dest_r
     }
 }
 
-void asm_x64_not_r64(asm_x64_t *as, int dest_r64) {
-    asm_x64_generic_r64_r64(as, dest_r64, 2, OPCODE_NOT_RM64);
-}
-
-void asm_x64_neg_r64(asm_x64_t *as, int dest_r64) {
-    asm_x64_generic_r64_r64(as, dest_r64, 3, OPCODE_NEG_RM64);
-}
-
 void asm_x64_and_r64_r64(asm_x64_t *as, int dest_r64, int src_r64) {
     asm_x64_generic_r64_r64(as, dest_r64, src_r64, OPCODE_AND_R64_TO_RM64);
 }
@@ -424,7 +414,7 @@ void asm_x64_sub_i32_from_r32(asm_x64_t *as, int src_i32, int dest_r32) {
 }
 */
 
-static void asm_x64_sub_r64_i32(asm_x64_t *as, int dest_r64, int src_i32) {
+STATIC void asm_x64_sub_r64_i32(asm_x64_t *as, int dest_r64, int src_i32) {
     assert(dest_r64 < 8);
     if (SIGNED_FIT8(src_i32)) {
         // use REX prefix for 64 bit operation
@@ -490,7 +480,7 @@ void asm_x64_jmp_reg(asm_x64_t *as, int src_r64) {
     asm_x64_write_byte_2(as, OPCODE_JMP_RM64, MODRM_R64(4) | MODRM_RM_REG | MODRM_RM_R64(src_r64));
 }
 
-static mp_uint_t get_label_dest(asm_x64_t *as, mp_uint_t label) {
+STATIC mp_uint_t get_label_dest(asm_x64_t *as, mp_uint_t label) {
     assert(label < as->base.max_num_labels);
     return as->base.label_offsets[label];
 }
@@ -570,7 +560,7 @@ void asm_x64_exit(asm_x64_t *as) {
 //  ^                ^
 //  | low address    | high address in RAM
 //
-static int asm_x64_local_offset_from_rsp(asm_x64_t *as, int local_num) {
+STATIC int asm_x64_local_offset_from_rsp(asm_x64_t *as, int local_num) {
     (void)as;
     // Stack is full descending, RSP points to local0
     return local_num * WORD_SIZE;

+ 0 - 4
py/asmx64.h

@@ -97,8 +97,6 @@ void asm_x64_mov_mem8_to_r64zx(asm_x64_t *as, int src_r64, int src_disp, int des
 void asm_x64_mov_mem16_to_r64zx(asm_x64_t *as, int src_r64, int src_disp, int dest_r64);
 void asm_x64_mov_mem32_to_r64zx(asm_x64_t *as, int src_r64, int src_disp, int dest_r64);
 void asm_x64_mov_mem64_to_r64(asm_x64_t *as, int src_r64, int src_disp, int dest_r64);
-void asm_x64_not_r64(asm_x64_t *as, int dest_r64);
-void asm_x64_neg_r64(asm_x64_t *as, int dest_r64);
 void asm_x64_and_r64_r64(asm_x64_t *as, int dest_r64, int src_r64);
 void asm_x64_or_r64_r64(asm_x64_t *as, int dest_r64, int src_r64);
 void asm_x64_xor_r64_r64(asm_x64_t *as, int dest_r64, int src_r64);
@@ -193,8 +191,6 @@ void asm_x64_call_ind(asm_x64_t *as, size_t fun_id, int temp_r32);
 #define ASM_MOV_REG_LOCAL_ADDR(as, reg_dest, local_num) asm_x64_mov_local_addr_to_r64((as), (local_num), (reg_dest))
 #define ASM_MOV_REG_PCREL(as, reg_dest, label) asm_x64_mov_reg_pcrel((as), (reg_dest), (label))
 
-#define ASM_NOT_REG(as, reg) asm_x64_not_r64((as), (reg))
-#define ASM_NEG_REG(as, reg) asm_x64_neg_r64((as), (reg))
 #define ASM_LSL_REG(as, reg) asm_x64_shl_r64_cl((as), (reg))
 #define ASM_LSR_REG(as, reg) asm_x64_shr_r64_cl((as), (reg))
 #define ASM_ASR_REG(as, reg) asm_x64_sar_r64_cl((as), (reg))

+ 16 - 26
py/asmx86.c

@@ -54,8 +54,6 @@
 #define OPCODE_MOVZX_RM8_TO_R32  (0xb6) /* 0x0f 0xb6/r */
 #define OPCODE_MOVZX_RM16_TO_R32 (0xb7) /* 0x0f 0xb7/r */
 #define OPCODE_LEA_MEM_TO_R32    (0x8d) /* /r */
-#define OPCODE_NOT_RM32          (0xf7) /* /2 */
-#define OPCODE_NEG_RM32          (0xf7) /* /3 */
 #define OPCODE_AND_R32_TO_RM32   (0x21) /* /r */
 #define OPCODE_OR_R32_TO_RM32    (0x09) /* /r */
 #define OPCODE_XOR_R32_TO_RM32   (0x31) /* /r */
@@ -105,14 +103,14 @@
 
 #define SIGNED_FIT8(x) (((x) & 0xffffff80) == 0) || (((x) & 0xffffff80) == 0xffffff80)
 
-static void asm_x86_write_byte_1(asm_x86_t *as, byte b1) {
+STATIC void asm_x86_write_byte_1(asm_x86_t *as, byte b1) {
     byte *c = mp_asm_base_get_cur_to_write_bytes(&as->base, 1);
     if (c != NULL) {
         c[0] = b1;
     }
 }
 
-static void asm_x86_write_byte_2(asm_x86_t *as, byte b1, byte b2) {
+STATIC void asm_x86_write_byte_2(asm_x86_t *as, byte b1, byte b2) {
     byte *c = mp_asm_base_get_cur_to_write_bytes(&as->base, 2);
     if (c != NULL) {
         c[0] = b1;
@@ -120,7 +118,7 @@ static void asm_x86_write_byte_2(asm_x86_t *as, byte b1, byte b2) {
     }
 }
 
-static void asm_x86_write_byte_3(asm_x86_t *as, byte b1, byte b2, byte b3) {
+STATIC void asm_x86_write_byte_3(asm_x86_t *as, byte b1, byte b2, byte b3) {
     byte *c = mp_asm_base_get_cur_to_write_bytes(&as->base, 3);
     if (c != NULL) {
         c[0] = b1;
@@ -129,7 +127,7 @@ static void asm_x86_write_byte_3(asm_x86_t *as, byte b1, byte b2, byte b3) {
     }
 }
 
-static void asm_x86_write_word32(asm_x86_t *as, int w32) {
+STATIC void asm_x86_write_word32(asm_x86_t *as, int w32) {
     byte *c = mp_asm_base_get_cur_to_write_bytes(&as->base, 4);
     if (c != NULL) {
         c[0] = IMM32_L0(w32);
@@ -139,7 +137,7 @@ static void asm_x86_write_word32(asm_x86_t *as, int w32) {
     }
 }
 
-static void asm_x86_write_r32_disp(asm_x86_t *as, int r32, int disp_r32, int disp_offset) {
+STATIC void asm_x86_write_r32_disp(asm_x86_t *as, int r32, int disp_r32, int disp_offset) {
     uint8_t rm_disp;
     if (disp_offset == 0 && disp_r32 != ASM_X86_REG_EBP) {
         rm_disp = MODRM_RM_DISP0;
@@ -160,17 +158,17 @@ static void asm_x86_write_r32_disp(asm_x86_t *as, int r32, int disp_r32, int dis
     }
 }
 
-static void asm_x86_generic_r32_r32(asm_x86_t *as, int dest_r32, int src_r32, int op) {
+STATIC void asm_x86_generic_r32_r32(asm_x86_t *as, int dest_r32, int src_r32, int op) {
     asm_x86_write_byte_2(as, op, MODRM_R32(src_r32) | MODRM_RM_REG | MODRM_RM_R32(dest_r32));
 }
 
 #if 0
-static void asm_x86_nop(asm_x86_t *as) {
+STATIC void asm_x86_nop(asm_x86_t *as) {
     asm_x86_write_byte_1(as, OPCODE_NOP);
 }
 #endif
 
-static void asm_x86_push_r32(asm_x86_t *as, int src_r32) {
+STATIC void asm_x86_push_r32(asm_x86_t *as, int src_r32) {
     asm_x86_write_byte_1(as, OPCODE_PUSH_R32 | src_r32);
 }
 
@@ -186,11 +184,11 @@ void asm_x86_push_disp(asm_x86_t *as, int src_r32, int src_offset) {
 }
 #endif
 
-static void asm_x86_pop_r32(asm_x86_t *as, int dest_r32) {
+STATIC void asm_x86_pop_r32(asm_x86_t *as, int dest_r32) {
     asm_x86_write_byte_1(as, OPCODE_POP_R32 | dest_r32);
 }
 
-static void asm_x86_ret(asm_x86_t *as) {
+STATIC void asm_x86_ret(asm_x86_t *as) {
     asm_x86_write_byte_1(as, OPCODE_RET);
 }
 
@@ -228,7 +226,7 @@ void asm_x86_mov_mem32_to_r32(asm_x86_t *as, int src_r32, int src_disp, int dest
     asm_x86_write_r32_disp(as, dest_r32, src_r32, src_disp);
 }
 
-static void asm_x86_lea_disp_to_r32(asm_x86_t *as, int src_r32, int src_disp, int dest_r32) {
+STATIC void asm_x86_lea_disp_to_r32(asm_x86_t *as, int src_r32, int src_disp, int dest_r32) {
     asm_x86_write_byte_1(as, OPCODE_LEA_MEM_TO_R32);
     asm_x86_write_r32_disp(as, dest_r32, src_r32, src_disp);
 }
@@ -246,14 +244,6 @@ size_t asm_x86_mov_i32_to_r32(asm_x86_t *as, int32_t src_i32, int dest_r32) {
     return loc;
 }
 
-void asm_x86_not_r32(asm_x86_t *as, int dest_r32) {
-    asm_x86_generic_r32_r32(as, dest_r32, 2, OPCODE_NOT_RM32);
-}
-
-void asm_x86_neg_r32(asm_x86_t *as, int dest_r32) {
-    asm_x86_generic_r32_r32(as, dest_r32, 3, OPCODE_NEG_RM32);
-}
-
 void asm_x86_and_r32_r32(asm_x86_t *as, int dest_r32, int src_r32) {
     asm_x86_generic_r32_r32(as, dest_r32, src_r32, OPCODE_AND_R32_TO_RM32);
 }
@@ -282,7 +272,7 @@ void asm_x86_add_r32_r32(asm_x86_t *as, int dest_r32, int src_r32) {
     asm_x86_generic_r32_r32(as, dest_r32, src_r32, OPCODE_ADD_R32_TO_RM32);
 }
 
-static void asm_x86_add_i32_to_r32(asm_x86_t *as, int src_i32, int dest_r32) {
+STATIC void asm_x86_add_i32_to_r32(asm_x86_t *as, int src_i32, int dest_r32) {
     if (SIGNED_FIT8(src_i32)) {
         asm_x86_write_byte_2(as, OPCODE_ADD_I8_TO_RM32, MODRM_R32(0) | MODRM_RM_REG | MODRM_RM_R32(dest_r32));
         asm_x86_write_byte_1(as, src_i32 & 0xff);
@@ -296,7 +286,7 @@ void asm_x86_sub_r32_r32(asm_x86_t *as, int dest_r32, int src_r32) {
     asm_x86_generic_r32_r32(as, dest_r32, src_r32, OPCODE_SUB_R32_FROM_RM32);
 }
 
-static void asm_x86_sub_r32_i32(asm_x86_t *as, int dest_r32, int src_i32) {
+STATIC void asm_x86_sub_r32_i32(asm_x86_t *as, int dest_r32, int src_i32) {
     if (SIGNED_FIT8(src_i32)) {
         // defaults to 32 bit operation
         asm_x86_write_byte_2(as, OPCODE_SUB_I8_FROM_RM32, MODRM_R32(5) | MODRM_RM_REG | MODRM_RM_R32(dest_r32));
@@ -363,7 +353,7 @@ void asm_x86_jmp_reg(asm_x86_t *as, int src_r32) {
     asm_x86_write_byte_2(as, OPCODE_JMP_RM32, MODRM_R32(4) | MODRM_RM_REG | MODRM_RM_R32(src_r32));
 }
 
-static mp_uint_t get_label_dest(asm_x86_t *as, mp_uint_t label) {
+STATIC mp_uint_t get_label_dest(asm_x86_t *as, mp_uint_t label) {
     assert(label < as->base.max_num_labels);
     return as->base.label_offsets[label];
 }
@@ -432,7 +422,7 @@ void asm_x86_exit(asm_x86_t *as) {
     asm_x86_ret(as);
 }
 
-static int asm_x86_arg_offset_from_esp(asm_x86_t *as, size_t arg_num) {
+STATIC int asm_x86_arg_offset_from_esp(asm_x86_t *as, size_t arg_num) {
     // Above esp are: locals, 4 saved registers, return eip, arguments
     return (as->num_locals + 4 + 1 + arg_num) * WORD_SIZE;
 }
@@ -464,7 +454,7 @@ void asm_x86_mov_r32_to_arg(asm_x86_t *as, int src_r32, int dest_arg_num) {
 //  ^                ^
 //  | low address    | high address in RAM
 //
-static int asm_x86_local_offset_from_esp(asm_x86_t *as, int local_num) {
+STATIC int asm_x86_local_offset_from_esp(asm_x86_t *as, int local_num) {
     (void)as;
     // Stack is full descending, ESP points to local0
     return local_num * WORD_SIZE;

+ 0 - 4
py/asmx86.h

@@ -92,8 +92,6 @@ void asm_x86_mov_r32_to_mem32(asm_x86_t *as, int src_r32, int dest_r32, int dest
 void asm_x86_mov_mem8_to_r32zx(asm_x86_t *as, int src_r32, int src_disp, int dest_r32);
 void asm_x86_mov_mem16_to_r32zx(asm_x86_t *as, int src_r32, int src_disp, int dest_r32);
 void asm_x86_mov_mem32_to_r32(asm_x86_t *as, int src_r32, int src_disp, int dest_r32);
-void asm_x86_not_r32(asm_x86_t *as, int dest_r32);
-void asm_x86_neg_r32(asm_x86_t *as, int dest_r32);
 void asm_x86_and_r32_r32(asm_x86_t *as, int dest_r32, int src_r32);
 void asm_x86_or_r32_r32(asm_x86_t *as, int dest_r32, int src_r32);
 void asm_x86_xor_r32_r32(asm_x86_t *as, int dest_r32, int src_r32);
@@ -188,8 +186,6 @@ void asm_x86_call_ind(asm_x86_t *as, size_t fun_id, mp_uint_t n_args, int temp_r
 #define ASM_MOV_REG_LOCAL_ADDR(as, reg_dest, local_num) asm_x86_mov_local_addr_to_r32((as), (local_num), (reg_dest))
 #define ASM_MOV_REG_PCREL(as, reg_dest, label) asm_x86_mov_reg_pcrel((as), (reg_dest), (label))
 
-#define ASM_NOT_REG(as, reg) asm_x86_not_r32((as), (reg))
-#define ASM_NEG_REG(as, reg) asm_x86_neg_r32((as), (reg))
 #define ASM_LSL_REG(as, reg) asm_x86_shl_r32_cl((as), (reg))
 #define ASM_LSR_REG(as, reg) asm_x86_shr_r32_cl((as), (reg))
 #define ASM_ASR_REG(as, reg) asm_x86_sar_r32_cl((as), (reg))

+ 2 - 4
py/asmxtensa.c

@@ -117,7 +117,7 @@ void asm_xtensa_exit_win(asm_xtensa_t *as) {
     asm_xtensa_op_retw_n(as);
 }
 
-static uint32_t get_label_dest(asm_xtensa_t *as, uint label) {
+STATIC uint32_t get_label_dest(asm_xtensa_t *as, uint label) {
     assert(label < as->base.max_num_labels);
     return as->base.label_offsets[label];
 }
@@ -185,9 +185,7 @@ size_t asm_xtensa_mov_reg_i32(asm_xtensa_t *as, uint reg_dest, uint32_t i32) {
 }
 
 void asm_xtensa_mov_reg_i32_optimised(asm_xtensa_t *as, uint reg_dest, uint32_t i32) {
-    if (-32 <= (int)i32 && (int)i32 <= 95) {
-        asm_xtensa_op_movi_n(as, reg_dest, i32);
-    } else if (SIGNED_FIT12(i32)) {
+    if (SIGNED_FIT12(i32)) {
         asm_xtensa_op_movi(as, reg_dest, i32);
     } else {
         asm_xtensa_mov_reg_i32(as, reg_dest, i32);

+ 2 - 8
py/asmxtensa.h

@@ -203,19 +203,14 @@ static inline void asm_xtensa_op_movi(asm_xtensa_t *as, uint reg_dest, int32_t i
     asm_xtensa_op24(as, ASM_XTENSA_ENCODE_RRI8(2, 10, (imm12 >> 8) & 0xf, reg_dest, imm12 & 0xff));
 }
 
-// Argument must be in the range (-32 .. 95) inclusive.
-static inline void asm_xtensa_op_movi_n(asm_xtensa_t *as, uint reg_dest, int imm7) {
-    asm_xtensa_op16(as, ASM_XTENSA_ENCODE_RI7(12, reg_dest, imm7));
+static inline void asm_xtensa_op_movi_n(asm_xtensa_t *as, uint reg_dest, int imm4) {
+    asm_xtensa_op16(as, ASM_XTENSA_ENCODE_RI7(12, reg_dest, imm4));
 }
 
 static inline void asm_xtensa_op_mull(asm_xtensa_t *as, uint reg_dest, uint reg_src_a, uint reg_src_b) {
     asm_xtensa_op24(as, ASM_XTENSA_ENCODE_RRR(0, 2, 8, reg_dest, reg_src_a, reg_src_b));
 }
 
-static inline void asm_xtensa_op_neg(asm_xtensa_t *as, uint reg_dest, uint reg_src) {
-    asm_xtensa_op24(as, ASM_XTENSA_ENCODE_RRR(0, 0, 6, reg_dest, 0, reg_src));
-}
-
 static inline void asm_xtensa_op_or(asm_xtensa_t *as, uint reg_dest, uint reg_src_a, uint reg_src_b) {
     asm_xtensa_op24(as, ASM_XTENSA_ENCODE_RRR(0, 0, 2, reg_dest, reg_src_a, reg_src_b));
 }
@@ -376,7 +371,6 @@ void asm_xtensa_call_ind_win(asm_xtensa_t *as, uint idx);
 #define ASM_MOV_REG_LOCAL_ADDR(as, reg_dest, local_num) asm_xtensa_mov_reg_local_addr((as), (reg_dest), ASM_NUM_REGS_SAVED + (local_num))
 #define ASM_MOV_REG_PCREL(as, reg_dest, label) asm_xtensa_mov_reg_pcrel((as), (reg_dest), (label))
 
-#define ASM_NEG_REG(as, reg_dest) asm_xtensa_op_neg((as), (reg_dest), (reg_dest))
 #define ASM_LSL_REG_REG(as, reg_dest, reg_shift) \
     do { \
         asm_xtensa_op_ssl((as), (reg_shift)); \

+ 4 - 4
py/bc.c

@@ -88,7 +88,7 @@ const byte *mp_decode_uint_skip(const byte *ptr) {
     return ptr;
 }
 
-static NORETURN void fun_pos_args_mismatch(mp_obj_fun_bc_t *f, size_t expected, size_t given) {
+STATIC NORETURN void fun_pos_args_mismatch(mp_obj_fun_bc_t *f, size_t expected, size_t given) {
     #if MICROPY_ERROR_REPORTING <= MICROPY_ERROR_REPORTING_TERSE
     // generic message, used also for other argument issues
     (void)f;
@@ -107,7 +107,7 @@ static NORETURN void fun_pos_args_mismatch(mp_obj_fun_bc_t *f, size_t expected,
 }
 
 #if DEBUG_PRINT
-static void dump_args(const mp_obj_t *a, size_t sz) {
+STATIC void dump_args(const mp_obj_t *a, size_t sz) {
     DEBUG_printf("%p: ", a);
     for (size_t i = 0; i < sz; i++) {
         DEBUG_printf("%p ", a[i]);
@@ -124,7 +124,7 @@ static void dump_args(const mp_obj_t *a, size_t sz) {
 //    - code_state->ip should contain a pointer to the beginning of the prelude
 //    - code_state->sp should be: &code_state->state[0] - 1
 //    - code_state->n_state should be the number of objects in the local state
-static void mp_setup_code_state_helper(mp_code_state_t *code_state, size_t n_args, size_t n_kw, const mp_obj_t *args) {
+STATIC void mp_setup_code_state_helper(mp_code_state_t *code_state, size_t n_args, size_t n_kw, const mp_obj_t *args) {
     // This function is pretty complicated.  It's main aim is to be efficient in speed and RAM
     // usage for the common case of positional only args.
 
@@ -336,9 +336,9 @@ void mp_setup_code_state(mp_code_state_t *code_state, size_t n_args, size_t n_kw
 // On entry code_state should be allocated somewhere (stack/heap) and
 // contain the following valid entries:
 //    - code_state->fun_bc should contain a pointer to the function object
+//    - code_state->ip should contain a pointer to the beginning of the prelude
 //    - code_state->n_state should be the number of objects in the local state
 void mp_setup_code_state_native(mp_code_state_native_t *code_state, size_t n_args, size_t n_kw, const mp_obj_t *args) {
-    code_state->ip = mp_obj_fun_native_get_prelude_ptr(code_state->fun_bc);
     code_state->sp = &code_state->state[0] - 1;
     mp_setup_code_state_helper((mp_code_state_t *)code_state, n_args, n_kw, args);
 }

+ 4 - 4
py/bc.h

@@ -44,11 +44,11 @@
 //  prelude size    : var uint
 //      contains two values interleaved bit-wise as: xIIIIIIC repeated
 //          x = extension           another byte follows
-//          I = n_info              number of bytes in source info section (always > 0)
+//          I = n_info              number of bytes in source info section
 //          C = n_cells             number of bytes/cells in closure section
 //
 //  source info section:
-//      simple_name : var qstr      always exists
+//      simple_name : var qstr
 //      argname0    : var qstr
 //      ...         : var qstr
 //      argnameN    : var qstr      N = num_pos_args + num_kwonly_args - 1
@@ -226,7 +226,7 @@ typedef struct _mp_compiled_module_t {
 // Outer level struct defining a frozen module.
 typedef struct _mp_frozen_module_t {
     const mp_module_constants_t constants;
-    const void *proto_fun;
+    const struct _mp_raw_code_t *rc;
 } mp_frozen_module_t;
 
 // State for an executing function.
@@ -281,7 +281,7 @@ mp_vm_return_kind_t mp_execute_bytecode(mp_code_state_t *code_state,
 mp_code_state_t *mp_obj_fun_bc_prepare_codestate(mp_obj_t func, size_t n_args, size_t n_kw, const mp_obj_t *args);
 void mp_setup_code_state(mp_code_state_t *code_state, size_t n_args, size_t n_kw, const mp_obj_t *args);
 void mp_setup_code_state_native(mp_code_state_native_t *code_state, size_t n_args, size_t n_kw, const mp_obj_t *args);
-void mp_bytecode_print(const mp_print_t *print, const struct _mp_raw_code_t *rc, size_t fun_data_len, const mp_module_constants_t *cm);
+void mp_bytecode_print(const mp_print_t *print, const struct _mp_raw_code_t *rc, const mp_module_constants_t *cm);
 void mp_bytecode_print2(const mp_print_t *print, const byte *ip, size_t len, struct _mp_raw_code_t *const *child_table, const mp_module_constants_t *cm);
 const byte *mp_bytecode_print_str(const mp_print_t *print, const byte *ip_start, const byte *ip, struct _mp_raw_code_t *const *child_table, const mp_module_constants_t *cm);
 #define mp_bytecode_print_inst(print, code, x_table) mp_bytecode_print2(print, code, 1, x_table)

+ 2 - 107
py/binary.c

@@ -74,14 +74,11 @@ size_t mp_binary_get_size(char struct_type, char val_type, size_t *palign) {
                 case 'S':
                     size = sizeof(void *);
                     break;
-                case 'e':
-                    size = 2;
-                    break;
                 case 'f':
-                    size = 4;
+                    size = sizeof(float);
                     break;
                 case 'd':
-                    size = 8;
+                    size = sizeof(double);
                     break;
             }
             break;
@@ -125,10 +122,6 @@ size_t mp_binary_get_size(char struct_type, char val_type, size_t *palign) {
                     align = alignof(void *);
                     size = sizeof(void *);
                     break;
-                case 'e':
-                    align = 2;
-                    size = 2;
-                    break;
                 case 'f':
                     align = alignof(float);
                     size = sizeof(float);
@@ -151,99 +144,6 @@ size_t mp_binary_get_size(char struct_type, char val_type, size_t *palign) {
     return size;
 }
 
-#if MICROPY_PY_BUILTINS_FLOAT && MICROPY_FLOAT_USE_NATIVE_FLT16
-
-static inline float mp_decode_half_float(uint16_t hf) {
-    union {
-        uint16_t i;
-        _Float16 f;
-    } fpu = { .i = hf };
-    return fpu.f;
-}
-
-static inline uint16_t mp_encode_half_float(float x) {
-    union {
-        uint16_t i;
-        _Float16 f;
-    } fp_sp = { .f = (_Float16)x };
-    return fp_sp.i;
-}
-
-#elif MICROPY_PY_BUILTINS_FLOAT
-
-static float mp_decode_half_float(uint16_t hf) {
-    union {
-        uint32_t i;
-        float f;
-    } fpu;
-
-    uint16_t m = hf & 0x3ff;
-    int e = (hf >> 10) & 0x1f;
-    if (e == 0x1f) {
-        // Half-float is infinity.
-        e = 0xff;
-    } else if (e) {
-        // Half-float is normal.
-        e += 127 - 15;
-    } else if (m) {
-        // Half-float is subnormal, make it normal.
-        e = 127 - 15;
-        while (!(m & 0x400)) {
-            m <<= 1;
-            --e;
-        }
-        m -= 0x400;
-        ++e;
-    }
-
-    fpu.i = ((hf & 0x8000) << 16) | (e << 23) | (m << 13);
-    return fpu.f;
-}
-
-static uint16_t mp_encode_half_float(float x) {
-    union {
-        uint32_t i;
-        float f;
-    } fpu = { .f = x };
-
-    uint16_t m = (fpu.i >> 13) & 0x3ff;
-    if (fpu.i & (1 << 12)) {
-        // Round up.
-        ++m;
-    }
-    int e = (fpu.i >> 23) & 0xff;
-
-    if (e == 0xff) {
-        // Infinity.
-        e = 0x1f;
-    } else if (e != 0) {
-        e -= 127 - 15;
-        if (e < 0) {
-            // Underflow: denormalized, or zero.
-            if (e >= -11) {
-                m = (m | 0x400) >> -e;
-                if (m & 1) {
-                    m = (m >> 1) + 1;
-                } else {
-                    m >>= 1;
-                }
-            } else {
-                m = 0;
-            }
-            e = 0;
-        } else if (e > 0x3f) {
-            // Overflow: infinity.
-            e = 0x1f;
-            m = 0;
-        }
-    }
-
-    uint16_t bits = ((fpu.i >> 16) & 0x8000) | (e << 10) | m;
-    return bits;
-}
-
-#endif
-
 mp_obj_t mp_binary_get_val_array(char typecode, void *p, size_t index) {
     mp_int_t val = 0;
     switch (typecode) {
@@ -340,8 +240,6 @@ mp_obj_t mp_binary_get_val(char struct_type, char val_type, byte *p_base, byte *
         const char *s_val = (const char *)(uintptr_t)(mp_uint_t)val;
         return mp_obj_new_str(s_val, strlen(s_val));
     #if MICROPY_PY_BUILTINS_FLOAT
-    } else if (val_type == 'e') {
-        return mp_obj_new_float_from_f(mp_decode_half_float(val));
     } else if (val_type == 'f') {
         union {
             uint32_t i;
@@ -411,9 +309,6 @@ void mp_binary_set_val(char struct_type, char val_type, mp_obj_t val_in, byte *p
             val = (mp_uint_t)val_in;
             break;
         #if MICROPY_PY_BUILTINS_FLOAT
-        case 'e':
-            val = mp_encode_half_float(mp_obj_get_float_to_f(val_in));
-            break;
         case 'f': {
             union {
                 uint32_t i;

+ 10 - 14
py/builtinevex.c

@@ -38,13 +38,13 @@ typedef struct _mp_obj_code_t {
     mp_obj_t module_fun;
 } mp_obj_code_t;
 
-static MP_DEFINE_CONST_OBJ_TYPE(
+STATIC MP_DEFINE_CONST_OBJ_TYPE(
     mp_type_code,
     MP_QSTR_code,
     MP_TYPE_FLAG_NONE
     );
 
-static mp_obj_t code_execute(mp_obj_code_t *self, mp_obj_dict_t *globals, mp_obj_dict_t *locals) {
+STATIC mp_obj_t code_execute(mp_obj_code_t *self, mp_obj_dict_t *globals, mp_obj_dict_t *locals) {
     // save context
     nlr_jump_callback_node_globals_locals_t ctx;
     ctx.globals = mp_globals_get();
@@ -57,13 +57,9 @@ static mp_obj_t code_execute(mp_obj_code_t *self, mp_obj_dict_t *globals, mp_obj
     // set exception handler to restore context if an exception is raised
     nlr_push_jump_callback(&ctx.callback, mp_globals_locals_set_from_nlr_jump_callback);
 
-    // The call to mp_parse_compile_execute() in mp_builtin_compile() below passes
-    // NULL for the globals, so repopulate that entry now with the correct globals.
-    if (mp_obj_is_type(self->module_fun, &mp_type_fun_bc)
-        #if MICROPY_EMIT_NATIVE
-        || mp_obj_is_type(self->module_fun, &mp_type_fun_native)
-        #endif
-        ) {
+    // a bit of a hack: fun_bc will re-set globals, so need to make sure it's
+    // the correct one
+    if (mp_obj_is_type(self->module_fun, &mp_type_fun_bc)) {
         mp_obj_fun_bc_t *fun_bc = MP_OBJ_TO_PTR(self->module_fun);
         ((mp_module_context_t *)fun_bc->context)->module.globals = globals;
     }
@@ -78,7 +74,7 @@ static mp_obj_t code_execute(mp_obj_code_t *self, mp_obj_dict_t *globals, mp_obj
     return ret;
 }
 
-static mp_obj_t mp_builtin_compile(size_t n_args, const mp_obj_t *args) {
+STATIC mp_obj_t mp_builtin_compile(size_t n_args, const mp_obj_t *args) {
     (void)n_args;
 
     // get the source
@@ -118,7 +114,7 @@ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_compile_obj, 3, 6, mp_builtin_com
 
 #if MICROPY_PY_BUILTINS_EVAL_EXEC
 
-static mp_obj_t eval_exec_helper(size_t n_args, const mp_obj_t *args, mp_parse_input_kind_t parse_input_kind) {
+STATIC mp_obj_t eval_exec_helper(size_t n_args, const mp_obj_t *args, mp_parse_input_kind_t parse_input_kind) {
     // work out the context
     mp_obj_dict_t *globals = mp_globals_get();
     mp_obj_dict_t *locals = mp_locals_get();
@@ -158,12 +154,12 @@ static mp_obj_t eval_exec_helper(size_t n_args, const mp_obj_t *args, mp_parse_i
     return mp_parse_compile_execute(lex, parse_input_kind, globals, locals);
 }
 
-static mp_obj_t mp_builtin_eval(size_t n_args, const mp_obj_t *args) {
+STATIC mp_obj_t mp_builtin_eval(size_t n_args, const mp_obj_t *args) {
     return eval_exec_helper(n_args, args, MP_PARSE_EVAL_INPUT);
 }
 MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_eval_obj, 1, 3, mp_builtin_eval);
 
-static mp_obj_t mp_builtin_exec(size_t n_args, const mp_obj_t *args) {
+STATIC mp_obj_t mp_builtin_exec(size_t n_args, const mp_obj_t *args) {
     return eval_exec_helper(n_args, args, MP_PARSE_FILE_INPUT);
 }
 MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_exec_obj, 1, 3, mp_builtin_exec);
@@ -171,7 +167,7 @@ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_exec_obj, 1, 3, mp_builtin_exec);
 #endif // MICROPY_PY_BUILTINS_EVAL_EXEC
 
 #if MICROPY_PY_BUILTINS_EXECFILE
-static mp_obj_t mp_builtin_execfile(size_t n_args, const mp_obj_t *args) {
+STATIC mp_obj_t mp_builtin_execfile(size_t n_args, const mp_obj_t *args) {
     // MP_PARSE_SINGLE_INPUT is used to indicate a file input
     return eval_exec_helper(n_args, args, MP_PARSE_SINGLE_INPUT);
 }

+ 6 - 6
py/builtinhelp.c

@@ -47,7 +47,7 @@ const char mp_help_default_text[] =
     "For further help on a specific object, type help(obj)\n"
 ;
 
-static void mp_help_print_info_about_object(mp_obj_t name_o, mp_obj_t value) {
+STATIC void mp_help_print_info_about_object(mp_obj_t name_o, mp_obj_t value) {
     mp_print_str(MP_PYTHON_PRINTER, "  ");
     mp_obj_print(name_o, PRINT_STR);
     mp_print_str(MP_PYTHON_PRINTER, " -- ");
@@ -56,7 +56,7 @@ static void mp_help_print_info_about_object(mp_obj_t name_o, mp_obj_t value) {
 }
 
 #if MICROPY_PY_BUILTINS_HELP_MODULES
-static void mp_help_add_from_map(mp_obj_t list, const mp_map_t *map) {
+STATIC void mp_help_add_from_map(mp_obj_t list, const mp_map_t *map) {
     for (size_t i = 0; i < map->alloc; i++) {
         if (mp_map_slot_is_filled(map, i)) {
             mp_obj_list_append(list, map->table[i].key);
@@ -65,7 +65,7 @@ static void mp_help_add_from_map(mp_obj_t list, const mp_map_t *map) {
 }
 
 #if MICROPY_MODULE_FROZEN
-static void mp_help_add_from_names(mp_obj_t list, const char *name) {
+STATIC void mp_help_add_from_names(mp_obj_t list, const char *name) {
     while (*name) {
         size_t len = strlen(name);
         // name should end in '.py' and we strip it off
@@ -75,7 +75,7 @@ static void mp_help_add_from_names(mp_obj_t list, const char *name) {
 }
 #endif
 
-static void mp_help_print_modules(void) {
+STATIC void mp_help_print_modules(void) {
     mp_obj_t list = mp_obj_new_list(0, NULL);
 
     mp_help_add_from_map(list, &mp_builtin_module_map);
@@ -122,7 +122,7 @@ static void mp_help_print_modules(void) {
 }
 #endif
 
-static void mp_help_print_obj(const mp_obj_t obj) {
+STATIC void mp_help_print_obj(const mp_obj_t obj) {
     #if MICROPY_PY_BUILTINS_HELP_MODULES
     if (obj == MP_OBJ_NEW_QSTR(MP_QSTR_modules)) {
         mp_help_print_modules();
@@ -158,7 +158,7 @@ static void mp_help_print_obj(const mp_obj_t obj) {
     }
 }
 
-static mp_obj_t mp_builtin_help(size_t n_args, const mp_obj_t *args) {
+STATIC mp_obj_t mp_builtin_help(size_t n_args, const mp_obj_t *args) {
     if (n_args == 0) {
         // print a general help message
         mp_print_str(MP_PYTHON_PRINTER, MICROPY_PY_BUILTINS_HELP_TEXT);

+ 19 - 20
py/builtinimport.c

@@ -57,17 +57,16 @@
 // uses mp_vfs_import_stat) to also search frozen modules. Given an exact
 // path to a file or directory (e.g. "foo/bar", foo/bar.py" or "foo/bar.mpy"),
 // will return whether the path is a file, directory, or doesn't exist.
-static mp_import_stat_t stat_path(vstr_t *path) {
-    const char *str = vstr_null_terminated_str(path);
+STATIC mp_import_stat_t stat_path(const char *path) {
     #if MICROPY_MODULE_FROZEN
     // Only try and load as a frozen module if it starts with .frozen/.
     const int frozen_path_prefix_len = strlen(MP_FROZEN_PATH_PREFIX);
-    if (strncmp(str, MP_FROZEN_PATH_PREFIX, frozen_path_prefix_len) == 0) {
+    if (strncmp(path, MP_FROZEN_PATH_PREFIX, frozen_path_prefix_len) == 0) {
         // Just stat (which is the return value), don't get the data.
-        return mp_find_frozen_module(str + frozen_path_prefix_len, NULL, NULL);
+        return mp_find_frozen_module(path + frozen_path_prefix_len, NULL, NULL);
     }
     #endif
-    return mp_import_stat(str);
+    return mp_import_stat(path);
 }
 
 // Stat a given filesystem path to a .py file. If the file does not exist,
@@ -75,8 +74,8 @@ static mp_import_stat_t stat_path(vstr_t *path) {
 // argument. This is the logic that makes .py files take precedent over .mpy
 // files. This uses stat_path above, rather than mp_import_stat directly, so
 // that the .frozen path prefix is handled.
-static mp_import_stat_t stat_file_py_or_mpy(vstr_t *path) {
-    mp_import_stat_t stat = stat_path(path);
+STATIC mp_import_stat_t stat_file_py_or_mpy(vstr_t *path) {
+    mp_import_stat_t stat = stat_path(vstr_null_terminated_str(path));
     if (stat == MP_IMPORT_STAT_FILE) {
         return stat;
     }
@@ -86,7 +85,7 @@ static mp_import_stat_t stat_file_py_or_mpy(vstr_t *path) {
     // Note: There's no point doing this if it's a frozen path, but adding the check
     // would be extra code, and no harm letting mp_find_frozen_module fail instead.
     vstr_ins_byte(path, path->len - 2, 'm');
-    stat = stat_path(path);
+    stat = stat_path(vstr_null_terminated_str(path));
     if (stat == MP_IMPORT_STAT_FILE) {
         return stat;
     }
@@ -99,8 +98,8 @@ static mp_import_stat_t stat_file_py_or_mpy(vstr_t *path) {
 // or "foo/bar.(m)py" in either the filesystem or frozen modules. If the
 // result is a file, the path argument will be updated to include the file
 // extension.
-static mp_import_stat_t stat_module(vstr_t *path) {
-    mp_import_stat_t stat = stat_path(path);
+STATIC mp_import_stat_t stat_module(vstr_t *path) {
+    mp_import_stat_t stat = stat_path(vstr_null_terminated_str(path));
     DEBUG_printf("stat %s: %d\n", vstr_str(path), stat);
     if (stat == MP_IMPORT_STAT_DIR) {
         return stat;
@@ -114,7 +113,7 @@ static mp_import_stat_t stat_module(vstr_t *path) {
 // Given a top-level module name, try and find it in each of the sys.path
 // entries. Note: On success, the dest argument will be updated to the matching
 // path (i.e. "<entry>/mod_name(.py)").
-static mp_import_stat_t stat_top_level(qstr mod_name, vstr_t *dest) {
+STATIC mp_import_stat_t stat_top_level(qstr mod_name, vstr_t *dest) {
     DEBUG_printf("stat_top_level: '%s'\n", qstr_str(mod_name));
     #if MICROPY_PY_SYS
     size_t path_num;
@@ -152,7 +151,7 @@ static mp_import_stat_t stat_top_level(qstr mod_name, vstr_t *dest) {
 }
 
 #if MICROPY_MODULE_FROZEN_STR || MICROPY_ENABLE_COMPILER
-static void do_load_from_lexer(mp_module_context_t *context, mp_lexer_t *lex) {
+STATIC void do_load_from_lexer(mp_module_context_t *context, mp_lexer_t *lex) {
     #if MICROPY_PY___FILE__
     qstr source_name = lex->source_name;
     mp_store_attr(MP_OBJ_FROM_PTR(&context->module), MP_QSTR___file__, MP_OBJ_NEW_QSTR(source_name));
@@ -165,7 +164,7 @@ static void do_load_from_lexer(mp_module_context_t *context, mp_lexer_t *lex) {
 #endif
 
 #if (MICROPY_HAS_FILE_READER && MICROPY_PERSISTENT_CODE_LOAD) || MICROPY_MODULE_FROZEN_MPY
-static void do_execute_proto_fun(const mp_module_context_t *context, mp_proto_fun_t proto_fun, qstr source_name) {
+STATIC void do_execute_raw_code(const mp_module_context_t *context, const mp_raw_code_t *rc, qstr source_name) {
     #if MICROPY_PY___FILE__
     mp_store_attr(MP_OBJ_FROM_PTR(&context->module), MP_QSTR___file__, MP_OBJ_NEW_QSTR(source_name));
     #else
@@ -188,7 +187,7 @@ static void do_execute_proto_fun(const mp_module_context_t *context, mp_proto_fu
     nlr_push_jump_callback(&ctx.callback, mp_globals_locals_set_from_nlr_jump_callback);
 
     // make and execute the function
-    mp_obj_t module_fun = mp_make_function_from_proto_fun(proto_fun, context, NULL);
+    mp_obj_t module_fun = mp_make_function_from_raw_code(rc, context, NULL);
     mp_call_function_0(module_fun);
 
     // deregister exception handler and restore context
@@ -196,7 +195,7 @@ static void do_execute_proto_fun(const mp_module_context_t *context, mp_proto_fu
 }
 #endif
 
-static void do_load(mp_module_context_t *module_obj, vstr_t *file) {
+STATIC void do_load(mp_module_context_t *module_obj, vstr_t *file) {
     #if MICROPY_MODULE_FROZEN || MICROPY_ENABLE_COMPILER || (MICROPY_PERSISTENT_CODE_LOAD && MICROPY_HAS_FILE_READER)
     const char *file_str = vstr_null_terminated_str(file);
     #endif
@@ -230,7 +229,7 @@ static void do_load(mp_module_context_t *module_obj, vstr_t *file) {
             #else
             qstr frozen_file_qstr = MP_QSTRnull;
             #endif
-            do_execute_proto_fun(module_obj, frozen->proto_fun, frozen_file_qstr);
+            do_execute_raw_code(module_obj, frozen->rc, frozen_file_qstr);
             return;
         }
         #endif
@@ -247,7 +246,7 @@ static void do_load(mp_module_context_t *module_obj, vstr_t *file) {
         mp_compiled_module_t cm;
         cm.context = module_obj;
         mp_raw_code_load_file(file_qstr, &cm);
-        do_execute_proto_fun(cm.context, cm.rc, file_qstr);
+        do_execute_raw_code(cm.context, cm.rc, file_qstr);
         return;
     }
     #endif
@@ -267,7 +266,7 @@ static void do_load(mp_module_context_t *module_obj, vstr_t *file) {
 
 // Convert a relative (to the current module) import, going up "level" levels,
 // into an absolute import.
-static void evaluate_relative_import(mp_int_t level, const char **module_name, size_t *module_name_len) {
+STATIC void evaluate_relative_import(mp_int_t level, const char **module_name, size_t *module_name_len) {
     // What we want to do here is to take the name of the current module,
     // remove <level> trailing components, and concatenate the passed-in
     // module name.
@@ -350,7 +349,7 @@ typedef struct _nlr_jump_callback_node_unregister_module_t {
     qstr name;
 } nlr_jump_callback_node_unregister_module_t;
 
-static void unregister_module_from_nlr_jump_callback(void *ctx_in) {
+STATIC void unregister_module_from_nlr_jump_callback(void *ctx_in) {
     nlr_jump_callback_node_unregister_module_t *ctx = ctx_in;
     mp_map_t *mp_loaded_modules_map = &MP_STATE_VM(mp_loaded_modules_dict).map;
     mp_map_lookup(mp_loaded_modules_map, MP_OBJ_NEW_QSTR(ctx->name), MP_MAP_LOOKUP_REMOVE_IF_FOUND);
@@ -363,7 +362,7 @@ static void unregister_module_from_nlr_jump_callback(void *ctx_in) {
 //                   attribute on it) (or MP_OBJ_NULL for top-level).
 // override_main:    Whether to set the __name__ to "__main__" (and use __main__
 //                   for the actual path).
-static mp_obj_t process_import_at_level(qstr full_mod_name, qstr level_mod_name, mp_obj_t outer_module_obj, bool override_main) {
+STATIC mp_obj_t process_import_at_level(qstr full_mod_name, qstr level_mod_name, mp_obj_t outer_module_obj, bool override_main) {
     // Immediately return if the module at this level is already loaded.
     mp_map_elem_t *elem;
 

+ 113 - 120
py/compile.c

@@ -41,6 +41,8 @@
 
 #if MICROPY_ENABLE_COMPILER
 
+// TODO need to mangle __attr names
+
 #define INVALID_LABEL (0xffff)
 
 typedef enum {
@@ -90,7 +92,7 @@ typedef enum {
 #define NATIVE_EMITTER(f) emit_native_table[mp_dynamic_compiler.native_arch]->emit_##f
 #define NATIVE_EMITTER_TABLE (emit_native_table[mp_dynamic_compiler.native_arch])
 
-static const emit_method_table_t *emit_native_table[] = {
+STATIC const emit_method_table_t *emit_native_table[] = {
     NULL,
     &emit_native_x86_method_table,
     &emit_native_x64_method_table,
@@ -129,7 +131,7 @@ static const emit_method_table_t *emit_native_table[] = {
 #define ASM_EMITTER(f) emit_asm_table[mp_dynamic_compiler.native_arch]->asm_##f
 #define ASM_EMITTER_TABLE emit_asm_table[mp_dynamic_compiler.native_arch]
 
-static const emit_inline_asm_method_table_t *emit_asm_table[] = {
+STATIC const emit_inline_asm_method_table_t *emit_asm_table[] = {
     NULL,
     NULL,
     NULL,
@@ -196,15 +198,11 @@ typedef struct _compiler_t {
     mp_emit_common_t emit_common;
 } compiler_t;
 
-#if MICROPY_COMP_ALLOW_TOP_LEVEL_AWAIT
-bool mp_compile_allow_top_level_await = false;
-#endif
-
 /******************************************************************************/
 // mp_emit_common_t helper functions
 // These are defined here so they can be inlined, to reduce code size.
 
-static void mp_emit_common_init(mp_emit_common_t *emit, qstr source_file) {
+STATIC void mp_emit_common_init(mp_emit_common_t *emit, qstr source_file) {
     #if MICROPY_EMIT_BYTECODE_USES_QSTR_TABLE
     mp_map_init(&emit->qstr_map, 1);
 
@@ -215,7 +213,7 @@ static void mp_emit_common_init(mp_emit_common_t *emit, qstr source_file) {
     mp_obj_list_init(&emit->const_obj_list, 0);
 }
 
-static void mp_emit_common_start_pass(mp_emit_common_t *emit, pass_kind_t pass) {
+STATIC void mp_emit_common_start_pass(mp_emit_common_t *emit, pass_kind_t pass) {
     emit->pass = pass;
     if (pass == MP_PASS_CODE_SIZE) {
         if (emit->ct_cur_child == 0) {
@@ -227,7 +225,7 @@ static void mp_emit_common_start_pass(mp_emit_common_t *emit, pass_kind_t pass)
     emit->ct_cur_child = 0;
 }
 
-static void mp_emit_common_populate_module_context(mp_emit_common_t *emit, qstr source_file, mp_module_context_t *context) {
+STATIC void mp_emit_common_populate_module_context(mp_emit_common_t *emit, qstr source_file, mp_module_context_t *context) {
     #if MICROPY_EMIT_BYTECODE_USES_QSTR_TABLE
     size_t qstr_map_used = emit->qstr_map.used;
     mp_module_context_alloc_tables(context, qstr_map_used, emit->const_obj_list.len);
@@ -250,14 +248,14 @@ static void mp_emit_common_populate_module_context(mp_emit_common_t *emit, qstr
 
 /******************************************************************************/
 
-static void compile_error_set_line(compiler_t *comp, mp_parse_node_t pn) {
+STATIC void compile_error_set_line(compiler_t *comp, mp_parse_node_t pn) {
     // if the line of the error is unknown then try to update it from the pn
     if (comp->compile_error_line == 0 && MP_PARSE_NODE_IS_STRUCT(pn)) {
         comp->compile_error_line = ((mp_parse_node_struct_t *)pn)->source_line;
     }
 }
 
-static void compile_syntax_error(compiler_t *comp, mp_parse_node_t pn, mp_rom_error_text_t msg) {
+STATIC void compile_syntax_error(compiler_t *comp, mp_parse_node_t pn, mp_rom_error_text_t msg) {
     // only register the error if there has been no other error
     if (comp->compile_error == MP_OBJ_NULL) {
         comp->compile_error = mp_obj_new_exception_msg(&mp_type_SyntaxError, msg);
@@ -265,17 +263,17 @@ static void compile_syntax_error(compiler_t *comp, mp_parse_node_t pn, mp_rom_er
     }
 }
 
-static void compile_trailer_paren_helper(compiler_t *comp, mp_parse_node_t pn_arglist, bool is_method_call, int n_positional_extra);
-static void compile_comprehension(compiler_t *comp, mp_parse_node_struct_t *pns, scope_kind_t kind);
-static void compile_atom_brace_helper(compiler_t *comp, mp_parse_node_struct_t *pns, bool create_map);
-static void compile_node(compiler_t *comp, mp_parse_node_t pn);
+STATIC void compile_trailer_paren_helper(compiler_t *comp, mp_parse_node_t pn_arglist, bool is_method_call, int n_positional_extra);
+STATIC void compile_comprehension(compiler_t *comp, mp_parse_node_struct_t *pns, scope_kind_t kind);
+STATIC void compile_atom_brace_helper(compiler_t *comp, mp_parse_node_struct_t *pns, bool create_map);
+STATIC void compile_node(compiler_t *comp, mp_parse_node_t pn);
 
-static uint comp_next_label(compiler_t *comp) {
+STATIC uint comp_next_label(compiler_t *comp) {
     return comp->next_label++;
 }
 
 #if MICROPY_EMIT_NATIVE
-static void reserve_labels_for_native(compiler_t *comp, int n) {
+STATIC void reserve_labels_for_native(compiler_t *comp, int n) {
     if (comp->scope_cur->emit_options != MP_EMIT_OPT_BYTECODE) {
         comp->next_label += n;
     }
@@ -284,7 +282,7 @@ static void reserve_labels_for_native(compiler_t *comp, int n) {
 #define reserve_labels_for_native(comp, n)
 #endif
 
-static void compile_increase_except_level(compiler_t *comp, uint label, int kind) {
+STATIC void compile_increase_except_level(compiler_t *comp, uint label, int kind) {
     EMIT_ARG(setup_block, label, kind);
     comp->cur_except_level += 1;
     if (comp->cur_except_level > comp->scope_cur->exc_stack_size) {
@@ -292,14 +290,14 @@ static void compile_increase_except_level(compiler_t *comp, uint label, int kind
     }
 }
 
-static void compile_decrease_except_level(compiler_t *comp) {
+STATIC void compile_decrease_except_level(compiler_t *comp) {
     assert(comp->cur_except_level > 0);
     comp->cur_except_level -= 1;
     EMIT(end_finally);
     reserve_labels_for_native(comp, 1);
 }
 
-static scope_t *scope_new_and_link(compiler_t *comp, scope_kind_t kind, mp_parse_node_t pn, uint emit_options) {
+STATIC scope_t *scope_new_and_link(compiler_t *comp, scope_kind_t kind, mp_parse_node_t pn, uint emit_options) {
     scope_t *scope = scope_new(kind, pn, emit_options);
     scope->parent = comp->scope_cur;
     scope->next = NULL;
@@ -317,7 +315,7 @@ static scope_t *scope_new_and_link(compiler_t *comp, scope_kind_t kind, mp_parse
 
 typedef void (*apply_list_fun_t)(compiler_t *comp, mp_parse_node_t pn);
 
-static void apply_to_single_or_list(compiler_t *comp, mp_parse_node_t pn, pn_kind_t pn_list_kind, apply_list_fun_t f) {
+STATIC void apply_to_single_or_list(compiler_t *comp, mp_parse_node_t pn, pn_kind_t pn_list_kind, apply_list_fun_t f) {
     if (MP_PARSE_NODE_IS_STRUCT_KIND(pn, pn_list_kind)) {
         mp_parse_node_struct_t *pns = (mp_parse_node_struct_t *)pn;
         int num_nodes = MP_PARSE_NODE_STRUCT_NUM_NODES(pns);
@@ -329,7 +327,7 @@ static void apply_to_single_or_list(compiler_t *comp, mp_parse_node_t pn, pn_kin
     }
 }
 
-static void compile_generic_all_nodes(compiler_t *comp, mp_parse_node_struct_t *pns) {
+STATIC void compile_generic_all_nodes(compiler_t *comp, mp_parse_node_struct_t *pns) {
     int num_nodes = MP_PARSE_NODE_STRUCT_NUM_NODES(pns);
     for (int i = 0; i < num_nodes; i++) {
         compile_node(comp, pns->nodes[i]);
@@ -341,7 +339,7 @@ static void compile_generic_all_nodes(compiler_t *comp, mp_parse_node_struct_t *
     }
 }
 
-static void compile_load_id(compiler_t *comp, qstr qst) {
+STATIC void compile_load_id(compiler_t *comp, qstr qst) {
     if (comp->pass == MP_PASS_SCOPE) {
         mp_emit_common_get_id_for_load(comp->scope_cur, qst);
     } else {
@@ -353,7 +351,7 @@ static void compile_load_id(compiler_t *comp, qstr qst) {
     }
 }
 
-static void compile_store_id(compiler_t *comp, qstr qst) {
+STATIC void compile_store_id(compiler_t *comp, qstr qst) {
     if (comp->pass == MP_PASS_SCOPE) {
         mp_emit_common_get_id_for_modification(comp->scope_cur, qst);
     } else {
@@ -365,7 +363,7 @@ static void compile_store_id(compiler_t *comp, qstr qst) {
     }
 }
 
-static void compile_delete_id(compiler_t *comp, qstr qst) {
+STATIC void compile_delete_id(compiler_t *comp, qstr qst) {
     if (comp->pass == MP_PASS_SCOPE) {
         mp_emit_common_get_id_for_modification(comp->scope_cur, qst);
     } else {
@@ -377,7 +375,7 @@ static void compile_delete_id(compiler_t *comp, qstr qst) {
     }
 }
 
-static void compile_generic_tuple(compiler_t *comp, mp_parse_node_struct_t *pns) {
+STATIC void compile_generic_tuple(compiler_t *comp, mp_parse_node_struct_t *pns) {
     // a simple tuple expression
     size_t num_nodes = MP_PARSE_NODE_STRUCT_NUM_NODES(pns);
     for (size_t i = 0; i < num_nodes; i++) {
@@ -386,7 +384,7 @@ static void compile_generic_tuple(compiler_t *comp, mp_parse_node_struct_t *pns)
     EMIT_ARG(build, num_nodes, MP_EMIT_BUILD_TUPLE);
 }
 
-static void c_if_cond(compiler_t *comp, mp_parse_node_t pn, bool jump_if, int label) {
+STATIC void c_if_cond(compiler_t *comp, mp_parse_node_t pn, bool jump_if, int label) {
     if (mp_parse_node_is_const_false(pn)) {
         if (jump_if == false) {
             EMIT_ARG(jump, label);
@@ -434,9 +432,9 @@ static void c_if_cond(compiler_t *comp, mp_parse_node_t pn, bool jump_if, int la
 }
 
 typedef enum { ASSIGN_STORE, ASSIGN_AUG_LOAD, ASSIGN_AUG_STORE } assign_kind_t;
-static void c_assign(compiler_t *comp, mp_parse_node_t pn, assign_kind_t kind);
+STATIC void c_assign(compiler_t *comp, mp_parse_node_t pn, assign_kind_t kind);
 
-static void c_assign_atom_expr(compiler_t *comp, mp_parse_node_struct_t *pns, assign_kind_t assign_kind) {
+STATIC void c_assign_atom_expr(compiler_t *comp, mp_parse_node_struct_t *pns, assign_kind_t assign_kind) {
     if (assign_kind != ASSIGN_AUG_STORE) {
         compile_node(comp, pns->nodes[0]);
     }
@@ -485,7 +483,7 @@ static void c_assign_atom_expr(compiler_t *comp, mp_parse_node_struct_t *pns, as
     compile_syntax_error(comp, (mp_parse_node_t)pns, MP_ERROR_TEXT("can't assign to expression"));
 }
 
-static void c_assign_tuple(compiler_t *comp, uint num_tail, mp_parse_node_t *nodes_tail) {
+STATIC void c_assign_tuple(compiler_t *comp, uint num_tail, mp_parse_node_t *nodes_tail) {
     // look for star expression
     uint have_star_index = -1;
     for (uint i = 0; i < num_tail; i++) {
@@ -512,7 +510,7 @@ static void c_assign_tuple(compiler_t *comp, uint num_tail, mp_parse_node_t *nod
 }
 
 // assigns top of stack to pn
-static void c_assign(compiler_t *comp, mp_parse_node_t pn, assign_kind_t assign_kind) {
+STATIC void c_assign(compiler_t *comp, mp_parse_node_t pn, assign_kind_t assign_kind) {
     assert(!MP_PARSE_NODE_IS_NULL(pn));
     if (MP_PARSE_NODE_IS_LEAF(pn)) {
         if (MP_PARSE_NODE_IS_ID(pn)) {
@@ -603,7 +601,7 @@ cannot_assign:
 //  if n_pos_defaults > 0 then there is a tuple on the stack with the positional defaults
 //  if n_kw_defaults > 0 then there is a dictionary on the stack with the keyword defaults
 //  if both exist, the tuple is above the dictionary (ie the first pop gets the tuple)
-static void close_over_variables_etc(compiler_t *comp, scope_t *this_scope, int n_pos_defaults, int n_kw_defaults) {
+STATIC void close_over_variables_etc(compiler_t *comp, scope_t *this_scope, int n_pos_defaults, int n_kw_defaults) {
     assert(n_pos_defaults >= 0);
     assert(n_kw_defaults >= 0);
 
@@ -645,7 +643,7 @@ static void close_over_variables_etc(compiler_t *comp, scope_t *this_scope, int
     }
 }
 
-static void compile_funcdef_lambdef_param(compiler_t *comp, mp_parse_node_t pn) {
+STATIC void compile_funcdef_lambdef_param(compiler_t *comp, mp_parse_node_t pn) {
     // For efficiency of the code below we extract the parse-node kind here
     int pn_kind;
     if (MP_PARSE_NODE_IS_ID(pn)) {
@@ -736,7 +734,7 @@ static void compile_funcdef_lambdef_param(compiler_t *comp, mp_parse_node_t pn)
     }
 }
 
-static void compile_funcdef_lambdef(compiler_t *comp, scope_t *scope, mp_parse_node_t pn_params, pn_kind_t pn_list_kind) {
+STATIC void compile_funcdef_lambdef(compiler_t *comp, scope_t *scope, mp_parse_node_t pn_params, pn_kind_t pn_list_kind) {
     // When we call compile_funcdef_lambdef_param below it can compile an arbitrary
     // expression for default arguments, which may contain a lambda.  The lambda will
     // call here in a nested way, so we must save and restore the relevant state.
@@ -772,7 +770,7 @@ static void compile_funcdef_lambdef(compiler_t *comp, scope_t *scope, mp_parse_n
 
 // leaves function object on stack
 // returns function name
-static qstr compile_funcdef_helper(compiler_t *comp, mp_parse_node_struct_t *pns, uint emit_options) {
+STATIC qstr compile_funcdef_helper(compiler_t *comp, mp_parse_node_struct_t *pns, uint emit_options) {
     if (comp->pass == MP_PASS_SCOPE) {
         // create a new scope for this function
         scope_t *s = scope_new_and_link(comp, SCOPE_FUNCTION, (mp_parse_node_t)pns, emit_options);
@@ -792,7 +790,7 @@ static qstr compile_funcdef_helper(compiler_t *comp, mp_parse_node_struct_t *pns
 
 // leaves class object on stack
 // returns class name
-static qstr compile_classdef_helper(compiler_t *comp, mp_parse_node_struct_t *pns, uint emit_options) {
+STATIC qstr compile_classdef_helper(compiler_t *comp, mp_parse_node_struct_t *pns, uint emit_options) {
     if (comp->pass == MP_PASS_SCOPE) {
         // create a new scope for this class
         scope_t *s = scope_new_and_link(comp, SCOPE_CLASS, (mp_parse_node_t)pns, emit_options);
@@ -824,7 +822,7 @@ static qstr compile_classdef_helper(compiler_t *comp, mp_parse_node_struct_t *pn
 }
 
 // returns true if it was a built-in decorator (even if the built-in had an error)
-static bool compile_built_in_decorator(compiler_t *comp, size_t name_len, mp_parse_node_t *name_nodes, uint *emit_options) {
+STATIC bool compile_built_in_decorator(compiler_t *comp, size_t name_len, mp_parse_node_t *name_nodes, uint *emit_options) {
     if (MP_PARSE_NODE_LEAF_ARG(name_nodes[0]) != MP_QSTR_micropython) {
         return false;
     }
@@ -873,7 +871,7 @@ static bool compile_built_in_decorator(compiler_t *comp, size_t name_len, mp_par
     return true;
 }
 
-static void compile_decorated(compiler_t *comp, mp_parse_node_struct_t *pns) {
+STATIC void compile_decorated(compiler_t *comp, mp_parse_node_struct_t *pns) {
     // get the list of decorators
     mp_parse_node_t *nodes;
     size_t n = mp_parse_node_extract_list(&pns->nodes[0], PN_decorators, &nodes);
@@ -941,13 +939,13 @@ static void compile_decorated(compiler_t *comp, mp_parse_node_struct_t *pns) {
     compile_store_id(comp, body_name);
 }
 
-static void compile_funcdef(compiler_t *comp, mp_parse_node_struct_t *pns) {
+STATIC void compile_funcdef(compiler_t *comp, mp_parse_node_struct_t *pns) {
     qstr fname = compile_funcdef_helper(comp, pns, comp->scope_cur->emit_options);
     // store function object into function name
     compile_store_id(comp, fname);
 }
 
-static void c_del_stmt(compiler_t *comp, mp_parse_node_t pn) {
+STATIC void c_del_stmt(compiler_t *comp, mp_parse_node_t pn) {
     if (MP_PARSE_NODE_IS_ID(pn)) {
         compile_delete_id(comp, MP_PARSE_NODE_LEAF_ARG(pn));
     } else if (MP_PARSE_NODE_IS_STRUCT_KIND(pn, PN_atom_expr_normal)) {
@@ -1003,11 +1001,11 @@ cannot_delete:
     compile_syntax_error(comp, (mp_parse_node_t)pn, MP_ERROR_TEXT("can't delete expression"));
 }
 
-static void compile_del_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
+STATIC void compile_del_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
     apply_to_single_or_list(comp, pns->nodes[0], PN_exprlist, c_del_stmt);
 }
 
-static void compile_break_cont_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
+STATIC void compile_break_cont_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
     uint16_t label;
     if (MP_PARSE_NODE_STRUCT_KIND(pns) == PN_break_stmt) {
         label = comp->break_label;
@@ -1021,7 +1019,7 @@ static void compile_break_cont_stmt(compiler_t *comp, mp_parse_node_struct_t *pn
     EMIT_ARG(unwind_jump, label, comp->cur_except_level - comp->break_continue_except_level);
 }
 
-static void compile_return_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
+STATIC void compile_return_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
     #if MICROPY_CPYTHON_COMPAT
     if (comp->scope_cur->kind != SCOPE_FUNCTION) {
         compile_syntax_error(comp, (mp_parse_node_t)pns, MP_ERROR_TEXT("'return' outside function"));
@@ -1049,12 +1047,12 @@ static void compile_return_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
     EMIT(return_value);
 }
 
-static void compile_yield_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
+STATIC void compile_yield_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
     compile_node(comp, pns->nodes[0]);
     EMIT(pop_top);
 }
 
-static void compile_raise_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
+STATIC void compile_raise_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
     if (MP_PARSE_NODE_IS_NULL(pns->nodes[0])) {
         // raise
         EMIT_ARG(raise_varargs, 0);
@@ -1074,7 +1072,7 @@ static void compile_raise_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
 // q_base holds the base of the name
 // eg   a -> q_base=a
 //      a.b.c -> q_base=a
-static void do_import_name(compiler_t *comp, mp_parse_node_t pn, qstr *q_base) {
+STATIC void do_import_name(compiler_t *comp, mp_parse_node_t pn, qstr *q_base) {
     bool is_as = false;
     if (MP_PARSE_NODE_IS_STRUCT_KIND(pn, PN_dotted_as_name)) {
         mp_parse_node_struct_t *pns = (mp_parse_node_struct_t *)pn;
@@ -1135,7 +1133,7 @@ static void do_import_name(compiler_t *comp, mp_parse_node_t pn, qstr *q_base) {
     }
 }
 
-static void compile_dotted_as_name(compiler_t *comp, mp_parse_node_t pn) {
+STATIC void compile_dotted_as_name(compiler_t *comp, mp_parse_node_t pn) {
     EMIT_ARG(load_const_small_int, 0); // level 0 import
     EMIT_ARG(load_const_tok, MP_TOKEN_KW_NONE); // not importing from anything
     qstr q_base;
@@ -1143,11 +1141,11 @@ static void compile_dotted_as_name(compiler_t *comp, mp_parse_node_t pn) {
     compile_store_id(comp, q_base);
 }
 
-static void compile_import_name(compiler_t *comp, mp_parse_node_struct_t *pns) {
+STATIC void compile_import_name(compiler_t *comp, mp_parse_node_struct_t *pns) {
     apply_to_single_or_list(comp, pns->nodes[0], PN_dotted_as_names, compile_dotted_as_name);
 }
 
-static void compile_import_from(compiler_t *comp, mp_parse_node_struct_t *pns) {
+STATIC void compile_import_from(compiler_t *comp, mp_parse_node_struct_t *pns) {
     mp_parse_node_t pn_import_source = pns->nodes[0];
 
     // extract the preceding .'s (if any) for a relative import, to compute the import level
@@ -1235,7 +1233,7 @@ static void compile_import_from(compiler_t *comp, mp_parse_node_struct_t *pns) {
     }
 }
 
-static void compile_declare_global(compiler_t *comp, mp_parse_node_t pn, id_info_t *id_info) {
+STATIC void compile_declare_global(compiler_t *comp, mp_parse_node_t pn, id_info_t *id_info) {
     if (id_info->kind != ID_INFO_KIND_UNDECIDED && id_info->kind != ID_INFO_KIND_GLOBAL_EXPLICIT) {
         compile_syntax_error(comp, pn, MP_ERROR_TEXT("identifier redefined as global"));
         return;
@@ -1249,7 +1247,7 @@ static void compile_declare_global(compiler_t *comp, mp_parse_node_t pn, id_info
     }
 }
 
-static void compile_declare_nonlocal(compiler_t *comp, mp_parse_node_t pn, id_info_t *id_info) {
+STATIC void compile_declare_nonlocal(compiler_t *comp, mp_parse_node_t pn, id_info_t *id_info) {
     if (id_info->kind == ID_INFO_KIND_UNDECIDED) {
         id_info->kind = ID_INFO_KIND_GLOBAL_IMPLICIT;
         scope_check_to_close_over(comp->scope_cur, id_info);
@@ -1261,7 +1259,7 @@ static void compile_declare_nonlocal(compiler_t *comp, mp_parse_node_t pn, id_in
     }
 }
 
-static void compile_declare_global_or_nonlocal(compiler_t *comp, mp_parse_node_t pn, id_info_t *id_info, bool is_global) {
+STATIC void compile_declare_global_or_nonlocal(compiler_t *comp, mp_parse_node_t pn, id_info_t *id_info, bool is_global) {
     if (is_global) {
         compile_declare_global(comp, pn, id_info);
     } else {
@@ -1269,7 +1267,7 @@ static void compile_declare_global_or_nonlocal(compiler_t *comp, mp_parse_node_t
     }
 }
 
-static void compile_global_nonlocal_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
+STATIC void compile_global_nonlocal_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
     if (comp->pass == MP_PASS_SCOPE) {
         bool is_global = MP_PARSE_NODE_STRUCT_KIND(pns) == PN_global_stmt;
 
@@ -1288,7 +1286,7 @@ static void compile_global_nonlocal_stmt(compiler_t *comp, mp_parse_node_struct_
     }
 }
 
-static void compile_assert_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
+STATIC void compile_assert_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
     // with optimisations enabled we don't compile assertions
     if (MP_STATE_VM(mp_optimise_value) != 0) {
         return;
@@ -1306,7 +1304,7 @@ static void compile_assert_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
     EMIT_ARG(label_assign, l_end);
 }
 
-static void compile_if_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
+STATIC void compile_if_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
     uint l_end = comp_next_label(comp);
 
     // optimisation: don't emit anything when "if False"
@@ -1376,7 +1374,7 @@ done:
     comp->continue_label = old_continue_label; \
     comp->break_continue_except_level = old_break_continue_except_level;
 
-static void compile_while_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
+STATIC void compile_while_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
     START_BREAK_CONTINUE_BLOCK
 
     if (!mp_parse_node_is_const_false(pns->nodes[0])) { // optimisation: don't emit anything for "while False"
@@ -1414,7 +1412,7 @@ static void compile_while_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
 // If <end> is a small-int, then the stack during the for-loop contains just
 // the current value of <var>.  Otherwise, the stack contains <end> then the
 // current value of <var>.
-static void compile_for_stmt_optimised_range(compiler_t *comp, mp_parse_node_t pn_var, mp_parse_node_t pn_start, mp_parse_node_t pn_end, mp_parse_node_t pn_step, mp_parse_node_t pn_body, mp_parse_node_t pn_else) {
+STATIC void compile_for_stmt_optimised_range(compiler_t *comp, mp_parse_node_t pn_var, mp_parse_node_t pn_start, mp_parse_node_t pn_end, mp_parse_node_t pn_step, mp_parse_node_t pn_body, mp_parse_node_t pn_else) {
     START_BREAK_CONTINUE_BLOCK
 
     uint top_label = comp_next_label(comp);
@@ -1496,7 +1494,7 @@ static void compile_for_stmt_optimised_range(compiler_t *comp, mp_parse_node_t p
     }
 }
 
-static void compile_for_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
+STATIC void compile_for_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
     // this bit optimises: for <x> in range(...), turning it into an explicitly incremented variable
     // this is actually slower, but uses no heap memory
     // for viper it will be much, much faster
@@ -1576,7 +1574,7 @@ static void compile_for_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
     EMIT_ARG(label_assign, break_label);
 }
 
-static void compile_try_except(compiler_t *comp, mp_parse_node_t pn_body, int n_except, mp_parse_node_t *pn_excepts, mp_parse_node_t pn_else) {
+STATIC void compile_try_except(compiler_t *comp, mp_parse_node_t pn_body, int n_except, mp_parse_node_t *pn_excepts, mp_parse_node_t pn_else) {
     // setup code
     uint l1 = comp_next_label(comp);
     uint success_label = comp_next_label(comp);
@@ -1673,7 +1671,7 @@ static void compile_try_except(compiler_t *comp, mp_parse_node_t pn_body, int n_
     EMIT_ARG(label_assign, l2);
 }
 
-static void compile_try_finally(compiler_t *comp, mp_parse_node_t pn_body, int n_except, mp_parse_node_t *pn_except, mp_parse_node_t pn_else, mp_parse_node_t pn_finally) {
+STATIC void compile_try_finally(compiler_t *comp, mp_parse_node_t pn_body, int n_except, mp_parse_node_t *pn_except, mp_parse_node_t pn_else, mp_parse_node_t pn_finally) {
     uint l_finally_block = comp_next_label(comp);
 
     compile_increase_except_level(comp, l_finally_block, MP_EMIT_SETUP_BLOCK_FINALLY);
@@ -1702,7 +1700,7 @@ static void compile_try_finally(compiler_t *comp, mp_parse_node_t pn_body, int n
     compile_decrease_except_level(comp);
 }
 
-static void compile_try_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
+STATIC void compile_try_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
     assert(MP_PARSE_NODE_IS_STRUCT(pns->nodes[1])); // should be
     {
         mp_parse_node_struct_t *pns2 = (mp_parse_node_struct_t *)pns->nodes[1];
@@ -1729,7 +1727,7 @@ static void compile_try_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
     }
 }
 
-static void compile_with_stmt_helper(compiler_t *comp, size_t n, mp_parse_node_t *nodes, mp_parse_node_t body) {
+STATIC void compile_with_stmt_helper(compiler_t *comp, size_t n, mp_parse_node_t *nodes, mp_parse_node_t body) {
     if (n == 0) {
         // no more pre-bits, compile the body of the with
         compile_node(comp, body);
@@ -1756,7 +1754,7 @@ static void compile_with_stmt_helper(compiler_t *comp, size_t n, mp_parse_node_t
     }
 }
 
-static void compile_with_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
+STATIC void compile_with_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
     // get the nodes for the pre-bit of the with (the a as b, c as d, ... bit)
     mp_parse_node_t *nodes;
     size_t n = mp_parse_node_extract_list(&pns->nodes[0], PN_with_stmt_list, &nodes);
@@ -1766,7 +1764,7 @@ static void compile_with_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
     compile_with_stmt_helper(comp, n, nodes, pns->nodes[1]);
 }
 
-static void compile_yield_from(compiler_t *comp) {
+STATIC void compile_yield_from(compiler_t *comp) {
     EMIT_ARG(get_iter, false);
     EMIT_ARG(load_const_tok, MP_TOKEN_KW_NONE);
     EMIT_ARG(yield, MP_EMIT_YIELD_FROM);
@@ -1774,13 +1772,13 @@ static void compile_yield_from(compiler_t *comp) {
 }
 
 #if MICROPY_PY_ASYNC_AWAIT
-static void compile_await_object_method(compiler_t *comp, qstr method) {
+STATIC void compile_await_object_method(compiler_t *comp, qstr method) {
     EMIT_ARG(load_method, method, false);
     EMIT_ARG(call_method, 0, 0, 0);
     compile_yield_from(comp);
 }
 
-static void compile_async_for_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
+STATIC void compile_async_for_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
     // Allocate labels.
     uint while_else_label = comp_next_label(comp);
     uint try_exception_label = comp_next_label(comp);
@@ -1847,7 +1845,7 @@ static void compile_async_for_stmt(compiler_t *comp, mp_parse_node_struct_t *pns
     // Stack: (...)
 }
 
-static void compile_async_with_stmt_helper(compiler_t *comp, size_t n, mp_parse_node_t *nodes, mp_parse_node_t body) {
+STATIC void compile_async_with_stmt_helper(compiler_t *comp, size_t n, mp_parse_node_t *nodes, mp_parse_node_t body) {
     if (n == 0) {
         // no more pre-bits, compile the body of the with
         compile_node(comp, body);
@@ -1959,7 +1957,7 @@ static void compile_async_with_stmt_helper(compiler_t *comp, size_t n, mp_parse_
     }
 }
 
-static void compile_async_with_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
+STATIC void compile_async_with_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
     // get the nodes for the pre-bit of the with (the a as b, c as d, ... bit)
     mp_parse_node_t *nodes;
     size_t n = mp_parse_node_extract_list(&pns->nodes[0], PN_with_stmt_list, &nodes);
@@ -1969,7 +1967,7 @@ static void compile_async_with_stmt(compiler_t *comp, mp_parse_node_struct_t *pn
     compile_async_with_stmt_helper(comp, n, nodes, pns->nodes[1]);
 }
 
-static void compile_async_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
+STATIC void compile_async_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
     assert(MP_PARSE_NODE_IS_STRUCT(pns->nodes[0]));
     mp_parse_node_struct_t *pns0 = (mp_parse_node_struct_t *)pns->nodes[0];
     if (MP_PARSE_NODE_STRUCT_KIND(pns0) == PN_funcdef) {
@@ -1998,7 +1996,7 @@ static void compile_async_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
 }
 #endif
 
-static void compile_expr_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
+STATIC void compile_expr_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
     mp_parse_node_t pn_rhs = pns->nodes[1];
     if (MP_PARSE_NODE_IS_NULL(pn_rhs)) {
         if (comp->is_repl && comp->scope_cur->kind == SCOPE_MODULE) {
@@ -2113,7 +2111,7 @@ static void compile_expr_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
     }
 }
 
-static void compile_test_if_expr(compiler_t *comp, mp_parse_node_struct_t *pns) {
+STATIC void compile_test_if_expr(compiler_t *comp, mp_parse_node_struct_t *pns) {
     assert(MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[1], PN_test_if_else));
     mp_parse_node_struct_t *pns_test_if_else = (mp_parse_node_struct_t *)pns->nodes[1];
 
@@ -2128,7 +2126,7 @@ static void compile_test_if_expr(compiler_t *comp, mp_parse_node_struct_t *pns)
     EMIT_ARG(label_assign, l_end);
 }
 
-static void compile_lambdef(compiler_t *comp, mp_parse_node_struct_t *pns) {
+STATIC void compile_lambdef(compiler_t *comp, mp_parse_node_struct_t *pns) {
     if (comp->pass == MP_PASS_SCOPE) {
         // create a new scope for this lambda
         scope_t *s = scope_new_and_link(comp, SCOPE_LAMBDA, (mp_parse_node_t)pns, comp->scope_cur->emit_options);
@@ -2144,7 +2142,7 @@ static void compile_lambdef(compiler_t *comp, mp_parse_node_struct_t *pns) {
 }
 
 #if MICROPY_PY_ASSIGN_EXPR
-static void compile_namedexpr_helper(compiler_t *comp, mp_parse_node_t pn_name, mp_parse_node_t pn_expr) {
+STATIC void compile_namedexpr_helper(compiler_t *comp, mp_parse_node_t pn_name, mp_parse_node_t pn_expr) {
     if (!MP_PARSE_NODE_IS_ID(pn_name)) {
         compile_syntax_error(comp, (mp_parse_node_t)pn_name, MP_ERROR_TEXT("can't assign to expression"));
     }
@@ -2176,12 +2174,12 @@ static void compile_namedexpr_helper(compiler_t *comp, mp_parse_node_t pn_name,
     compile_store_id(comp, target);
 }
 
-static void compile_namedexpr(compiler_t *comp, mp_parse_node_struct_t *pns) {
+STATIC void compile_namedexpr(compiler_t *comp, mp_parse_node_struct_t *pns) {
     compile_namedexpr_helper(comp, pns->nodes[0], pns->nodes[1]);
 }
 #endif
 
-static void compile_or_and_test(compiler_t *comp, mp_parse_node_struct_t *pns) {
+STATIC void compile_or_and_test(compiler_t *comp, mp_parse_node_struct_t *pns) {
     bool cond = MP_PARSE_NODE_STRUCT_KIND(pns) == PN_or_test;
     uint l_end = comp_next_label(comp);
     int n = MP_PARSE_NODE_STRUCT_NUM_NODES(pns);
@@ -2194,12 +2192,12 @@ static void compile_or_and_test(compiler_t *comp, mp_parse_node_struct_t *pns) {
     EMIT_ARG(label_assign, l_end);
 }
 
-static void compile_not_test_2(compiler_t *comp, mp_parse_node_struct_t *pns) {
+STATIC void compile_not_test_2(compiler_t *comp, mp_parse_node_struct_t *pns) {
     compile_node(comp, pns->nodes[0]);
     EMIT_ARG(unary_op, MP_UNARY_OP_NOT);
 }
 
-static void compile_comparison(compiler_t *comp, mp_parse_node_struct_t *pns) {
+STATIC void compile_comparison(compiler_t *comp, mp_parse_node_struct_t *pns) {
     int num_nodes = MP_PARSE_NODE_STRUCT_NUM_NODES(pns);
     compile_node(comp, pns->nodes[0]);
     bool multi = (num_nodes > 3);
@@ -2252,11 +2250,11 @@ static void compile_comparison(compiler_t *comp, mp_parse_node_struct_t *pns) {
     }
 }
 
-static void compile_star_expr(compiler_t *comp, mp_parse_node_struct_t *pns) {
+STATIC void compile_star_expr(compiler_t *comp, mp_parse_node_struct_t *pns) {
     compile_syntax_error(comp, (mp_parse_node_t)pns, MP_ERROR_TEXT("*x must be assignment target"));
 }
 
-static void compile_binary_op(compiler_t *comp, mp_parse_node_struct_t *pns) {
+STATIC void compile_binary_op(compiler_t *comp, mp_parse_node_struct_t *pns) {
     MP_STATIC_ASSERT(MP_BINARY_OP_OR + PN_xor_expr - PN_expr == MP_BINARY_OP_XOR);
     MP_STATIC_ASSERT(MP_BINARY_OP_OR + PN_and_expr - PN_expr == MP_BINARY_OP_AND);
     mp_binary_op_t binary_op = MP_BINARY_OP_OR + MP_PARSE_NODE_STRUCT_KIND(pns) - PN_expr;
@@ -2268,7 +2266,7 @@ static void compile_binary_op(compiler_t *comp, mp_parse_node_struct_t *pns) {
     }
 }
 
-static void compile_term(compiler_t *comp, mp_parse_node_struct_t *pns) {
+STATIC void compile_term(compiler_t *comp, mp_parse_node_struct_t *pns) {
     int num_nodes = MP_PARSE_NODE_STRUCT_NUM_NODES(pns);
     compile_node(comp, pns->nodes[0]);
     for (int i = 1; i + 1 < num_nodes; i += 2) {
@@ -2279,7 +2277,7 @@ static void compile_term(compiler_t *comp, mp_parse_node_struct_t *pns) {
     }
 }
 
-static void compile_factor_2(compiler_t *comp, mp_parse_node_struct_t *pns) {
+STATIC void compile_factor_2(compiler_t *comp, mp_parse_node_struct_t *pns) {
     compile_node(comp, pns->nodes[1]);
     mp_token_kind_t tok = MP_PARSE_NODE_LEAF_ARG(pns->nodes[0]);
     mp_unary_op_t op;
@@ -2292,7 +2290,7 @@ static void compile_factor_2(compiler_t *comp, mp_parse_node_struct_t *pns) {
     EMIT_ARG(unary_op, op);
 }
 
-static void compile_atom_expr_normal(compiler_t *comp, mp_parse_node_struct_t *pns) {
+STATIC void compile_atom_expr_normal(compiler_t *comp, mp_parse_node_struct_t *pns) {
     // compile the subject of the expression
     compile_node(comp, pns->nodes[0]);
 
@@ -2388,12 +2386,12 @@ static void compile_atom_expr_normal(compiler_t *comp, mp_parse_node_struct_t *p
     }
 }
 
-static void compile_power(compiler_t *comp, mp_parse_node_struct_t *pns) {
+STATIC void compile_power(compiler_t *comp, mp_parse_node_struct_t *pns) {
     compile_generic_all_nodes(comp, pns); // 2 nodes, arguments of power
     EMIT_ARG(binary_op, MP_BINARY_OP_POWER);
 }
 
-static void compile_trailer_paren_helper(compiler_t *comp, mp_parse_node_t pn_arglist, bool is_method_call, int n_positional_extra) {
+STATIC void compile_trailer_paren_helper(compiler_t *comp, mp_parse_node_t pn_arglist, bool is_method_call, int n_positional_extra) {
     // function to call is on top of stack
 
     // get the list of arguments
@@ -2488,7 +2486,7 @@ static void compile_trailer_paren_helper(compiler_t *comp, mp_parse_node_t pn_ar
 }
 
 // pns needs to have 2 nodes, first is lhs of comprehension, second is PN_comp_for node
-static void compile_comprehension(compiler_t *comp, mp_parse_node_struct_t *pns, scope_kind_t kind) {
+STATIC void compile_comprehension(compiler_t *comp, mp_parse_node_struct_t *pns, scope_kind_t kind) {
     assert(MP_PARSE_NODE_STRUCT_NUM_NODES(pns) == 2);
     assert(MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[1], PN_comp_for));
     mp_parse_node_struct_t *pns_comp_for = (mp_parse_node_struct_t *)pns->nodes[1];
@@ -2513,7 +2511,7 @@ static void compile_comprehension(compiler_t *comp, mp_parse_node_struct_t *pns,
     EMIT_ARG(call_function, 1, 0, 0);
 }
 
-static void compile_atom_paren(compiler_t *comp, mp_parse_node_struct_t *pns) {
+STATIC void compile_atom_paren(compiler_t *comp, mp_parse_node_struct_t *pns) {
     if (MP_PARSE_NODE_IS_NULL(pns->nodes[0])) {
         // an empty tuple
         EMIT_ARG(build, 0, MP_EMIT_BUILD_TUPLE);
@@ -2530,7 +2528,7 @@ static void compile_atom_paren(compiler_t *comp, mp_parse_node_struct_t *pns) {
     }
 }
 
-static void compile_atom_bracket(compiler_t *comp, mp_parse_node_struct_t *pns) {
+STATIC void compile_atom_bracket(compiler_t *comp, mp_parse_node_struct_t *pns) {
     if (MP_PARSE_NODE_IS_NULL(pns->nodes[0])) {
         // empty list
         EMIT_ARG(build, 0, MP_EMIT_BUILD_LIST);
@@ -2551,7 +2549,7 @@ static void compile_atom_bracket(compiler_t *comp, mp_parse_node_struct_t *pns)
     }
 }
 
-static void compile_atom_brace_helper(compiler_t *comp, mp_parse_node_struct_t *pns, bool create_map) {
+STATIC void compile_atom_brace_helper(compiler_t *comp, mp_parse_node_struct_t *pns, bool create_map) {
     mp_parse_node_t pn = pns->nodes[0];
     if (MP_PARSE_NODE_IS_NULL(pn)) {
         // empty dict
@@ -2653,27 +2651,27 @@ static void compile_atom_brace_helper(compiler_t *comp, mp_parse_node_struct_t *
     }
 }
 
-static void compile_atom_brace(compiler_t *comp, mp_parse_node_struct_t *pns) {
+STATIC void compile_atom_brace(compiler_t *comp, mp_parse_node_struct_t *pns) {
     compile_atom_brace_helper(comp, pns, true);
 }
 
-static void compile_trailer_paren(compiler_t *comp, mp_parse_node_struct_t *pns) {
+STATIC void compile_trailer_paren(compiler_t *comp, mp_parse_node_struct_t *pns) {
     compile_trailer_paren_helper(comp, pns->nodes[0], false, 0);
 }
 
-static void compile_trailer_bracket(compiler_t *comp, mp_parse_node_struct_t *pns) {
+STATIC void compile_trailer_bracket(compiler_t *comp, mp_parse_node_struct_t *pns) {
     // object who's index we want is on top of stack
     compile_node(comp, pns->nodes[0]); // the index
     EMIT_ARG(subscr, MP_EMIT_SUBSCR_LOAD);
 }
 
-static void compile_trailer_period(compiler_t *comp, mp_parse_node_struct_t *pns) {
+STATIC void compile_trailer_period(compiler_t *comp, mp_parse_node_struct_t *pns) {
     // object who's attribute we want is on top of stack
     EMIT_ARG(attr, MP_PARSE_NODE_LEAF_ARG(pns->nodes[0]), MP_EMIT_ATTR_LOAD); // attribute to get
 }
 
 #if MICROPY_PY_BUILTINS_SLICE
-static void compile_subscript(compiler_t *comp, mp_parse_node_struct_t *pns) {
+STATIC void compile_subscript(compiler_t *comp, mp_parse_node_struct_t *pns) {
     if (MP_PARSE_NODE_STRUCT_KIND(pns) == PN_subscript_2) {
         compile_node(comp, pns->nodes[0]); // start of slice
         assert(MP_PARSE_NODE_IS_STRUCT(pns->nodes[1])); // should always be
@@ -2728,19 +2726,19 @@ static void compile_subscript(compiler_t *comp, mp_parse_node_struct_t *pns) {
 }
 #endif // MICROPY_PY_BUILTINS_SLICE
 
-static void compile_dictorsetmaker_item(compiler_t *comp, mp_parse_node_struct_t *pns) {
+STATIC void compile_dictorsetmaker_item(compiler_t *comp, mp_parse_node_struct_t *pns) {
     // if this is called then we are compiling a dict key:value pair
     compile_node(comp, pns->nodes[1]); // value
     compile_node(comp, pns->nodes[0]); // key
 }
 
-static void compile_classdef(compiler_t *comp, mp_parse_node_struct_t *pns) {
+STATIC void compile_classdef(compiler_t *comp, mp_parse_node_struct_t *pns) {
     qstr cname = compile_classdef_helper(comp, pns, comp->scope_cur->emit_options);
     // store class object into class name
     compile_store_id(comp, cname);
 }
 
-static void compile_yield_expr(compiler_t *comp, mp_parse_node_struct_t *pns) {
+STATIC void compile_yield_expr(compiler_t *comp, mp_parse_node_struct_t *pns) {
     if (comp->scope_cur->kind != SCOPE_FUNCTION && comp->scope_cur->kind != SCOPE_LAMBDA) {
         compile_syntax_error(comp, (mp_parse_node_t)pns, MP_ERROR_TEXT("'yield' outside function"));
         return;
@@ -2761,31 +2759,26 @@ static void compile_yield_expr(compiler_t *comp, mp_parse_node_struct_t *pns) {
 }
 
 #if MICROPY_PY_ASYNC_AWAIT
-static void compile_atom_expr_await(compiler_t *comp, mp_parse_node_struct_t *pns) {
+STATIC void compile_atom_expr_await(compiler_t *comp, mp_parse_node_struct_t *pns) {
     if (comp->scope_cur->kind != SCOPE_FUNCTION && comp->scope_cur->kind != SCOPE_LAMBDA) {
-        #if MICROPY_COMP_ALLOW_TOP_LEVEL_AWAIT
-        if (!mp_compile_allow_top_level_await)
-        #endif
-        {
-            compile_syntax_error(comp, (mp_parse_node_t)pns, MP_ERROR_TEXT("'await' outside function"));
-            return;
-        }
+        compile_syntax_error(comp, (mp_parse_node_t)pns, MP_ERROR_TEXT("'await' outside function"));
+        return;
     }
     compile_atom_expr_normal(comp, pns);
     compile_yield_from(comp);
 }
 #endif
 
-static mp_obj_t get_const_object(mp_parse_node_struct_t *pns) {
+STATIC mp_obj_t get_const_object(mp_parse_node_struct_t *pns) {
     return mp_parse_node_extract_const_object(pns);
 }
 
-static void compile_const_object(compiler_t *comp, mp_parse_node_struct_t *pns) {
+STATIC void compile_const_object(compiler_t *comp, mp_parse_node_struct_t *pns) {
     EMIT_ARG(load_const_obj, get_const_object(pns));
 }
 
 typedef void (*compile_function_t)(compiler_t *, mp_parse_node_struct_t *);
-static const compile_function_t compile_function[] = {
+STATIC const compile_function_t compile_function[] = {
 // only define rules with a compile function
 #define c(f) compile_##f
 #define DEF_RULE(rule, comp, kind, ...) comp,
@@ -2797,7 +2790,7 @@ static const compile_function_t compile_function[] = {
     compile_const_object,
 };
 
-static void compile_node(compiler_t *comp, mp_parse_node_t pn) {
+STATIC void compile_node(compiler_t *comp, mp_parse_node_t pn) {
     if (MP_PARSE_NODE_IS_NULL(pn)) {
         // pass
     } else if (MP_PARSE_NODE_IS_SMALL_INT(pn)) {
@@ -2833,7 +2826,7 @@ static void compile_node(compiler_t *comp, mp_parse_node_t pn) {
 }
 
 #if MICROPY_EMIT_NATIVE
-static int compile_viper_type_annotation(compiler_t *comp, mp_parse_node_t pn_annotation) {
+STATIC int compile_viper_type_annotation(compiler_t *comp, mp_parse_node_t pn_annotation) {
     int native_type = MP_NATIVE_TYPE_OBJ;
     if (MP_PARSE_NODE_IS_NULL(pn_annotation)) {
         // No annotation, type defaults to object
@@ -2851,7 +2844,7 @@ static int compile_viper_type_annotation(compiler_t *comp, mp_parse_node_t pn_an
 }
 #endif
 
-static void compile_scope_func_lambda_param(compiler_t *comp, mp_parse_node_t pn, pn_kind_t pn_name, pn_kind_t pn_star, pn_kind_t pn_dbl_star) {
+STATIC void compile_scope_func_lambda_param(compiler_t *comp, mp_parse_node_t pn, pn_kind_t pn_name, pn_kind_t pn_star, pn_kind_t pn_dbl_star) {
     (void)pn_dbl_star;
 
     // check that **kw is last
@@ -2938,15 +2931,15 @@ static void compile_scope_func_lambda_param(compiler_t *comp, mp_parse_node_t pn
     }
 }
 
-static void compile_scope_func_param(compiler_t *comp, mp_parse_node_t pn) {
+STATIC void compile_scope_func_param(compiler_t *comp, mp_parse_node_t pn) {
     compile_scope_func_lambda_param(comp, pn, PN_typedargslist_name, PN_typedargslist_star, PN_typedargslist_dbl_star);
 }
 
-static void compile_scope_lambda_param(compiler_t *comp, mp_parse_node_t pn) {
+STATIC void compile_scope_lambda_param(compiler_t *comp, mp_parse_node_t pn) {
     compile_scope_func_lambda_param(comp, pn, PN_varargslist_name, PN_varargslist_star, PN_varargslist_dbl_star);
 }
 
-static void compile_scope_comp_iter(compiler_t *comp, mp_parse_node_struct_t *pns_comp_for, mp_parse_node_t pn_inner_expr, int for_depth) {
+STATIC void compile_scope_comp_iter(compiler_t *comp, mp_parse_node_struct_t *pns_comp_for, mp_parse_node_t pn_inner_expr, int for_depth) {
     uint l_top = comp_next_label(comp);
     uint l_end = comp_next_label(comp);
     EMIT_ARG(label_assign, l_top);
@@ -2985,7 +2978,7 @@ tail_recursion:
     EMIT(for_iter_end);
 }
 
-static void check_for_doc_string(compiler_t *comp, mp_parse_node_t pn) {
+STATIC void check_for_doc_string(compiler_t *comp, mp_parse_node_t pn) {
     #if MICROPY_ENABLE_DOC_STRING
     // see http://www.python.org/dev/peps/pep-0257/
 
@@ -3030,7 +3023,7 @@ static void check_for_doc_string(compiler_t *comp, mp_parse_node_t pn) {
     #endif
 }
 
-static bool compile_scope(compiler_t *comp, scope_t *scope, pass_kind_t pass) {
+STATIC bool compile_scope(compiler_t *comp, scope_t *scope, pass_kind_t pass) {
     comp->pass = pass;
     comp->scope_cur = scope;
     comp->next_label = 0;
@@ -3195,7 +3188,7 @@ static bool compile_scope(compiler_t *comp, scope_t *scope, pass_kind_t pass) {
 
 #if MICROPY_EMIT_INLINE_ASM
 // requires 3 passes: SCOPE, CODE_SIZE, EMIT
-static void compile_scope_inline_asm(compiler_t *comp, scope_t *scope, pass_kind_t pass) {
+STATIC void compile_scope_inline_asm(compiler_t *comp, scope_t *scope, pass_kind_t pass) {
     comp->pass = pass;
     comp->scope_cur = scope;
     comp->next_label = 0;
@@ -3370,7 +3363,7 @@ static void compile_scope_inline_asm(compiler_t *comp, scope_t *scope, pass_kind
 }
 #endif
 
-static void scope_compute_things(scope_t *scope) {
+STATIC void scope_compute_things(scope_t *scope) {
     // in MicroPython we put the *x parameter after all other parameters (except **y)
     if (scope->scope_flags & MP_SCOPE_FLAG_VARARGS) {
         id_info_t *id_param = NULL;
@@ -3464,7 +3457,7 @@ static void scope_compute_things(scope_t *scope) {
 }
 
 #if !MICROPY_PERSISTENT_CODE_SAVE
-static
+STATIC
 #endif
 void mp_compile_to_raw_code(mp_parse_tree_t *parse_tree, qstr source_file, bool is_repl, mp_compiled_module_t *cm) {
     // put compiler state on the stack, it's relatively small
@@ -3632,7 +3625,7 @@ void mp_compile_to_raw_code(mp_parse_tree_t *parse_tree, qstr source_file, bool
             for (scope_t *s = comp->scope_head; s != NULL; s = s->next) {
                 mp_raw_code_t *rc = s->raw_code;
                 if (rc->kind == MP_CODE_BYTECODE) {
-                    mp_bytecode_print(&mp_plat_print, rc, s->raw_code_data_len, &cm->context->constants);
+                    mp_bytecode_print(&mp_plat_print, rc, &cm->context->constants);
                 }
             }
         }
@@ -3674,7 +3667,7 @@ mp_obj_t mp_compile(mp_parse_tree_t *parse_tree, qstr source_file, bool is_repl)
     cm.context->module.globals = mp_globals_get();
     mp_compile_to_raw_code(parse_tree, source_file, is_repl, &cm);
     // return function that executes the outer module
-    return mp_make_function_from_proto_fun(cm.rc, cm.context, NULL);
+    return mp_make_function_from_raw_code(cm.rc, cm.context, NULL);
 }
 
 #endif // MICROPY_ENABLE_COMPILER

+ 0 - 5
py/compile.h

@@ -30,11 +30,6 @@
 #include "py/parse.h"
 #include "py/emitglue.h"
 
-#if MICROPY_COMP_ALLOW_TOP_LEVEL_AWAIT
-// set to `true` to allow top-level await expressions
-extern bool mp_compile_allow_top_level_await;
-#endif
-
 // the compiler will raise an exception if an error occurred
 // the compiler will clear the parse tree before it returns
 // mp_globals_get() will be used for the context

+ 5 - 12
py/dynruntime.h

@@ -29,7 +29,6 @@
 // This header file contains definitions to dynamically implement the static
 // MicroPython runtime API defined in py/obj.h and py/runtime.h.
 
-#include "py/binary.h"
 #include "py/nativeglue.h"
 #include "py/objfun.h"
 #include "py/objstr.h"
@@ -185,10 +184,6 @@ static inline void *mp_obj_malloc_helper_dyn(size_t num_bytes, const mp_obj_type
 /******************************************************************************/
 // General runtime functions
 
-#define mp_binary_get_size(struct_type, val_type, palign) (mp_fun_table.binary_get_size((struct_type), (val_type), (palign)))
-#define mp_binary_get_val_array(typecode, p, index) (mp_fun_table.binary_get_val_array((typecode), (p), (index)))
-#define mp_binary_set_val_array(typecode, p, index, val_in) (mp_fun_table.binary_set_val_array((typecode), (p), (index), (val_in)))
-
 #define mp_load_name(qst)                 (mp_fun_table.load_name((qst)))
 #define mp_load_global(qst)               (mp_fun_table.load_global((qst)))
 #define mp_load_attr(base, attr)          (mp_fun_table.load_attr((base), (attr)))
@@ -201,8 +196,8 @@ static inline void *mp_obj_malloc_helper_dyn(size_t num_bytes, const mp_obj_type
 #define mp_unary_op(op, obj)        (mp_fun_table.unary_op((op), (obj)))
 #define mp_binary_op(op, lhs, rhs)  (mp_fun_table.binary_op((op), (lhs), (rhs)))
 
-#define mp_make_function_from_proto_fun(rc, context, def_args) \
-    (mp_fun_table.make_function_from_proto_fun((rc), (context), (def_args)))
+#define mp_make_function_from_raw_code(rc, context, def_args) \
+    (mp_fun_table.make_function_from_raw_code((rc), (context), (def_args)))
 
 #define mp_call_function_n_kw(fun, n_args, n_kw, args) \
     (mp_fun_table.call_function_n_kw((fun), (n_args) | ((n_kw) << 8), args))
@@ -212,11 +207,9 @@ static inline void *mp_obj_malloc_helper_dyn(size_t num_bytes, const mp_obj_type
 
 #define MP_DYNRUNTIME_INIT_ENTRY \
     mp_obj_t old_globals = mp_fun_table.swap_globals(self->context->module.globals); \
-    mp_raw_code_truncated_t rc; \
-    rc.proto_fun_indicator[0] = MP_PROTO_FUN_INDICATOR_RAW_CODE_0; \
-    rc.proto_fun_indicator[1] = MP_PROTO_FUN_INDICATOR_RAW_CODE_1; \
+    mp_raw_code_t rc; \
     rc.kind = MP_CODE_NATIVE_VIPER; \
-    rc.is_generator = 0; \
+    rc.scope_flags = 0; \
     (void)rc;
 
 #define MP_DYNRUNTIME_INIT_EXIT \
@@ -224,7 +217,7 @@ static inline void *mp_obj_malloc_helper_dyn(size_t num_bytes, const mp_obj_type
     return mp_const_none;
 
 #define MP_DYNRUNTIME_MAKE_FUNCTION(f) \
-    (mp_make_function_from_proto_fun((rc.fun_data = (f), (const mp_raw_code_t *)&rc), self->context, NULL))
+    (mp_make_function_from_raw_code((rc.fun_data = (f), &rc), self->context, NULL))
 
 #define mp_import_name(name, fromlist, level) \
     (mp_fun_table.import_name((name), (fromlist), (level)))

+ 19 - 23
py/emitbc.c

@@ -92,7 +92,7 @@ void emit_bc_free(emit_t *emit) {
 }
 
 // all functions must go through this one to emit code info
-static uint8_t *emit_get_cur_to_write_code_info(void *emit_in, size_t num_bytes_to_write) {
+STATIC uint8_t *emit_get_cur_to_write_code_info(void *emit_in, size_t num_bytes_to_write) {
     emit_t *emit = emit_in;
     if (emit->pass < MP_PASS_EMIT) {
         emit->code_info_offset += num_bytes_to_write;
@@ -105,16 +105,16 @@ static uint8_t *emit_get_cur_to_write_code_info(void *emit_in, size_t num_bytes_
     }
 }
 
-static void emit_write_code_info_byte(emit_t *emit, byte val) {
+STATIC void emit_write_code_info_byte(emit_t *emit, byte val) {
     *emit_get_cur_to_write_code_info(emit, 1) = val;
 }
 
-static void emit_write_code_info_qstr(emit_t *emit, qstr qst) {
+STATIC void emit_write_code_info_qstr(emit_t *emit, qstr qst) {
     mp_encode_uint(emit, emit_get_cur_to_write_code_info, mp_emit_common_use_qstr(emit->emit_common, qst));
 }
 
 #if MICROPY_ENABLE_SOURCE_LINE
-static void emit_write_code_info_bytes_lines(emit_t *emit, mp_uint_t bytes_to_skip, mp_uint_t lines_to_skip) {
+STATIC void emit_write_code_info_bytes_lines(emit_t *emit, mp_uint_t bytes_to_skip, mp_uint_t lines_to_skip) {
     assert(bytes_to_skip > 0 || lines_to_skip > 0);
     while (bytes_to_skip > 0 || lines_to_skip > 0) {
         mp_uint_t b, l;
@@ -143,7 +143,7 @@ static void emit_write_code_info_bytes_lines(emit_t *emit, mp_uint_t bytes_to_sk
 #endif
 
 // all functions must go through this one to emit byte code
-static uint8_t *emit_get_cur_to_write_bytecode(void *emit_in, size_t num_bytes_to_write) {
+STATIC uint8_t *emit_get_cur_to_write_bytecode(void *emit_in, size_t num_bytes_to_write) {
     emit_t *emit = emit_in;
     if (emit->suppress) {
         return emit->dummy_data;
@@ -159,19 +159,19 @@ static uint8_t *emit_get_cur_to_write_bytecode(void *emit_in, size_t num_bytes_t
     }
 }
 
-static void emit_write_bytecode_raw_byte(emit_t *emit, byte b1) {
+STATIC void emit_write_bytecode_raw_byte(emit_t *emit, byte b1) {
     byte *c = emit_get_cur_to_write_bytecode(emit, 1);
     c[0] = b1;
 }
 
-static void emit_write_bytecode_byte(emit_t *emit, int stack_adj, byte b1) {
+STATIC void emit_write_bytecode_byte(emit_t *emit, int stack_adj, byte b1) {
     mp_emit_bc_adjust_stack_size(emit, stack_adj);
     byte *c = emit_get_cur_to_write_bytecode(emit, 1);
     c[0] = b1;
 }
 
 // Similar to mp_encode_uint(), just some extra handling to encode sign
-static void emit_write_bytecode_byte_int(emit_t *emit, int stack_adj, byte b1, mp_int_t num) {
+STATIC void emit_write_bytecode_byte_int(emit_t *emit, int stack_adj, byte b1, mp_int_t num) {
     emit_write_bytecode_byte(emit, stack_adj, b1);
 
     // We store each 7 bits in a separate byte, and that's how many bytes needed
@@ -197,24 +197,24 @@ static void emit_write_bytecode_byte_int(emit_t *emit, int stack_adj, byte b1, m
     *c = *p;
 }
 
-static void emit_write_bytecode_byte_uint(emit_t *emit, int stack_adj, byte b, mp_uint_t val) {
+STATIC void emit_write_bytecode_byte_uint(emit_t *emit, int stack_adj, byte b, mp_uint_t val) {
     emit_write_bytecode_byte(emit, stack_adj, b);
     mp_encode_uint(emit, emit_get_cur_to_write_bytecode, val);
 }
 
-static void emit_write_bytecode_byte_const(emit_t *emit, int stack_adj, byte b, mp_uint_t n) {
+STATIC void emit_write_bytecode_byte_const(emit_t *emit, int stack_adj, byte b, mp_uint_t n) {
     emit_write_bytecode_byte_uint(emit, stack_adj, b, n);
 }
 
-static void emit_write_bytecode_byte_qstr(emit_t *emit, int stack_adj, byte b, qstr qst) {
+STATIC void emit_write_bytecode_byte_qstr(emit_t *emit, int stack_adj, byte b, qstr qst) {
     emit_write_bytecode_byte_uint(emit, stack_adj, b, mp_emit_common_use_qstr(emit->emit_common, qst));
 }
 
-static void emit_write_bytecode_byte_obj(emit_t *emit, int stack_adj, byte b, mp_obj_t obj) {
+STATIC void emit_write_bytecode_byte_obj(emit_t *emit, int stack_adj, byte b, mp_obj_t obj) {
     emit_write_bytecode_byte_const(emit, stack_adj, b, mp_emit_common_use_const_obj(emit->emit_common, obj));
 }
 
-static void emit_write_bytecode_byte_child(emit_t *emit, int stack_adj, byte b, mp_raw_code_t *rc) {
+STATIC void emit_write_bytecode_byte_child(emit_t *emit, int stack_adj, byte b, mp_raw_code_t *rc) {
     emit_write_bytecode_byte_const(emit, stack_adj, b,
         mp_emit_common_alloc_const_child(emit->emit_common, rc));
     #if MICROPY_PY_SYS_SETTRACE
@@ -227,7 +227,7 @@ static void emit_write_bytecode_byte_child(emit_t *emit, int stack_adj, byte b,
 // The offset is encoded as either 1 or 2 bytes, depending on how big it is.
 // The encoding of this jump opcode can change size from one pass to the next,
 // but it must only ever decrease in size on successive passes.
-static void emit_write_bytecode_byte_label(emit_t *emit, int stack_adj, byte b1, mp_uint_t label) {
+STATIC void emit_write_bytecode_byte_label(emit_t *emit, int stack_adj, byte b1, mp_uint_t label) {
     mp_emit_bc_adjust_stack_size(emit, stack_adj);
 
     if (emit->suppress) {
@@ -393,18 +393,13 @@ bool mp_emit_bc_end_pass(emit_t *emit) {
             mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("bytecode overflow"));
         }
 
-        #if MICROPY_PERSISTENT_CODE_SAVE || MICROPY_DEBUG_PRINTERS
-        size_t bytecode_len = emit->code_info_size + emit->bytecode_size;
-        #if MICROPY_DEBUG_PRINTERS
-        emit->scope->raw_code_data_len = bytecode_len;
-        #endif
-        #endif
-
         // Bytecode is finalised, assign it to the raw code object.
         mp_emit_glue_assign_bytecode(emit->scope->raw_code, emit->code_base,
+            #if MICROPY_PERSISTENT_CODE_SAVE || MICROPY_DEBUG_PRINTERS
+            emit->code_info_size + emit->bytecode_size,
+            #endif
             emit->emit_common->children,
             #if MICROPY_PERSISTENT_CODE_SAVE
-            bytecode_len,
             emit->emit_common->ct_cur_child,
             #endif
             emit->scope->scope_flags);
@@ -448,6 +443,7 @@ void mp_emit_bc_label_assign(emit_t *emit, mp_uint_t l) {
     // should be emitted (until another unconditional flow control).
     emit->suppress = false;
 
+    mp_emit_bc_adjust_stack_size(emit, 0);
     if (emit->pass == MP_PASS_SCOPE) {
         return;
     }
@@ -768,7 +764,7 @@ void mp_emit_bc_make_closure(emit_t *emit, scope_t *scope, mp_uint_t n_closed_ov
     }
 }
 
-static void emit_bc_call_function_method_helper(emit_t *emit, int stack_adj, mp_uint_t bytecode_base, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags) {
+STATIC void emit_bc_call_function_method_helper(emit_t *emit, int stack_adj, mp_uint_t bytecode_base, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags) {
     if (star_flags) {
         // each positional arg is one object, each kwarg is two objects, the key
         // and the value and one extra object for the star args bitmap.

+ 31 - 47
py/emitglue.c

@@ -61,20 +61,24 @@ mp_raw_code_t *mp_emit_glue_new_raw_code(void) {
 }
 
 void mp_emit_glue_assign_bytecode(mp_raw_code_t *rc, const byte *code,
+    #if MICROPY_PERSISTENT_CODE_SAVE || MICROPY_DEBUG_PRINTERS
+    size_t len,
+    #endif
     mp_raw_code_t **children,
     #if MICROPY_PERSISTENT_CODE_SAVE
-    size_t len,
-    uint16_t n_children,
+    size_t n_children,
     #endif
-    uint16_t scope_flags) {
+    mp_uint_t scope_flags) {
 
     rc->kind = MP_CODE_BYTECODE;
-    rc->is_generator = (scope_flags & MP_SCOPE_FLAG_GENERATOR) != 0;
+    rc->scope_flags = scope_flags;
     rc->fun_data = code;
+    #if MICROPY_PERSISTENT_CODE_SAVE || MICROPY_DEBUG_PRINTERS
+    rc->fun_data_len = len;
+    #endif
     rc->children = children;
 
     #if MICROPY_PERSISTENT_CODE_SAVE
-    rc->fun_data_len = len;
     rc->n_children = n_children;
     #endif
 
@@ -84,7 +88,7 @@ void mp_emit_glue_assign_bytecode(mp_raw_code_t *rc, const byte *code,
     #endif
 
     #if DEBUG_PRINT
-    #if !MICROPY_PERSISTENT_CODE_SAVE
+    #if !(MICROPY_PERSISTENT_CODE_SAVE || MICROPY_DEBUG_PRINTERS)
     const size_t len = 0;
     #endif
     DEBUG_printf("assign byte code: code=%p len=" UINT_FMT " flags=%x\n", code, len, (uint)scope_flags);
@@ -92,14 +96,13 @@ void mp_emit_glue_assign_bytecode(mp_raw_code_t *rc, const byte *code,
 }
 
 #if MICROPY_EMIT_MACHINE_CODE
-void mp_emit_glue_assign_native(mp_raw_code_t *rc, mp_raw_code_kind_t kind, const void *fun_data, mp_uint_t fun_len,
+void mp_emit_glue_assign_native(mp_raw_code_t *rc, mp_raw_code_kind_t kind, void *fun_data, mp_uint_t fun_len,
     mp_raw_code_t **children,
     #if MICROPY_PERSISTENT_CODE_SAVE
-    uint16_t n_children,
+    size_t n_children,
     uint16_t prelude_offset,
     #endif
-    uint16_t scope_flags, uint32_t asm_n_pos_args, uint32_t asm_type_sig
-    ) {
+    mp_uint_t scope_flags, mp_uint_t n_pos_args, mp_uint_t type_sig) {
 
     assert(kind == MP_CODE_NATIVE_PY || kind == MP_CODE_NATIVE_VIPER || kind == MP_CODE_NATIVE_ASM);
 
@@ -115,7 +118,7 @@ void mp_emit_glue_assign_native(mp_raw_code_t *rc, mp_raw_code_kind_t kind, cons
     #endif
     #elif MICROPY_EMIT_ARM
     #if (defined(__linux__) && defined(__GNUC__)) || __ARM_ARCH == 7
-    __builtin___clear_cache((void *)fun_data, (uint8_t *)fun_data + fun_len);
+    __builtin___clear_cache(fun_data, (uint8_t *)fun_data + fun_len);
     #elif defined(__arm__)
     // Flush I-cache and D-cache.
     asm volatile (
@@ -129,10 +132,10 @@ void mp_emit_glue_assign_native(mp_raw_code_t *rc, mp_raw_code_kind_t kind, cons
     #endif
 
     rc->kind = kind;
-    rc->is_generator = (scope_flags & MP_SCOPE_FLAG_GENERATOR) != 0;
+    rc->scope_flags = scope_flags;
     rc->fun_data = fun_data;
 
-    #if MICROPY_PERSISTENT_CODE_SAVE
+    #if MICROPY_PERSISTENT_CODE_SAVE || MICROPY_DEBUG_PRINTERS
     rc->fun_data_len = fun_len;
     #endif
     rc->children = children;
@@ -142,19 +145,17 @@ void mp_emit_glue_assign_native(mp_raw_code_t *rc, mp_raw_code_kind_t kind, cons
     rc->prelude_offset = prelude_offset;
     #endif
 
-    #if MICROPY_EMIT_INLINE_ASM
     // These two entries are only needed for MP_CODE_NATIVE_ASM.
-    rc->asm_n_pos_args = asm_n_pos_args;
-    rc->asm_type_sig = asm_type_sig;
-    #endif
+    rc->n_pos_args = n_pos_args;
+    rc->type_sig = type_sig;
 
     #if DEBUG_PRINT
-    DEBUG_printf("assign native: kind=%d fun=%p len=" UINT_FMT " flags=%x\n", kind, fun_data, fun_len, (uint)scope_flags);
+    DEBUG_printf("assign native: kind=%d fun=%p len=" UINT_FMT " n_pos_args=" UINT_FMT " flags=%x\n", kind, fun_data, fun_len, n_pos_args, (uint)scope_flags);
     for (mp_uint_t i = 0; i < fun_len; i++) {
         if (i > 0 && i % 16 == 0) {
             DEBUG_printf("\n");
         }
-        DEBUG_printf(" %02x", ((const byte *)fun_data)[i]);
+        DEBUG_printf(" %02x", ((byte *)fun_data)[i]);
     }
     DEBUG_printf("\n");
 
@@ -169,9 +170,9 @@ void mp_emit_glue_assign_native(mp_raw_code_t *rc, mp_raw_code_kind_t kind, cons
 }
 #endif
 
-mp_obj_t mp_make_function_from_proto_fun(mp_proto_fun_t proto_fun, const mp_module_context_t *context, const mp_obj_t *def_args) {
-    DEBUG_OP_printf("make_function_from_proto_fun %p\n", proto_fun);
-    assert(proto_fun != NULL);
+mp_obj_t mp_make_function_from_raw_code(const mp_raw_code_t *rc, const mp_module_context_t *context, const mp_obj_t *def_args) {
+    DEBUG_OP_printf("make_function_from_raw_code %p\n", rc);
+    assert(rc != NULL);
 
     // def_args must be MP_OBJ_NULL or a tuple
     assert(def_args == NULL || def_args[0] == MP_OBJ_NULL || mp_obj_is_type(def_args[0], &mp_type_tuple));
@@ -179,39 +180,22 @@ mp_obj_t mp_make_function_from_proto_fun(mp_proto_fun_t proto_fun, const mp_modu
     // def_kw_args must be MP_OBJ_NULL or a dict
     assert(def_args == NULL || def_args[1] == MP_OBJ_NULL || mp_obj_is_type(def_args[1], &mp_type_dict));
 
-    #if MICROPY_MODULE_FROZEN_MPY
-    if (mp_proto_fun_is_bytecode(proto_fun)) {
-        const uint8_t *bc = proto_fun;
-        mp_obj_t fun = mp_obj_new_fun_bc(def_args, bc, context, NULL);
-        MP_BC_PRELUDE_SIG_DECODE(bc);
-        if (scope_flags & MP_SCOPE_FLAG_GENERATOR) {
-            ((mp_obj_base_t *)MP_OBJ_TO_PTR(fun))->type = &mp_type_gen_wrap;
-        }
-        return fun;
-    }
-    #endif
-
-    // the proto-function is a mp_raw_code_t
-    const mp_raw_code_t *rc = proto_fun;
-
     // make the function, depending on the raw code kind
     mp_obj_t fun;
     switch (rc->kind) {
         #if MICROPY_EMIT_NATIVE
         case MP_CODE_NATIVE_PY:
+        case MP_CODE_NATIVE_VIPER:
             fun = mp_obj_new_fun_native(def_args, rc->fun_data, context, rc->children);
             // Check for a generator function, and if so change the type of the object
-            if (rc->is_generator) {
+            if ((rc->scope_flags & MP_SCOPE_FLAG_GENERATOR) != 0) {
                 ((mp_obj_base_t *)MP_OBJ_TO_PTR(fun))->type = &mp_type_native_gen_wrap;
             }
             break;
-        case MP_CODE_NATIVE_VIPER:
-            fun = mp_obj_new_fun_viper(rc->fun_data, context, rc->children);
-            break;
         #endif
         #if MICROPY_EMIT_INLINE_ASM
         case MP_CODE_NATIVE_ASM:
-            fun = mp_obj_new_fun_asm(rc->asm_n_pos_args, rc->fun_data, rc->asm_type_sig);
+            fun = mp_obj_new_fun_asm(rc->n_pos_args, rc->fun_data, rc->type_sig);
             break;
         #endif
         default:
@@ -219,7 +203,7 @@ mp_obj_t mp_make_function_from_proto_fun(mp_proto_fun_t proto_fun, const mp_modu
             assert(rc->kind == MP_CODE_BYTECODE);
             fun = mp_obj_new_fun_bc(def_args, rc->fun_data, context, rc->children);
             // check for generator functions and if so change the type of the object
-            if (rc->is_generator) {
+            if ((rc->scope_flags & MP_SCOPE_FLAG_GENERATOR) != 0) {
                 ((mp_obj_base_t *)MP_OBJ_TO_PTR(fun))->type = &mp_type_gen_wrap;
             }
 
@@ -234,16 +218,16 @@ mp_obj_t mp_make_function_from_proto_fun(mp_proto_fun_t proto_fun, const mp_modu
     return fun;
 }
 
-mp_obj_t mp_make_closure_from_proto_fun(mp_proto_fun_t proto_fun, const mp_module_context_t *context, mp_uint_t n_closed_over, const mp_obj_t *args) {
-    DEBUG_OP_printf("make_closure_from_proto_fun %p " UINT_FMT " %p\n", proto_fun, n_closed_over, args);
+mp_obj_t mp_make_closure_from_raw_code(const mp_raw_code_t *rc, const mp_module_context_t *context, mp_uint_t n_closed_over, const mp_obj_t *args) {
+    DEBUG_OP_printf("make_closure_from_raw_code %p " UINT_FMT " %p\n", rc, n_closed_over, args);
     // make function object
     mp_obj_t ffun;
     if (n_closed_over & 0x100) {
         // default positional and keyword args given
-        ffun = mp_make_function_from_proto_fun(proto_fun, context, args);
+        ffun = mp_make_function_from_raw_code(rc, context, args);
     } else {
         // default positional and keyword args not given
-        ffun = mp_make_function_from_proto_fun(proto_fun, context, NULL);
+        ffun = mp_make_function_from_raw_code(rc, context, NULL);
     }
     // wrap function in closure object
     return mp_obj_new_closure(ffun, n_closed_over & 0xff, args + ((n_closed_over >> 7) & 2));

+ 22 - 60
py/emitglue.h

@@ -31,11 +31,6 @@
 
 // These variables and functions glue the code emitters to the runtime.
 
-// Used with mp_raw_code_t::proto_fun_indicator to detect if a mp_proto_fun_t is a
-// mp_raw_code_t struct or a direct pointer to bytecode.
-#define MP_PROTO_FUN_INDICATOR_RAW_CODE_0 (0)
-#define MP_PROTO_FUN_INDICATOR_RAW_CODE_1 (0)
-
 // These must fit in 8 bits; see scope.h
 enum {
     MP_EMIT_OPT_NONE,
@@ -54,91 +49,58 @@ typedef enum {
     MP_CODE_NATIVE_ASM,
 } mp_raw_code_kind_t;
 
-// An mp_proto_fun_t points to static information about a non-instantiated function.
-// A function object is created from this information, and that object can then be executed.
-// It points either to bytecode, or an mp_raw_code_t struct.
-typedef const void *mp_proto_fun_t;
-
-// Bytecode is distinguished from an mp_raw_code_t struct by the first two bytes: bytecode
-// is guaranteed to have either its first or second byte non-zero.  So if both bytes are
-// zero then the mp_proto_fun_t pointer must be an mp_raw_code_t.
-static inline bool mp_proto_fun_is_bytecode(mp_proto_fun_t proto_fun) {
-    const uint8_t *header = (const uint8_t *)proto_fun;
-    return (header[0] | (header[1] << 8)) != (MP_PROTO_FUN_INDICATOR_RAW_CODE_0 | (MP_PROTO_FUN_INDICATOR_RAW_CODE_1 << 8));
-}
-
-// The mp_raw_code_t struct appears in the following places:
 // compiled bytecode: instance in RAM, referenced by outer scope, usually freed after first (and only) use
 // mpy file: instance in RAM, created when .mpy file is loaded (same comments as above)
 // frozen: instance in ROM
 typedef struct _mp_raw_code_t {
-    uint8_t proto_fun_indicator[2];
-    uint8_t kind; // of type mp_raw_code_kind_t; only 3 bits used
-    bool is_generator;
+    mp_uint_t kind : 3; // of type mp_raw_code_kind_t
+    mp_uint_t scope_flags : 7;
+    mp_uint_t n_pos_args : 11;
     const void *fun_data;
+    #if MICROPY_PERSISTENT_CODE_SAVE || MICROPY_DEBUG_PRINTERS
+    size_t fun_data_len; // so mp_raw_code_save and mp_bytecode_print work
+    #endif
     struct _mp_raw_code_t **children;
     #if MICROPY_PERSISTENT_CODE_SAVE
-    uint32_t fun_data_len; // for mp_raw_code_save
-    uint16_t n_children;
-    #if MICROPY_EMIT_MACHINE_CODE
-    uint16_t prelude_offset;
-    #endif
+    size_t n_children;
     #if MICROPY_PY_SYS_SETTRACE
+    mp_bytecode_prelude_t prelude;
     // line_of_definition is a Python source line where the raw_code was
     // created e.g. MP_BC_MAKE_FUNCTION. This is different from lineno info
     // stored in prelude, which provides line number for first statement of
     // a function. Required to properly implement "call" trace event.
-    uint32_t line_of_definition;
-    mp_bytecode_prelude_t prelude;
+    mp_uint_t line_of_definition;
     #endif
-    #endif
-    #if MICROPY_EMIT_INLINE_ASM
-    uint32_t asm_n_pos_args : 8;
-    uint32_t asm_type_sig : 24; // compressed as 2-bit types; ret is MSB, then arg0, arg1, etc
-    #endif
-} mp_raw_code_t;
-
-// Version of mp_raw_code_t but without the asm_n_pos_args/asm_type_sig entries, which are
-// only needed when the kind is MP_CODE_NATIVE_ASM.  So this struct can be used when the
-// kind is MP_CODE_BYTECODE, MP_CODE_NATIVE_PY or MP_CODE_NATIVE_VIPER, to reduce its size.
-typedef struct _mp_raw_code_truncated_t {
-    uint8_t proto_fun_indicator[2];
-    uint8_t kind;
-    bool is_generator;
-    const void *fun_data;
-    struct _mp_raw_code_t **children;
-    #if MICROPY_PERSISTENT_CODE_SAVE
-    uint32_t fun_data_len;
-    uint16_t n_children;
     #if MICROPY_EMIT_MACHINE_CODE
     uint16_t prelude_offset;
     #endif
-    #if MICROPY_PY_SYS_SETTRACE
-    uint32_t line_of_definition;
-    mp_bytecode_prelude_t prelude;
     #endif
+    #if MICROPY_EMIT_MACHINE_CODE
+    mp_uint_t type_sig; // for viper, compressed as 2-bit types; ret is MSB, then arg0, arg1, etc
     #endif
-} mp_raw_code_truncated_t;
+} mp_raw_code_t;
 
 mp_raw_code_t *mp_emit_glue_new_raw_code(void);
 
 void mp_emit_glue_assign_bytecode(mp_raw_code_t *rc, const byte *code,
+    #if MICROPY_PERSISTENT_CODE_SAVE || MICROPY_DEBUG_PRINTERS
+    size_t len,
+    #endif
     mp_raw_code_t **children,
     #if MICROPY_PERSISTENT_CODE_SAVE
-    size_t len,
-    uint16_t n_children,
+    size_t n_children,
     #endif
-    uint16_t scope_flags);
+    mp_uint_t scope_flags);
 
-void mp_emit_glue_assign_native(mp_raw_code_t *rc, mp_raw_code_kind_t kind, const void *fun_data, mp_uint_t fun_len,
+void mp_emit_glue_assign_native(mp_raw_code_t *rc, mp_raw_code_kind_t kind, void *fun_data, mp_uint_t fun_len,
     mp_raw_code_t **children,
     #if MICROPY_PERSISTENT_CODE_SAVE
-    uint16_t n_children,
+    size_t n_children,
     uint16_t prelude_offset,
     #endif
-    uint16_t scope_flags, uint32_t asm_n_pos_args, uint32_t asm_type_sig);
+    mp_uint_t scope_flags, mp_uint_t n_pos_args, mp_uint_t type_sig);
 
-mp_obj_t mp_make_function_from_proto_fun(mp_proto_fun_t proto_fun, const mp_module_context_t *context, const mp_obj_t *def_args);
-mp_obj_t mp_make_closure_from_proto_fun(mp_proto_fun_t proto_fun, const mp_module_context_t *context, mp_uint_t n_closed_over, const mp_obj_t *args);
+mp_obj_t mp_make_function_from_raw_code(const mp_raw_code_t *rc, const mp_module_context_t *context, const mp_obj_t *def_args);
+mp_obj_t mp_make_closure_from_raw_code(const mp_raw_code_t *rc, const mp_module_context_t *context, mp_uint_t n_closed_over, const mp_obj_t *args);
 
 #endif // MICROPY_INCLUDED_PY_EMITGLUE_H

+ 21 - 21
py/emitinlinethumb.c

@@ -74,11 +74,11 @@ static inline bool emit_inline_thumb_allow_float(emit_inline_asm_t *emit) {
 
 #endif
 
-static void emit_inline_thumb_error_msg(emit_inline_asm_t *emit, mp_rom_error_text_t msg) {
+STATIC void emit_inline_thumb_error_msg(emit_inline_asm_t *emit, mp_rom_error_text_t msg) {
     *emit->error_slot = mp_obj_new_exception_msg(&mp_type_SyntaxError, msg);
 }
 
-static void emit_inline_thumb_error_exc(emit_inline_asm_t *emit, mp_obj_t exc) {
+STATIC void emit_inline_thumb_error_exc(emit_inline_asm_t *emit, mp_obj_t exc) {
     *emit->error_slot = exc;
 }
 
@@ -97,7 +97,7 @@ void emit_inline_thumb_free(emit_inline_asm_t *emit) {
     m_del_obj(emit_inline_asm_t, emit);
 }
 
-static void emit_inline_thumb_start_pass(emit_inline_asm_t *emit, pass_kind_t pass, mp_obj_t *error_slot) {
+STATIC void emit_inline_thumb_start_pass(emit_inline_asm_t *emit, pass_kind_t pass, mp_obj_t *error_slot) {
     emit->pass = pass;
     emit->error_slot = error_slot;
     if (emit->pass == MP_PASS_CODE_SIZE) {
@@ -107,12 +107,12 @@ static void emit_inline_thumb_start_pass(emit_inline_asm_t *emit, pass_kind_t pa
     asm_thumb_entry(&emit->as, 0);
 }
 
-static void emit_inline_thumb_end_pass(emit_inline_asm_t *emit, mp_uint_t type_sig) {
+STATIC void emit_inline_thumb_end_pass(emit_inline_asm_t *emit, mp_uint_t type_sig) {
     asm_thumb_exit(&emit->as);
     asm_thumb_end_pass(&emit->as);
 }
 
-static mp_uint_t emit_inline_thumb_count_params(emit_inline_asm_t *emit, mp_uint_t n_params, mp_parse_node_t *pn_params) {
+STATIC mp_uint_t emit_inline_thumb_count_params(emit_inline_asm_t *emit, mp_uint_t n_params, mp_parse_node_t *pn_params) {
     if (n_params > 4) {
         emit_inline_thumb_error_msg(emit, MP_ERROR_TEXT("can only have up to 4 parameters to Thumb assembly"));
         return 0;
@@ -131,7 +131,7 @@ static mp_uint_t emit_inline_thumb_count_params(emit_inline_asm_t *emit, mp_uint
     return n_params;
 }
 
-static bool emit_inline_thumb_label(emit_inline_asm_t *emit, mp_uint_t label_num, qstr label_id) {
+STATIC bool emit_inline_thumb_label(emit_inline_asm_t *emit, mp_uint_t label_num, qstr label_id) {
     assert(label_num < emit->max_num_labels);
     if (emit->pass == MP_PASS_CODE_SIZE) {
         // check for duplicate label on first pass
@@ -149,7 +149,7 @@ static bool emit_inline_thumb_label(emit_inline_asm_t *emit, mp_uint_t label_num
 typedef struct _reg_name_t { byte reg;
                              byte name[3];
 } reg_name_t;
-static const reg_name_t reg_name_table[] = {
+STATIC const reg_name_t reg_name_table[] = {
     {0, "r0\0"},
     {1, "r1\0"},
     {2, "r2\0"},
@@ -177,14 +177,14 @@ static const reg_name_t reg_name_table[] = {
 typedef struct _special_reg_name_t { byte reg;
                                      char name[MAX_SPECIAL_REGISTER_NAME_LENGTH + 1];
 } special_reg_name_t;
-static const special_reg_name_t special_reg_name_table[] = {
+STATIC const special_reg_name_t special_reg_name_table[] = {
     {5, "IPSR"},
     {17, "BASEPRI"},
 };
 
 // return empty string in case of error, so we can attempt to parse the string
 // without a special check if it was in fact a string
-static const char *get_arg_str(mp_parse_node_t pn) {
+STATIC const char *get_arg_str(mp_parse_node_t pn) {
     if (MP_PARSE_NODE_IS_ID(pn)) {
         qstr qst = MP_PARSE_NODE_LEAF_ARG(pn);
         return qstr_str(qst);
@@ -193,7 +193,7 @@ static const char *get_arg_str(mp_parse_node_t pn) {
     }
 }
 
-static mp_uint_t get_arg_reg(emit_inline_asm_t *emit, const char *op, mp_parse_node_t pn, mp_uint_t max_reg) {
+STATIC mp_uint_t get_arg_reg(emit_inline_asm_t *emit, const char *op, mp_parse_node_t pn, mp_uint_t max_reg) {
     const char *reg_str = get_arg_str(pn);
     for (mp_uint_t i = 0; i < MP_ARRAY_SIZE(reg_name_table); i++) {
         const reg_name_t *r = &reg_name_table[i];
@@ -217,7 +217,7 @@ static mp_uint_t get_arg_reg(emit_inline_asm_t *emit, const char *op, mp_parse_n
     return 0;
 }
 
-static mp_uint_t get_arg_special_reg(emit_inline_asm_t *emit, const char *op, mp_parse_node_t pn) {
+STATIC mp_uint_t get_arg_special_reg(emit_inline_asm_t *emit, const char *op, mp_parse_node_t pn) {
     const char *reg_str = get_arg_str(pn);
     for (mp_uint_t i = 0; i < MP_ARRAY_SIZE(special_reg_name_table); i++) {
         const special_reg_name_t *r = &special_reg_name_table[i];
@@ -231,7 +231,7 @@ static mp_uint_t get_arg_special_reg(emit_inline_asm_t *emit, const char *op, mp
     return 0;
 }
 
-static mp_uint_t get_arg_vfpreg(emit_inline_asm_t *emit, const char *op, mp_parse_node_t pn) {
+STATIC mp_uint_t get_arg_vfpreg(emit_inline_asm_t *emit, const char *op, mp_parse_node_t pn) {
     const char *reg_str = get_arg_str(pn);
     if (reg_str[0] == 's' && reg_str[1] != '\0') {
         mp_uint_t regno = 0;
@@ -258,7 +258,7 @@ malformed:
     return 0;
 }
 
-static mp_uint_t get_arg_reglist(emit_inline_asm_t *emit, const char *op, mp_parse_node_t pn) {
+STATIC mp_uint_t get_arg_reglist(emit_inline_asm_t *emit, const char *op, mp_parse_node_t pn) {
     // a register list looks like {r0, r1, r2} and is parsed as a Python set
 
     if (!MP_PARSE_NODE_IS_STRUCT_KIND(pn, PN_atom_brace)) {
@@ -310,7 +310,7 @@ bad_arg:
     return 0;
 }
 
-static uint32_t get_arg_i(emit_inline_asm_t *emit, const char *op, mp_parse_node_t pn, uint32_t fit_mask) {
+STATIC uint32_t get_arg_i(emit_inline_asm_t *emit, const char *op, mp_parse_node_t pn, uint32_t fit_mask) {
     mp_obj_t o;
     if (!mp_parse_node_get_int_maybe(pn, &o)) {
         emit_inline_thumb_error_exc(emit, mp_obj_new_exception_msg_varg(&mp_type_SyntaxError, MP_ERROR_TEXT("'%s' expects an integer"), op));
@@ -324,7 +324,7 @@ static uint32_t get_arg_i(emit_inline_asm_t *emit, const char *op, mp_parse_node
     return i;
 }
 
-static bool get_arg_addr(emit_inline_asm_t *emit, const char *op, mp_parse_node_t pn, mp_parse_node_t *pn_base, mp_parse_node_t *pn_offset) {
+STATIC bool get_arg_addr(emit_inline_asm_t *emit, const char *op, mp_parse_node_t pn, mp_parse_node_t *pn_base, mp_parse_node_t *pn_offset) {
     if (!MP_PARSE_NODE_IS_STRUCT_KIND(pn, PN_atom_bracket)) {
         goto bad_arg;
     }
@@ -346,7 +346,7 @@ bad_arg:
     return false;
 }
 
-static int get_arg_label(emit_inline_asm_t *emit, const char *op, mp_parse_node_t pn) {
+STATIC int get_arg_label(emit_inline_asm_t *emit, const char *op, mp_parse_node_t pn) {
     if (!MP_PARSE_NODE_IS_ID(pn)) {
         emit_inline_thumb_error_exc(emit, mp_obj_new_exception_msg_varg(&mp_type_SyntaxError, MP_ERROR_TEXT("'%s' expects a label"), op));
         return 0;
@@ -367,7 +367,7 @@ static int get_arg_label(emit_inline_asm_t *emit, const char *op, mp_parse_node_
 typedef struct _cc_name_t { byte cc;
                             byte name[2];
 } cc_name_t;
-static const cc_name_t cc_name_table[] = {
+STATIC const cc_name_t cc_name_table[] = {
     { ASM_THUMB_CC_EQ, "eq" },
     { ASM_THUMB_CC_NE, "ne" },
     { ASM_THUMB_CC_CS, "cs" },
@@ -388,7 +388,7 @@ typedef struct _format_4_op_t { byte op;
                                 char name[3];
 } format_4_op_t;
 #define X(x) (((x) >> 4) & 0xff) // only need 1 byte to distinguish these ops
-static const format_4_op_t format_4_op_table[] = {
+STATIC const format_4_op_t format_4_op_table[] = {
     { X(ASM_THUMB_FORMAT_4_EOR), "eor" },
     { X(ASM_THUMB_FORMAT_4_LSL), "lsl" },
     { X(ASM_THUMB_FORMAT_4_LSR), "lsr" },
@@ -412,7 +412,7 @@ typedef struct _format_9_10_op_t { uint16_t op;
                                    uint16_t name;
 } format_9_10_op_t;
 #define X(x) (x)
-static const format_9_10_op_t format_9_10_op_table[] = {
+STATIC const format_9_10_op_t format_9_10_op_table[] = {
     { X(ASM_THUMB_FORMAT_9_LDR | ASM_THUMB_FORMAT_9_WORD_TRANSFER), MP_QSTR_ldr },
     { X(ASM_THUMB_FORMAT_9_LDR | ASM_THUMB_FORMAT_9_BYTE_TRANSFER), MP_QSTR_ldrb },
     { X(ASM_THUMB_FORMAT_10_LDRH), MP_QSTR_ldrh },
@@ -427,7 +427,7 @@ typedef struct _format_vfp_op_t {
     byte op;
     char name[3];
 } format_vfp_op_t;
-static const format_vfp_op_t format_vfp_op_table[] = {
+STATIC const format_vfp_op_t format_vfp_op_table[] = {
     { 0x30, "add" },
     { 0x34, "sub" },
     { 0x20, "mul" },
@@ -437,7 +437,7 @@ static const format_vfp_op_t format_vfp_op_table[] = {
 // shorthand alias for whether we allow ARMv7-M instructions
 #define ARMV7M asm_thumb_allow_armv7m(&emit->as)
 
-static void emit_inline_thumb_op(emit_inline_asm_t *emit, qstr op, mp_uint_t n_args, mp_parse_node_t *pn_args) {
+STATIC void emit_inline_thumb_op(emit_inline_asm_t *emit, qstr op, mp_uint_t n_args, mp_parse_node_t *pn_args) {
     // TODO perhaps make two tables:
     // one_args =
     // "b", LAB, asm_thumb_b_n,

+ 13 - 13
py/emitinlinextensa.c

@@ -43,11 +43,11 @@ struct _emit_inline_asm_t {
     qstr *label_lookup;
 };
 
-static void emit_inline_xtensa_error_msg(emit_inline_asm_t *emit, mp_rom_error_text_t msg) {
+STATIC void emit_inline_xtensa_error_msg(emit_inline_asm_t *emit, mp_rom_error_text_t msg) {
     *emit->error_slot = mp_obj_new_exception_msg(&mp_type_SyntaxError, msg);
 }
 
-static void emit_inline_xtensa_error_exc(emit_inline_asm_t *emit, mp_obj_t exc) {
+STATIC void emit_inline_xtensa_error_exc(emit_inline_asm_t *emit, mp_obj_t exc) {
     *emit->error_slot = exc;
 }
 
@@ -66,7 +66,7 @@ void emit_inline_xtensa_free(emit_inline_asm_t *emit) {
     m_del_obj(emit_inline_asm_t, emit);
 }
 
-static void emit_inline_xtensa_start_pass(emit_inline_asm_t *emit, pass_kind_t pass, mp_obj_t *error_slot) {
+STATIC void emit_inline_xtensa_start_pass(emit_inline_asm_t *emit, pass_kind_t pass, mp_obj_t *error_slot) {
     emit->pass = pass;
     emit->error_slot = error_slot;
     if (emit->pass == MP_PASS_CODE_SIZE) {
@@ -76,12 +76,12 @@ static void emit_inline_xtensa_start_pass(emit_inline_asm_t *emit, pass_kind_t p
     asm_xtensa_entry(&emit->as, 0);
 }
 
-static void emit_inline_xtensa_end_pass(emit_inline_asm_t *emit, mp_uint_t type_sig) {
+STATIC void emit_inline_xtensa_end_pass(emit_inline_asm_t *emit, mp_uint_t type_sig) {
     asm_xtensa_exit(&emit->as);
     asm_xtensa_end_pass(&emit->as);
 }
 
-static mp_uint_t emit_inline_xtensa_count_params(emit_inline_asm_t *emit, mp_uint_t n_params, mp_parse_node_t *pn_params) {
+STATIC mp_uint_t emit_inline_xtensa_count_params(emit_inline_asm_t *emit, mp_uint_t n_params, mp_parse_node_t *pn_params) {
     if (n_params > 4) {
         emit_inline_xtensa_error_msg(emit, MP_ERROR_TEXT("can only have up to 4 parameters to Xtensa assembly"));
         return 0;
@@ -100,7 +100,7 @@ static mp_uint_t emit_inline_xtensa_count_params(emit_inline_asm_t *emit, mp_uin
     return n_params;
 }
 
-static bool emit_inline_xtensa_label(emit_inline_asm_t *emit, mp_uint_t label_num, qstr label_id) {
+STATIC bool emit_inline_xtensa_label(emit_inline_asm_t *emit, mp_uint_t label_num, qstr label_id) {
     assert(label_num < emit->max_num_labels);
     if (emit->pass == MP_PASS_CODE_SIZE) {
         // check for duplicate label on first pass
@@ -118,7 +118,7 @@ static bool emit_inline_xtensa_label(emit_inline_asm_t *emit, mp_uint_t label_nu
 typedef struct _reg_name_t { byte reg;
                              byte name[3];
 } reg_name_t;
-static const reg_name_t reg_name_table[] = {
+STATIC const reg_name_t reg_name_table[] = {
     {0, "a0\0"},
     {1, "a1\0"},
     {2, "a2\0"},
@@ -139,7 +139,7 @@ static const reg_name_t reg_name_table[] = {
 
 // return empty string in case of error, so we can attempt to parse the string
 // without a special check if it was in fact a string
-static const char *get_arg_str(mp_parse_node_t pn) {
+STATIC const char *get_arg_str(mp_parse_node_t pn) {
     if (MP_PARSE_NODE_IS_ID(pn)) {
         qstr qst = MP_PARSE_NODE_LEAF_ARG(pn);
         return qstr_str(qst);
@@ -148,7 +148,7 @@ static const char *get_arg_str(mp_parse_node_t pn) {
     }
 }
 
-static mp_uint_t get_arg_reg(emit_inline_asm_t *emit, const char *op, mp_parse_node_t pn) {
+STATIC mp_uint_t get_arg_reg(emit_inline_asm_t *emit, const char *op, mp_parse_node_t pn) {
     const char *reg_str = get_arg_str(pn);
     for (mp_uint_t i = 0; i < MP_ARRAY_SIZE(reg_name_table); i++) {
         const reg_name_t *r = &reg_name_table[i];
@@ -165,7 +165,7 @@ static mp_uint_t get_arg_reg(emit_inline_asm_t *emit, const char *op, mp_parse_n
     return 0;
 }
 
-static uint32_t get_arg_i(emit_inline_asm_t *emit, const char *op, mp_parse_node_t pn, int min, int max) {
+STATIC uint32_t get_arg_i(emit_inline_asm_t *emit, const char *op, mp_parse_node_t pn, int min, int max) {
     mp_obj_t o;
     if (!mp_parse_node_get_int_maybe(pn, &o)) {
         emit_inline_xtensa_error_exc(emit, mp_obj_new_exception_msg_varg(&mp_type_SyntaxError, MP_ERROR_TEXT("'%s' expects an integer"), op));
@@ -179,7 +179,7 @@ static uint32_t get_arg_i(emit_inline_asm_t *emit, const char *op, mp_parse_node
     return i;
 }
 
-static int get_arg_label(emit_inline_asm_t *emit, const char *op, mp_parse_node_t pn) {
+STATIC int get_arg_label(emit_inline_asm_t *emit, const char *op, mp_parse_node_t pn) {
     if (!MP_PARSE_NODE_IS_ID(pn)) {
         emit_inline_xtensa_error_exc(emit, mp_obj_new_exception_msg_varg(&mp_type_SyntaxError, MP_ERROR_TEXT("'%s' expects a label"), op));
         return 0;
@@ -208,7 +208,7 @@ typedef struct _opcode_table_3arg_t {
     uint8_t a1 : 4;
 } opcode_table_3arg_t;
 
-static const opcode_table_3arg_t opcode_table_3arg[] = {
+STATIC const opcode_table_3arg_t opcode_table_3arg[] = {
     // arithmetic opcodes: reg, reg, reg
     {MP_QSTR_and_, RRR, 0, 1},
     {MP_QSTR_or_, RRR, 0, 2},
@@ -242,7 +242,7 @@ static const opcode_table_3arg_t opcode_table_3arg[] = {
     {MP_QSTR_bnone, RRI8_B, ASM_XTENSA_CC_NONE, 0},
 };
 
-static void emit_inline_xtensa_op(emit_inline_asm_t *emit, qstr op, mp_uint_t n_args, mp_parse_node_t *pn_args) {
+STATIC void emit_inline_xtensa_op(emit_inline_asm_t *emit, qstr op, mp_uint_t n_args, mp_parse_node_t *pn_args) {
     size_t op_len;
     const char *op_str = (const char *)qstr_data(op, &op_len);
 

Разница между файлами не показана из-за своего большого размера
+ 131 - 147
py/emitnative.c


+ 2 - 2
py/emitnx86.c

@@ -13,7 +13,7 @@
 #define NLR_BUF_IDX_LOCAL_1 (5) // ebx
 
 // x86 needs a table to know how many args a given function has
-static byte mp_f_n_args[MP_F_NUMBER_OF] = {
+STATIC byte mp_f_n_args[MP_F_NUMBER_OF] = {
     [MP_F_CONVERT_OBJ_TO_NATIVE] = 2,
     [MP_F_CONVERT_NATIVE_TO_OBJ] = 2,
     [MP_F_NATIVE_SWAP_GLOBALS] = 1,
@@ -37,7 +37,7 @@ static byte mp_f_n_args[MP_F_NUMBER_OF] = {
     [MP_F_STORE_SET] = 2,
     [MP_F_LIST_APPEND] = 2,
     [MP_F_STORE_MAP] = 3,
-    [MP_F_MAKE_FUNCTION_FROM_PROTO_FUN] = 3,
+    [MP_F_MAKE_FUNCTION_FROM_RAW_CODE] = 3,
     [MP_F_NATIVE_CALL_FUNCTION_N_KW] = 3,
     [MP_F_CALL_METHOD_N_KW] = 3,
     [MP_F_CALL_METHOD_N_KW_VAR] = 3,

+ 7 - 7
py/gc.c

@@ -121,7 +121,7 @@
 #endif
 
 // TODO waste less memory; currently requires that all entries in alloc_table have a corresponding block in pool
-static void gc_setup_area(mp_state_mem_area_t *area, void *start, void *end) {
+STATIC void gc_setup_area(mp_state_mem_area_t *area, void *start, void *end) {
     // calculate parameters for GC (T=total, A=alloc table, F=finaliser table, P=pool; all in bytes):
     // T = A + F + P
     //     F = A * BLOCKS_PER_ATB / BLOCKS_PER_FTB
@@ -239,7 +239,7 @@ void gc_add(void *start, void *end) {
 
 #if MICROPY_GC_SPLIT_HEAP_AUTO
 // Try to automatically add a heap area large enough to fulfill 'failed_alloc'.
-static bool gc_try_add_heap(size_t failed_alloc) {
+STATIC bool gc_try_add_heap(size_t failed_alloc) {
     // 'needed' is the size of a heap large enough to hold failed_alloc, with
     // the additional metadata overheads as calculated in gc_setup_area().
     //
@@ -349,7 +349,7 @@ bool gc_is_locked(void) {
 #if MICROPY_GC_SPLIT_HEAP
 // Returns the area to which this pointer belongs, or NULL if it isn't
 // allocated on the GC-managed heap.
-static inline mp_state_mem_area_t *gc_get_ptr_area(const void *ptr) {
+STATIC inline mp_state_mem_area_t *gc_get_ptr_area(const void *ptr) {
     if (((uintptr_t)(ptr) & (BYTES_PER_BLOCK - 1)) != 0) {   // must be aligned on a block
         return NULL;
     }
@@ -383,9 +383,9 @@ static inline mp_state_mem_area_t *gc_get_ptr_area(const void *ptr) {
 // blocks on the stack. When all children have been checked, pop off the
 // topmost block on the stack and repeat with that one.
 #if MICROPY_GC_SPLIT_HEAP
-static void gc_mark_subtree(mp_state_mem_area_t *area, size_t block)
+STATIC void gc_mark_subtree(mp_state_mem_area_t *area, size_t block)
 #else
-static void gc_mark_subtree(size_t block)
+STATIC void gc_mark_subtree(size_t block)
 #endif
 {
     // Start with the block passed in the argument.
@@ -456,7 +456,7 @@ static void gc_mark_subtree(size_t block)
     }
 }
 
-static void gc_deal_with_stack_overflow(void) {
+STATIC void gc_deal_with_stack_overflow(void) {
     while (MP_STATE_MEM(gc_stack_overflow)) {
         MP_STATE_MEM(gc_stack_overflow) = 0;
 
@@ -477,7 +477,7 @@ static void gc_deal_with_stack_overflow(void) {
     }
 }
 
-static void gc_sweep(void) {
+STATIC void gc_sweep(void) {
     #if MICROPY_PY_GC_COLLECT_RETVAL
     MP_STATE_MEM(gc_collected) = 0;
     #endif

+ 29 - 29
py/lexer.c

@@ -42,74 +42,74 @@
 #define MP_LEXER_EOF ((unichar)MP_READER_EOF)
 #define CUR_CHAR(lex) ((lex)->chr0)
 
-static bool is_end(mp_lexer_t *lex) {
+STATIC bool is_end(mp_lexer_t *lex) {
     return lex->chr0 == MP_LEXER_EOF;
 }
 
-static bool is_physical_newline(mp_lexer_t *lex) {
+STATIC bool is_physical_newline(mp_lexer_t *lex) {
     return lex->chr0 == '\n';
 }
 
-static bool is_char(mp_lexer_t *lex, byte c) {
+STATIC bool is_char(mp_lexer_t *lex, byte c) {
     return lex->chr0 == c;
 }
 
-static bool is_char_or(mp_lexer_t *lex, byte c1, byte c2) {
+STATIC bool is_char_or(mp_lexer_t *lex, byte c1, byte c2) {
     return lex->chr0 == c1 || lex->chr0 == c2;
 }
 
-static bool is_char_or3(mp_lexer_t *lex, byte c1, byte c2, byte c3) {
+STATIC bool is_char_or3(mp_lexer_t *lex, byte c1, byte c2, byte c3) {
     return lex->chr0 == c1 || lex->chr0 == c2 || lex->chr0 == c3;
 }
 
 #if MICROPY_PY_FSTRINGS
-static bool is_char_or4(mp_lexer_t *lex, byte c1, byte c2, byte c3, byte c4) {
+STATIC bool is_char_or4(mp_lexer_t *lex, byte c1, byte c2, byte c3, byte c4) {
     return lex->chr0 == c1 || lex->chr0 == c2 || lex->chr0 == c3 || lex->chr0 == c4;
 }
 #endif
 
-static bool is_char_following(mp_lexer_t *lex, byte c) {
+STATIC bool is_char_following(mp_lexer_t *lex, byte c) {
     return lex->chr1 == c;
 }
 
-static bool is_char_following_or(mp_lexer_t *lex, byte c1, byte c2) {
+STATIC bool is_char_following_or(mp_lexer_t *lex, byte c1, byte c2) {
     return lex->chr1 == c1 || lex->chr1 == c2;
 }
 
-static bool is_char_following_following_or(mp_lexer_t *lex, byte c1, byte c2) {
+STATIC bool is_char_following_following_or(mp_lexer_t *lex, byte c1, byte c2) {
     return lex->chr2 == c1 || lex->chr2 == c2;
 }
 
-static bool is_char_and(mp_lexer_t *lex, byte c1, byte c2) {
+STATIC bool is_char_and(mp_lexer_t *lex, byte c1, byte c2) {
     return lex->chr0 == c1 && lex->chr1 == c2;
 }
 
-static bool is_whitespace(mp_lexer_t *lex) {
+STATIC bool is_whitespace(mp_lexer_t *lex) {
     return unichar_isspace(lex->chr0);
 }
 
-static bool is_letter(mp_lexer_t *lex) {
+STATIC bool is_letter(mp_lexer_t *lex) {
     return unichar_isalpha(lex->chr0);
 }
 
-static bool is_digit(mp_lexer_t *lex) {
+STATIC bool is_digit(mp_lexer_t *lex) {
     return unichar_isdigit(lex->chr0);
 }
 
-static bool is_following_digit(mp_lexer_t *lex) {
+STATIC bool is_following_digit(mp_lexer_t *lex) {
     return unichar_isdigit(lex->chr1);
 }
 
-static bool is_following_base_char(mp_lexer_t *lex) {
+STATIC bool is_following_base_char(mp_lexer_t *lex) {
     const unichar chr1 = lex->chr1 | 0x20;
     return chr1 == 'b' || chr1 == 'o' || chr1 == 'x';
 }
 
-static bool is_following_odigit(mp_lexer_t *lex) {
+STATIC bool is_following_odigit(mp_lexer_t *lex) {
     return lex->chr1 >= '0' && lex->chr1 <= '7';
 }
 
-static bool is_string_or_bytes(mp_lexer_t *lex) {
+STATIC bool is_string_or_bytes(mp_lexer_t *lex) {
     return is_char_or(lex, '\'', '\"')
            #if MICROPY_PY_FSTRINGS
            || (is_char_or4(lex, 'r', 'u', 'b', 'f') && is_char_following_or(lex, '\'', '\"'))
@@ -123,15 +123,15 @@ static bool is_string_or_bytes(mp_lexer_t *lex) {
 }
 
 // to easily parse utf-8 identifiers we allow any raw byte with high bit set
-static bool is_head_of_identifier(mp_lexer_t *lex) {
+STATIC bool is_head_of_identifier(mp_lexer_t *lex) {
     return is_letter(lex) || lex->chr0 == '_' || lex->chr0 >= 0x80;
 }
 
-static bool is_tail_of_identifier(mp_lexer_t *lex) {
+STATIC bool is_tail_of_identifier(mp_lexer_t *lex) {
     return is_head_of_identifier(lex) || is_digit(lex);
 }
 
-static void next_char(mp_lexer_t *lex) {
+STATIC void next_char(mp_lexer_t *lex) {
     if (lex->chr0 == '\n') {
         // a new line
         ++lex->line;
@@ -189,7 +189,7 @@ static void next_char(mp_lexer_t *lex) {
     }
 }
 
-static void indent_push(mp_lexer_t *lex, size_t indent) {
+STATIC void indent_push(mp_lexer_t *lex, size_t indent) {
     if (lex->num_indent_level >= lex->alloc_indent_level) {
         lex->indent_level = m_renew(uint16_t, lex->indent_level, lex->alloc_indent_level, lex->alloc_indent_level + MICROPY_ALLOC_LEXEL_INDENT_INC);
         lex->alloc_indent_level += MICROPY_ALLOC_LEXEL_INDENT_INC;
@@ -197,11 +197,11 @@ static void indent_push(mp_lexer_t *lex, size_t indent) {
     lex->indent_level[lex->num_indent_level++] = indent;
 }
 
-static size_t indent_top(mp_lexer_t *lex) {
+STATIC size_t indent_top(mp_lexer_t *lex) {
     return lex->indent_level[lex->num_indent_level - 1];
 }
 
-static void indent_pop(mp_lexer_t *lex) {
+STATIC void indent_pop(mp_lexer_t *lex) {
     lex->num_indent_level -= 1;
 }
 
@@ -211,7 +211,7 @@ static void indent_pop(mp_lexer_t *lex) {
 //     c<op> = continue with <op>, if this opchar matches then continue matching
 // this means if the start of two ops are the same then they are equal til the last char
 
-static const char *const tok_enc =
+STATIC const char *const tok_enc =
     "()[]{},;~"   // singles
     ":e="         // : :=
     "<e=c<e="     // < <= << <<=
@@ -229,7 +229,7 @@ static const char *const tok_enc =
     "!.";         // start of special cases: != . ...
 
 // TODO static assert that number of tokens is less than 256 so we can safely make this table with byte sized entries
-static const uint8_t tok_enc_kind[] = {
+STATIC const uint8_t tok_enc_kind[] = {
     MP_TOKEN_DEL_PAREN_OPEN, MP_TOKEN_DEL_PAREN_CLOSE,
     MP_TOKEN_DEL_BRACKET_OPEN, MP_TOKEN_DEL_BRACKET_CLOSE,
     MP_TOKEN_DEL_BRACE_OPEN, MP_TOKEN_DEL_BRACE_CLOSE,
@@ -252,7 +252,7 @@ static const uint8_t tok_enc_kind[] = {
 
 // must have the same order as enum in lexer.h
 // must be sorted according to strcmp
-static const char *const tok_kw[] = {
+STATIC const char *const tok_kw[] = {
     "False",
     "None",
     "True",
@@ -296,7 +296,7 @@ static const char *const tok_kw[] = {
 // This is called with CUR_CHAR() before first hex digit, and should return with
 // it pointing to last hex digit
 // num_digits must be greater than zero
-static bool get_hex(mp_lexer_t *lex, size_t num_digits, mp_uint_t *result) {
+STATIC bool get_hex(mp_lexer_t *lex, size_t num_digits, mp_uint_t *result) {
     mp_uint_t num = 0;
     while (num_digits-- != 0) {
         next_char(lex);
@@ -310,7 +310,7 @@ static bool get_hex(mp_lexer_t *lex, size_t num_digits, mp_uint_t *result) {
     return true;
 }
 
-static void parse_string_literal(mp_lexer_t *lex, bool is_raw, bool is_fstring) {
+STATIC void parse_string_literal(mp_lexer_t *lex, bool is_raw, bool is_fstring) {
     // get first quoting character
     char quote_char = '\'';
     if (is_char(lex, '\"')) {
@@ -529,7 +529,7 @@ static void parse_string_literal(mp_lexer_t *lex, bool is_raw, bool is_fstring)
 
 // This function returns whether it has crossed a newline or not.
 // It therefore always return true if stop_at_newline is true
-static bool skip_whitespace(mp_lexer_t *lex, bool stop_at_newline) {
+STATIC bool skip_whitespace(mp_lexer_t *lex, bool stop_at_newline) {
     while (!is_end(lex)) {
         if (is_physical_newline(lex)) {
             if (stop_at_newline && lex->nested_bracket_level == 0) {

+ 2 - 2
py/malloc.c

@@ -69,7 +69,7 @@
 #error MICROPY_ENABLE_FINALISER requires MICROPY_ENABLE_GC
 #endif
 
-static void *realloc_ext(void *ptr, size_t n_bytes, bool allow_move) {
+STATIC void *realloc_ext(void *ptr, size_t n_bytes, bool allow_move) {
     if (allow_move) {
         return realloc(ptr, n_bytes);
     } else {
@@ -221,7 +221,7 @@ typedef struct _m_tracked_node_t {
 } m_tracked_node_t;
 
 #if MICROPY_DEBUG_VERBOSE
-static size_t m_tracked_count_links(size_t *nb) {
+STATIC size_t m_tracked_count_links(size_t *nb) {
     m_tracked_node_t *node = MP_STATE_VM(m_tracked_head);
     size_t n = 0;
     *nb = 0;

+ 4 - 4
py/map.c

@@ -65,14 +65,14 @@
 // The first set of sizes are chosen so the allocation fits exactly in a
 // 4-word GC block, and it's not so important for these small values to be
 // prime.  The latter sizes are prime and increase at an increasing rate.
-static const uint16_t hash_allocation_sizes[] = {
+STATIC const uint16_t hash_allocation_sizes[] = {
     0, 2, 4, 6, 8, 10, 12, // +2
     17, 23, 29, 37, 47, 59, 73, // *1.25
     97, 127, 167, 223, 293, 389, 521, 691, 919, 1223, 1627, 2161, // *1.33
     3229, 4831, 7243, 10861, 16273, 24407, 36607, 54907, // *1.5
 };
 
-static size_t get_hash_alloc_greater_or_equal_to(size_t x) {
+STATIC size_t get_hash_alloc_greater_or_equal_to(size_t x) {
     for (size_t i = 0; i < MP_ARRAY_SIZE(hash_allocation_sizes); i++) {
         if (hash_allocation_sizes[i] >= x) {
             return hash_allocation_sizes[i];
@@ -128,7 +128,7 @@ void mp_map_clear(mp_map_t *map) {
     map->table = NULL;
 }
 
-static void mp_map_rehash(mp_map_t *map) {
+STATIC void mp_map_rehash(mp_map_t *map) {
     size_t old_alloc = map->alloc;
     size_t new_alloc = get_hash_alloc_greater_or_equal_to(map->alloc + 1);
     DEBUG_printf("mp_map_rehash(%p): " UINT_FMT " -> " UINT_FMT "\n", map, old_alloc, new_alloc);
@@ -332,7 +332,7 @@ void mp_set_init(mp_set_t *set, size_t n) {
     set->table = m_new0(mp_obj_t, set->alloc);
 }
 
-static void mp_set_rehash(mp_set_t *set) {
+STATIC void mp_set_rehash(mp_set_t *set) {
     size_t old_alloc = set->alloc;
     mp_obj_t *old_table = set->table;
     set->alloc = get_hash_alloc_greater_or_equal_to(set->alloc + 1);

+ 7 - 0
py/misc.h

@@ -79,6 +79,13 @@ typedef unsigned int uint;
 #define m_new_obj_var(obj_type, var_field, var_type, var_num) ((obj_type *)m_malloc(offsetof(obj_type, var_field) + sizeof(var_type) * (var_num)))
 #define m_new_obj_var0(obj_type, var_field, var_type, var_num) ((obj_type *)m_malloc0(offsetof(obj_type, var_field) + sizeof(var_type) * (var_num)))
 #define m_new_obj_var_maybe(obj_type, var_field, var_type, var_num) ((obj_type *)m_malloc_maybe(offsetof(obj_type, var_field) + sizeof(var_type) * (var_num)))
+#if MICROPY_ENABLE_FINALISER
+#define m_new_obj_with_finaliser(type) ((type *)(m_malloc_with_finaliser(sizeof(type))))
+#define m_new_obj_var_with_finaliser(type, var_field, var_type, var_num) ((type *)m_malloc_with_finaliser(offsetof(type, var_field) + sizeof(var_type) * (var_num)))
+#else
+#define m_new_obj_with_finaliser(type) m_new_obj(type)
+#define m_new_obj_var_with_finaliser(type, var_field, var_type, var_num) m_new_obj_var(type, var_field, var_type, var_num)
+#endif
 #if MICROPY_MALLOC_USES_ALLOCATED_SIZE
 #define m_renew(type, ptr, old_num, new_num) ((type *)(m_realloc((ptr), sizeof(type) * (old_num), sizeof(type) * (new_num))))
 #define m_renew_maybe(type, ptr, old_num, new_num, allow_move) ((type *)(m_realloc_maybe((ptr), sizeof(type) * (old_num), sizeof(type) * (new_num), (allow_move))))

+ 2 - 2
py/modarray.c

@@ -28,12 +28,12 @@
 
 #if MICROPY_PY_ARRAY
 
-static const mp_rom_map_elem_t mp_module_array_globals_table[] = {
+STATIC const mp_rom_map_elem_t mp_module_array_globals_table[] = {
     { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_array) },
     { MP_ROM_QSTR(MP_QSTR_array), MP_ROM_PTR(&mp_type_array) },
 };
 
-static MP_DEFINE_CONST_DICT(mp_module_array_globals, mp_module_array_globals_table);
+STATIC MP_DEFINE_CONST_DICT(mp_module_array_globals, mp_module_array_globals_table);
 
 const mp_obj_module_t mp_module_array = {
     .base = { &mp_type_module },

+ 34 - 34
py/modbuiltins.c

@@ -46,7 +46,7 @@ extern struct _mp_dummy_t mp_sys_stdout_obj; // type is irrelevant, just need po
 // args[0] is function from class body
 // args[1] is class name
 // args[2:] are base objects
-static mp_obj_t mp_builtin___build_class__(size_t n_args, const mp_obj_t *args) {
+STATIC mp_obj_t mp_builtin___build_class__(size_t n_args, const mp_obj_t *args) {
     assert(2 <= n_args);
 
     // set the new classes __locals__ object
@@ -88,12 +88,12 @@ static mp_obj_t mp_builtin___build_class__(size_t n_args, const mp_obj_t *args)
 }
 MP_DEFINE_CONST_FUN_OBJ_VAR(mp_builtin___build_class___obj, 2, mp_builtin___build_class__);
 
-static mp_obj_t mp_builtin_abs(mp_obj_t o_in) {
+STATIC mp_obj_t mp_builtin_abs(mp_obj_t o_in) {
     return mp_unary_op(MP_UNARY_OP_ABS, o_in);
 }
 MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_abs_obj, mp_builtin_abs);
 
-static mp_obj_t mp_builtin_all(mp_obj_t o_in) {
+STATIC mp_obj_t mp_builtin_all(mp_obj_t o_in) {
     mp_obj_iter_buf_t iter_buf;
     mp_obj_t iterable = mp_getiter(o_in, &iter_buf);
     mp_obj_t item;
@@ -106,7 +106,7 @@ static mp_obj_t mp_builtin_all(mp_obj_t o_in) {
 }
 MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_all_obj, mp_builtin_all);
 
-static mp_obj_t mp_builtin_any(mp_obj_t o_in) {
+STATIC mp_obj_t mp_builtin_any(mp_obj_t o_in) {
     mp_obj_iter_buf_t iter_buf;
     mp_obj_t iterable = mp_getiter(o_in, &iter_buf);
     mp_obj_t item;
@@ -119,13 +119,13 @@ static mp_obj_t mp_builtin_any(mp_obj_t o_in) {
 }
 MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_any_obj, mp_builtin_any);
 
-static mp_obj_t mp_builtin_bin(mp_obj_t o_in) {
+STATIC mp_obj_t mp_builtin_bin(mp_obj_t o_in) {
     mp_obj_t args[] = { MP_OBJ_NEW_QSTR(MP_QSTR__brace_open__colon__hash_b_brace_close_), o_in };
     return mp_obj_str_format(MP_ARRAY_SIZE(args), args, NULL);
 }
 MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_bin_obj, mp_builtin_bin);
 
-static mp_obj_t mp_builtin_callable(mp_obj_t o_in) {
+STATIC mp_obj_t mp_builtin_callable(mp_obj_t o_in) {
     if (mp_obj_is_callable(o_in)) {
         return mp_const_true;
     } else {
@@ -134,7 +134,7 @@ static mp_obj_t mp_builtin_callable(mp_obj_t o_in) {
 }
 MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_callable_obj, mp_builtin_callable);
 
-static mp_obj_t mp_builtin_chr(mp_obj_t o_in) {
+STATIC mp_obj_t mp_builtin_chr(mp_obj_t o_in) {
     #if MICROPY_PY_BUILTINS_STR_UNICODE
     mp_uint_t c = mp_obj_get_int(o_in);
     if (c >= 0x110000) {
@@ -155,7 +155,7 @@ static mp_obj_t mp_builtin_chr(mp_obj_t o_in) {
 }
 MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_chr_obj, mp_builtin_chr);
 
-static mp_obj_t mp_builtin_dir(size_t n_args, const mp_obj_t *args) {
+STATIC mp_obj_t mp_builtin_dir(size_t n_args, const mp_obj_t *args) {
     mp_obj_t dir = mp_obj_new_list(0, NULL);
     if (n_args == 0) {
         // Make a list of names in the local namespace
@@ -188,18 +188,18 @@ static mp_obj_t mp_builtin_dir(size_t n_args, const mp_obj_t *args) {
 }
 MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_dir_obj, 0, 1, mp_builtin_dir);
 
-static mp_obj_t mp_builtin_divmod(mp_obj_t o1_in, mp_obj_t o2_in) {
+STATIC mp_obj_t mp_builtin_divmod(mp_obj_t o1_in, mp_obj_t o2_in) {
     return mp_binary_op(MP_BINARY_OP_DIVMOD, o1_in, o2_in);
 }
 MP_DEFINE_CONST_FUN_OBJ_2(mp_builtin_divmod_obj, mp_builtin_divmod);
 
-static mp_obj_t mp_builtin_hash(mp_obj_t o_in) {
+STATIC mp_obj_t mp_builtin_hash(mp_obj_t o_in) {
     // result is guaranteed to be a (small) int
     return mp_unary_op(MP_UNARY_OP_HASH, o_in);
 }
 MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_hash_obj, mp_builtin_hash);
 
-static mp_obj_t mp_builtin_hex(mp_obj_t o_in) {
+STATIC mp_obj_t mp_builtin_hex(mp_obj_t o_in) {
     #if MICROPY_PY_BUILTINS_STR_OP_MODULO
     return mp_binary_op(MP_BINARY_OP_MODULO, MP_OBJ_NEW_QSTR(MP_QSTR__percent__hash_x), o_in);
     #else
@@ -219,7 +219,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_hex_obj, mp_builtin_hex);
 #define mp_hal_readline readline
 #endif
 
-static mp_obj_t mp_builtin_input(size_t n_args, const mp_obj_t *args) {
+STATIC mp_obj_t mp_builtin_input(size_t n_args, const mp_obj_t *args) {
     if (n_args == 1) {
         mp_obj_print(args[0], PRINT_STR);
     }
@@ -238,14 +238,14 @@ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_input_obj, 0, 1, mp_builtin_input
 
 #endif
 
-static mp_obj_t mp_builtin_iter(mp_obj_t o_in) {
+STATIC mp_obj_t mp_builtin_iter(mp_obj_t o_in) {
     return mp_getiter(o_in, NULL);
 }
 MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_iter_obj, mp_builtin_iter);
 
 #if MICROPY_PY_BUILTINS_MIN_MAX
 
-static mp_obj_t mp_builtin_min_max(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs, mp_uint_t op) {
+STATIC mp_obj_t mp_builtin_min_max(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs, mp_uint_t op) {
     mp_map_elem_t *key_elem = mp_map_lookup(kwargs, MP_OBJ_NEW_QSTR(MP_QSTR_key), MP_MAP_LOOKUP);
     mp_map_elem_t *default_elem;
     mp_obj_t key_fn = key_elem == NULL ? MP_OBJ_NULL : key_elem->value;
@@ -287,12 +287,12 @@ static mp_obj_t mp_builtin_min_max(size_t n_args, const mp_obj_t *args, mp_map_t
     }
 }
 
-static mp_obj_t mp_builtin_max(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs) {
+STATIC mp_obj_t mp_builtin_max(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs) {
     return mp_builtin_min_max(n_args, args, kwargs, MP_BINARY_OP_MORE);
 }
 MP_DEFINE_CONST_FUN_OBJ_KW(mp_builtin_max_obj, 1, mp_builtin_max);
 
-static mp_obj_t mp_builtin_min(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs) {
+STATIC mp_obj_t mp_builtin_min(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs) {
     return mp_builtin_min_max(n_args, args, kwargs, MP_BINARY_OP_LESS);
 }
 MP_DEFINE_CONST_FUN_OBJ_KW(mp_builtin_min_obj, 1, mp_builtin_min);
@@ -300,7 +300,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(mp_builtin_min_obj, 1, mp_builtin_min);
 #endif
 
 #if MICROPY_PY_BUILTINS_NEXT2
-static mp_obj_t mp_builtin_next(size_t n_args, const mp_obj_t *args) {
+STATIC mp_obj_t mp_builtin_next(size_t n_args, const mp_obj_t *args) {
     if (n_args == 1) {
         mp_obj_t ret = mp_iternext_allow_raise(args[0]);
         if (ret == MP_OBJ_STOP_ITERATION) {
@@ -315,7 +315,7 @@ static mp_obj_t mp_builtin_next(size_t n_args, const mp_obj_t *args) {
 }
 MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_next_obj, 1, 2, mp_builtin_next);
 #else
-static mp_obj_t mp_builtin_next(mp_obj_t o) {
+STATIC mp_obj_t mp_builtin_next(mp_obj_t o) {
     mp_obj_t ret = mp_iternext_allow_raise(o);
     if (ret == MP_OBJ_STOP_ITERATION) {
         mp_raise_StopIteration(MP_STATE_THREAD(stop_iteration_arg));
@@ -326,7 +326,7 @@ static mp_obj_t mp_builtin_next(mp_obj_t o) {
 MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_next_obj, mp_builtin_next);
 #endif
 
-static mp_obj_t mp_builtin_oct(mp_obj_t o_in) {
+STATIC mp_obj_t mp_builtin_oct(mp_obj_t o_in) {
     #if MICROPY_PY_BUILTINS_STR_OP_MODULO
     return mp_binary_op(MP_BINARY_OP_MODULO, MP_OBJ_NEW_QSTR(MP_QSTR__percent__hash_o), o_in);
     #else
@@ -336,7 +336,7 @@ static mp_obj_t mp_builtin_oct(mp_obj_t o_in) {
 }
 MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_oct_obj, mp_builtin_oct);
 
-static mp_obj_t mp_builtin_ord(mp_obj_t o_in) {
+STATIC mp_obj_t mp_builtin_ord(mp_obj_t o_in) {
     size_t len;
     const byte *str = (const byte *)mp_obj_str_get_data(o_in, &len);
     #if MICROPY_PY_BUILTINS_STR_UNICODE
@@ -363,7 +363,7 @@ static mp_obj_t mp_builtin_ord(mp_obj_t o_in) {
 }
 MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_ord_obj, mp_builtin_ord);
 
-static mp_obj_t mp_builtin_pow(size_t n_args, const mp_obj_t *args) {
+STATIC mp_obj_t mp_builtin_pow(size_t n_args, const mp_obj_t *args) {
     switch (n_args) {
         case 2:
             return mp_binary_op(MP_BINARY_OP_POWER, args[0], args[1]);
@@ -379,7 +379,7 @@ static mp_obj_t mp_builtin_pow(size_t n_args, const mp_obj_t *args) {
 }
 MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_pow_obj, 2, 3, mp_builtin_pow);
 
-static mp_obj_t mp_builtin_print(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
+STATIC mp_obj_t mp_builtin_print(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
     enum { ARG_sep, ARG_end, ARG_file };
     static const mp_arg_t allowed_args[] = {
         { MP_QSTR_sep, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_rom_obj = MP_ROM_QSTR(MP_QSTR__space_)} },
@@ -430,7 +430,7 @@ static mp_obj_t mp_builtin_print(size_t n_args, const mp_obj_t *pos_args, mp_map
 }
 MP_DEFINE_CONST_FUN_OBJ_KW(mp_builtin_print_obj, 0, mp_builtin_print);
 
-static mp_obj_t mp_builtin___repl_print__(mp_obj_t o) {
+STATIC mp_obj_t mp_builtin___repl_print__(mp_obj_t o) {
     if (o != mp_const_none) {
         mp_obj_print_helper(MP_PYTHON_PRINTER, o, PRINT_REPR);
         mp_print_str(MP_PYTHON_PRINTER, "\n");
@@ -444,7 +444,7 @@ static mp_obj_t mp_builtin___repl_print__(mp_obj_t o) {
 }
 MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin___repl_print___obj, mp_builtin___repl_print__);
 
-static mp_obj_t mp_builtin_repr(mp_obj_t o_in) {
+STATIC mp_obj_t mp_builtin_repr(mp_obj_t o_in) {
     vstr_t vstr;
     mp_print_t print;
     vstr_init_print(&vstr, 16, &print);
@@ -453,7 +453,7 @@ static mp_obj_t mp_builtin_repr(mp_obj_t o_in) {
 }
 MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_repr_obj, mp_builtin_repr);
 
-static mp_obj_t mp_builtin_round(size_t n_args, const mp_obj_t *args) {
+STATIC mp_obj_t mp_builtin_round(size_t n_args, const mp_obj_t *args) {
     mp_obj_t o_in = args[0];
     if (mp_obj_is_int(o_in)) {
         if (n_args <= 1) {
@@ -505,7 +505,7 @@ static mp_obj_t mp_builtin_round(size_t n_args, const mp_obj_t *args) {
 }
 MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_round_obj, 1, 2, mp_builtin_round);
 
-static mp_obj_t mp_builtin_sum(size_t n_args, const mp_obj_t *args) {
+STATIC mp_obj_t mp_builtin_sum(size_t n_args, const mp_obj_t *args) {
     mp_obj_t value;
     switch (n_args) {
         case 1:
@@ -525,7 +525,7 @@ static mp_obj_t mp_builtin_sum(size_t n_args, const mp_obj_t *args) {
 }
 MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_sum_obj, 1, 2, mp_builtin_sum);
 
-static mp_obj_t mp_builtin_sorted(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs) {
+STATIC mp_obj_t mp_builtin_sorted(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs) {
     if (n_args > 1) {
         mp_raise_TypeError(MP_ERROR_TEXT("must use keyword argument for key function"));
     }
@@ -556,7 +556,7 @@ static inline mp_obj_t mp_load_attr_default(mp_obj_t base, qstr attr, mp_obj_t d
     }
 }
 
-static mp_obj_t mp_builtin_getattr(size_t n_args, const mp_obj_t *args) {
+STATIC mp_obj_t mp_builtin_getattr(size_t n_args, const mp_obj_t *args) {
     mp_obj_t defval = MP_OBJ_NULL;
     if (n_args > 2) {
         defval = args[2];
@@ -565,20 +565,20 @@ static mp_obj_t mp_builtin_getattr(size_t n_args, const mp_obj_t *args) {
 }
 MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_getattr_obj, 2, 3, mp_builtin_getattr);
 
-static mp_obj_t mp_builtin_setattr(mp_obj_t base, mp_obj_t attr, mp_obj_t value) {
+STATIC mp_obj_t mp_builtin_setattr(mp_obj_t base, mp_obj_t attr, mp_obj_t value) {
     mp_store_attr(base, mp_obj_str_get_qstr(attr), value);
     return mp_const_none;
 }
 MP_DEFINE_CONST_FUN_OBJ_3(mp_builtin_setattr_obj, mp_builtin_setattr);
 
 #if MICROPY_CPYTHON_COMPAT
-static mp_obj_t mp_builtin_delattr(mp_obj_t base, mp_obj_t attr) {
+STATIC mp_obj_t mp_builtin_delattr(mp_obj_t base, mp_obj_t attr) {
     return mp_builtin_setattr(base, attr, MP_OBJ_NULL);
 }
 MP_DEFINE_CONST_FUN_OBJ_2(mp_builtin_delattr_obj, mp_builtin_delattr);
 #endif
 
-static mp_obj_t mp_builtin_hasattr(mp_obj_t object_in, mp_obj_t attr_in) {
+STATIC mp_obj_t mp_builtin_hasattr(mp_obj_t object_in, mp_obj_t attr_in) {
     qstr attr = mp_obj_str_get_qstr(attr_in);
     mp_obj_t dest[2];
     mp_load_method_protected(object_in, attr, dest, false);
@@ -586,12 +586,12 @@ static mp_obj_t mp_builtin_hasattr(mp_obj_t object_in, mp_obj_t attr_in) {
 }
 MP_DEFINE_CONST_FUN_OBJ_2(mp_builtin_hasattr_obj, mp_builtin_hasattr);
 
-static mp_obj_t mp_builtin_globals(void) {
+STATIC mp_obj_t mp_builtin_globals(void) {
     return MP_OBJ_FROM_PTR(mp_globals_get());
 }
 MP_DEFINE_CONST_FUN_OBJ_0(mp_builtin_globals_obj, mp_builtin_globals);
 
-static mp_obj_t mp_builtin_locals(void) {
+STATIC mp_obj_t mp_builtin_locals(void) {
     return MP_OBJ_FROM_PTR(mp_locals_get());
 }
 MP_DEFINE_CONST_FUN_OBJ_0(mp_builtin_locals_obj, mp_builtin_locals);
@@ -600,7 +600,7 @@ MP_DEFINE_CONST_FUN_OBJ_0(mp_builtin_locals_obj, mp_builtin_locals);
 MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_id_obj, mp_obj_id);
 MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_len_obj, mp_obj_len);
 
-static const mp_rom_map_elem_t mp_module_builtins_globals_table[] = {
+STATIC const mp_rom_map_elem_t mp_module_builtins_globals_table[] = {
     { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_builtins) },
 
     // built-in core functions

+ 20 - 20
py/modcmath.c

@@ -31,15 +31,15 @@
 #include <math.h>
 
 // phase(z): returns the phase of the number z in the range (-pi, +pi]
-static mp_obj_t mp_cmath_phase(mp_obj_t z_obj) {
+STATIC mp_obj_t mp_cmath_phase(mp_obj_t z_obj) {
     mp_float_t real, imag;
     mp_obj_get_complex(z_obj, &real, &imag);
     return mp_obj_new_float(MICROPY_FLOAT_C_FUN(atan2)(imag, real));
 }
-static MP_DEFINE_CONST_FUN_OBJ_1(mp_cmath_phase_obj, mp_cmath_phase);
+STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_cmath_phase_obj, mp_cmath_phase);
 
 // polar(z): returns the polar form of z as a tuple
-static mp_obj_t mp_cmath_polar(mp_obj_t z_obj) {
+STATIC mp_obj_t mp_cmath_polar(mp_obj_t z_obj) {
     mp_float_t real, imag;
     mp_obj_get_complex(z_obj, &real, &imag);
     mp_obj_t tuple[2] = {
@@ -48,71 +48,71 @@ static mp_obj_t mp_cmath_polar(mp_obj_t z_obj) {
     };
     return mp_obj_new_tuple(2, tuple);
 }
-static MP_DEFINE_CONST_FUN_OBJ_1(mp_cmath_polar_obj, mp_cmath_polar);
+STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_cmath_polar_obj, mp_cmath_polar);
 
 // rect(r, phi): returns the complex number with modulus r and phase phi
-static mp_obj_t mp_cmath_rect(mp_obj_t r_obj, mp_obj_t phi_obj) {
+STATIC mp_obj_t mp_cmath_rect(mp_obj_t r_obj, mp_obj_t phi_obj) {
     mp_float_t r = mp_obj_get_float(r_obj);
     mp_float_t phi = mp_obj_get_float(phi_obj);
     return mp_obj_new_complex(r * MICROPY_FLOAT_C_FUN(cos)(phi), r * MICROPY_FLOAT_C_FUN(sin)(phi));
 }
-static MP_DEFINE_CONST_FUN_OBJ_2(mp_cmath_rect_obj, mp_cmath_rect);
+STATIC MP_DEFINE_CONST_FUN_OBJ_2(mp_cmath_rect_obj, mp_cmath_rect);
 
 // exp(z): return the exponential of z
-static mp_obj_t mp_cmath_exp(mp_obj_t z_obj) {
+STATIC mp_obj_t mp_cmath_exp(mp_obj_t z_obj) {
     mp_float_t real, imag;
     mp_obj_get_complex(z_obj, &real, &imag);
     mp_float_t exp_real = MICROPY_FLOAT_C_FUN(exp)(real);
     return mp_obj_new_complex(exp_real * MICROPY_FLOAT_C_FUN(cos)(imag), exp_real * MICROPY_FLOAT_C_FUN(sin)(imag));
 }
-static MP_DEFINE_CONST_FUN_OBJ_1(mp_cmath_exp_obj, mp_cmath_exp);
+STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_cmath_exp_obj, mp_cmath_exp);
 
 // log(z): return the natural logarithm of z, with branch cut along the negative real axis
 // TODO can take second argument, being the base
-static mp_obj_t mp_cmath_log(mp_obj_t z_obj) {
+STATIC mp_obj_t mp_cmath_log(mp_obj_t z_obj) {
     mp_float_t real, imag;
     mp_obj_get_complex(z_obj, &real, &imag);
     return mp_obj_new_complex(MICROPY_FLOAT_CONST(0.5) * MICROPY_FLOAT_C_FUN(log)(real * real + imag * imag), MICROPY_FLOAT_C_FUN(atan2)(imag, real));
 }
-static MP_DEFINE_CONST_FUN_OBJ_1(mp_cmath_log_obj, mp_cmath_log);
+STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_cmath_log_obj, mp_cmath_log);
 
 #if MICROPY_PY_MATH_SPECIAL_FUNCTIONS
 // log10(z): return the base-10 logarithm of z, with branch cut along the negative real axis
-static mp_obj_t mp_cmath_log10(mp_obj_t z_obj) {
+STATIC mp_obj_t mp_cmath_log10(mp_obj_t z_obj) {
     mp_float_t real, imag;
     mp_obj_get_complex(z_obj, &real, &imag);
     return mp_obj_new_complex(MICROPY_FLOAT_CONST(0.5) * MICROPY_FLOAT_C_FUN(log10)(real * real + imag * imag), MICROPY_FLOAT_CONST(0.4342944819032518) * MICROPY_FLOAT_C_FUN(atan2)(imag, real));
 }
-static MP_DEFINE_CONST_FUN_OBJ_1(mp_cmath_log10_obj, mp_cmath_log10);
+STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_cmath_log10_obj, mp_cmath_log10);
 #endif
 
 // sqrt(z): return the square-root of z
-static mp_obj_t mp_cmath_sqrt(mp_obj_t z_obj) {
+STATIC mp_obj_t mp_cmath_sqrt(mp_obj_t z_obj) {
     mp_float_t real, imag;
     mp_obj_get_complex(z_obj, &real, &imag);
     mp_float_t sqrt_abs = MICROPY_FLOAT_C_FUN(pow)(real * real + imag * imag, MICROPY_FLOAT_CONST(0.25));
     mp_float_t theta = MICROPY_FLOAT_CONST(0.5) * MICROPY_FLOAT_C_FUN(atan2)(imag, real);
     return mp_obj_new_complex(sqrt_abs * MICROPY_FLOAT_C_FUN(cos)(theta), sqrt_abs * MICROPY_FLOAT_C_FUN(sin)(theta));
 }
-static MP_DEFINE_CONST_FUN_OBJ_1(mp_cmath_sqrt_obj, mp_cmath_sqrt);
+STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_cmath_sqrt_obj, mp_cmath_sqrt);
 
 // cos(z): return the cosine of z
-static mp_obj_t mp_cmath_cos(mp_obj_t z_obj) {
+STATIC mp_obj_t mp_cmath_cos(mp_obj_t z_obj) {
     mp_float_t real, imag;
     mp_obj_get_complex(z_obj, &real, &imag);
     return mp_obj_new_complex(MICROPY_FLOAT_C_FUN(cos)(real) * MICROPY_FLOAT_C_FUN(cosh)(imag), -MICROPY_FLOAT_C_FUN(sin)(real) * MICROPY_FLOAT_C_FUN(sinh)(imag));
 }
-static MP_DEFINE_CONST_FUN_OBJ_1(mp_cmath_cos_obj, mp_cmath_cos);
+STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_cmath_cos_obj, mp_cmath_cos);
 
 // sin(z): return the sine of z
-static mp_obj_t mp_cmath_sin(mp_obj_t z_obj) {
+STATIC mp_obj_t mp_cmath_sin(mp_obj_t z_obj) {
     mp_float_t real, imag;
     mp_obj_get_complex(z_obj, &real, &imag);
     return mp_obj_new_complex(MICROPY_FLOAT_C_FUN(sin)(real) * MICROPY_FLOAT_C_FUN(cosh)(imag), MICROPY_FLOAT_C_FUN(cos)(real) * MICROPY_FLOAT_C_FUN(sinh)(imag));
 }
-static MP_DEFINE_CONST_FUN_OBJ_1(mp_cmath_sin_obj, mp_cmath_sin);
+STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_cmath_sin_obj, mp_cmath_sin);
 
-static const mp_rom_map_elem_t mp_module_cmath_globals_table[] = {
+STATIC const mp_rom_map_elem_t mp_module_cmath_globals_table[] = {
     { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_cmath) },
     { MP_ROM_QSTR(MP_QSTR_e), mp_const_float_e },
     { MP_ROM_QSTR(MP_QSTR_pi), mp_const_float_pi },
@@ -142,7 +142,7 @@ static const mp_rom_map_elem_t mp_module_cmath_globals_table[] = {
     // { MP_ROM_QSTR(MP_QSTR_isnan), MP_ROM_PTR(&mp_cmath_isnan_obj) },
 };
 
-static MP_DEFINE_CONST_DICT(mp_module_cmath_globals, mp_module_cmath_globals_table);
+STATIC MP_DEFINE_CONST_DICT(mp_module_cmath_globals, mp_module_cmath_globals_table);
 
 const mp_obj_module_t mp_module_cmath = {
     .base = { &mp_type_module },

+ 2 - 2
py/modcollections.c

@@ -28,7 +28,7 @@
 
 #if MICROPY_PY_COLLECTIONS
 
-static const mp_rom_map_elem_t mp_module_collections_globals_table[] = {
+STATIC const mp_rom_map_elem_t mp_module_collections_globals_table[] = {
     { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_collections) },
     #if MICROPY_PY_COLLECTIONS_DEQUE
     { MP_ROM_QSTR(MP_QSTR_deque), MP_ROM_PTR(&mp_type_deque) },
@@ -39,7 +39,7 @@ static const mp_rom_map_elem_t mp_module_collections_globals_table[] = {
     #endif
 };
 
-static MP_DEFINE_CONST_DICT(mp_module_collections_globals, mp_module_collections_globals_table);
+STATIC MP_DEFINE_CONST_DICT(mp_module_collections_globals, mp_module_collections_globals_table);
 
 const mp_obj_module_t mp_module_collections = {
     .base = { &mp_type_module },

+ 4 - 4
py/moderrno.c

@@ -62,13 +62,13 @@
 #endif
 
 #if MICROPY_PY_ERRNO_ERRORCODE
-static const mp_rom_map_elem_t errorcode_table[] = {
+STATIC const mp_rom_map_elem_t errorcode_table[] = {
     #define X(e) { MP_ROM_INT(MP_##e), MP_ROM_QSTR(MP_QSTR_##e) },
     MICROPY_PY_ERRNO_LIST
 #undef X
 };
 
-static const mp_obj_dict_t errorcode_dict = {
+STATIC const mp_obj_dict_t errorcode_dict = {
     .base = {&mp_type_dict},
     .map = {
         .all_keys_are_qstrs = 0, // keys are integers
@@ -81,7 +81,7 @@ static const mp_obj_dict_t errorcode_dict = {
 };
 #endif
 
-static const mp_rom_map_elem_t mp_module_errno_globals_table[] = {
+STATIC const mp_rom_map_elem_t mp_module_errno_globals_table[] = {
     { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_errno) },
     #if MICROPY_PY_ERRNO_ERRORCODE
     { MP_ROM_QSTR(MP_QSTR_errorcode), MP_ROM_PTR(&errorcode_dict) },
@@ -92,7 +92,7 @@ static const mp_rom_map_elem_t mp_module_errno_globals_table[] = {
 #undef X
 };
 
-static MP_DEFINE_CONST_DICT(mp_module_errno_globals, mp_module_errno_globals_table);
+STATIC MP_DEFINE_CONST_DICT(mp_module_errno_globals, mp_module_errno_globals_table);
 
 const mp_obj_module_t mp_module_errno = {
     .base = { &mp_type_module },

+ 9 - 9
py/modgc.c

@@ -31,7 +31,7 @@
 #if MICROPY_PY_GC && MICROPY_ENABLE_GC
 
 // collect(): run a garbage collection
-static mp_obj_t py_gc_collect(void) {
+STATIC mp_obj_t py_gc_collect(void) {
     gc_collect();
     #if MICROPY_PY_GC_COLLECT_RETVAL
     return MP_OBJ_NEW_SMALL_INT(MP_STATE_MEM(gc_collected));
@@ -42,26 +42,26 @@ static mp_obj_t py_gc_collect(void) {
 MP_DEFINE_CONST_FUN_OBJ_0(gc_collect_obj, py_gc_collect);
 
 // disable(): disable the garbage collector
-static mp_obj_t gc_disable(void) {
+STATIC mp_obj_t gc_disable(void) {
     MP_STATE_MEM(gc_auto_collect_enabled) = 0;
     return mp_const_none;
 }
 MP_DEFINE_CONST_FUN_OBJ_0(gc_disable_obj, gc_disable);
 
 // enable(): enable the garbage collector
-static mp_obj_t gc_enable(void) {
+STATIC mp_obj_t gc_enable(void) {
     MP_STATE_MEM(gc_auto_collect_enabled) = 1;
     return mp_const_none;
 }
 MP_DEFINE_CONST_FUN_OBJ_0(gc_enable_obj, gc_enable);
 
-static mp_obj_t gc_isenabled(void) {
+STATIC mp_obj_t gc_isenabled(void) {
     return mp_obj_new_bool(MP_STATE_MEM(gc_auto_collect_enabled));
 }
 MP_DEFINE_CONST_FUN_OBJ_0(gc_isenabled_obj, gc_isenabled);
 
 // mem_free(): return the number of bytes of available heap RAM
-static mp_obj_t gc_mem_free(void) {
+STATIC mp_obj_t gc_mem_free(void) {
     gc_info_t info;
     gc_info(&info);
     #if MICROPY_GC_SPLIT_HEAP_AUTO
@@ -74,7 +74,7 @@ static mp_obj_t gc_mem_free(void) {
 MP_DEFINE_CONST_FUN_OBJ_0(gc_mem_free_obj, gc_mem_free);
 
 // mem_alloc(): return the number of bytes of heap RAM that are allocated
-static mp_obj_t gc_mem_alloc(void) {
+STATIC mp_obj_t gc_mem_alloc(void) {
     gc_info_t info;
     gc_info(&info);
     return MP_OBJ_NEW_SMALL_INT(info.used);
@@ -82,7 +82,7 @@ static mp_obj_t gc_mem_alloc(void) {
 MP_DEFINE_CONST_FUN_OBJ_0(gc_mem_alloc_obj, gc_mem_alloc);
 
 #if MICROPY_GC_ALLOC_THRESHOLD
-static mp_obj_t gc_threshold(size_t n_args, const mp_obj_t *args) {
+STATIC mp_obj_t gc_threshold(size_t n_args, const mp_obj_t *args) {
     if (n_args == 0) {
         if (MP_STATE_MEM(gc_alloc_threshold) == (size_t)-1) {
             return MP_OBJ_NEW_SMALL_INT(-1);
@@ -100,7 +100,7 @@ static mp_obj_t gc_threshold(size_t n_args, const mp_obj_t *args) {
 MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(gc_threshold_obj, 0, 1, gc_threshold);
 #endif
 
-static const mp_rom_map_elem_t mp_module_gc_globals_table[] = {
+STATIC const mp_rom_map_elem_t mp_module_gc_globals_table[] = {
     { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_gc) },
     { MP_ROM_QSTR(MP_QSTR_collect), MP_ROM_PTR(&gc_collect_obj) },
     { MP_ROM_QSTR(MP_QSTR_disable), MP_ROM_PTR(&gc_disable_obj) },
@@ -113,7 +113,7 @@ static const mp_rom_map_elem_t mp_module_gc_globals_table[] = {
     #endif
 };
 
-static MP_DEFINE_CONST_DICT(mp_module_gc_globals, mp_module_gc_globals_table);
+STATIC MP_DEFINE_CONST_DICT(mp_module_gc_globals, mp_module_gc_globals_table);
 
 const mp_obj_module_t mp_module_gc = {
     .base = { &mp_type_module },

+ 20 - 20
py/modio.c

@@ -39,11 +39,11 @@
 
 #if MICROPY_PY_IO_IOBASE
 
-static const mp_obj_type_t mp_type_iobase;
+STATIC const mp_obj_type_t mp_type_iobase;
 
-static const mp_obj_base_t iobase_singleton = {&mp_type_iobase};
+STATIC const mp_obj_base_t iobase_singleton = {&mp_type_iobase};
 
-static mp_obj_t iobase_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
+STATIC mp_obj_t iobase_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
     (void)type;
     (void)n_args;
     (void)n_kw;
@@ -51,7 +51,7 @@ static mp_obj_t iobase_make_new(const mp_obj_type_t *type, size_t n_args, size_t
     return MP_OBJ_FROM_PTR(&iobase_singleton);
 }
 
-static mp_uint_t iobase_read_write(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode, qstr qst) {
+STATIC mp_uint_t iobase_read_write(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode, qstr qst) {
     mp_obj_t dest[3];
     mp_load_method(obj, qst, dest);
     mp_obj_array_t ar = {{&mp_type_bytearray}, BYTEARRAY_TYPECODE, 0, size, buf};
@@ -69,15 +69,15 @@ static mp_uint_t iobase_read_write(mp_obj_t obj, void *buf, mp_uint_t size, int
         return MP_STREAM_ERROR;
     }
 }
-static mp_uint_t iobase_read(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode) {
+STATIC mp_uint_t iobase_read(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode) {
     return iobase_read_write(obj, buf, size, errcode, MP_QSTR_readinto);
 }
 
-static mp_uint_t iobase_write(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode) {
+STATIC mp_uint_t iobase_write(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode) {
     return iobase_read_write(obj, (void *)buf, size, errcode, MP_QSTR_write);
 }
 
-static mp_uint_t iobase_ioctl(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode) {
+STATIC mp_uint_t iobase_ioctl(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode) {
     mp_obj_t dest[4];
     mp_load_method(obj, MP_QSTR_ioctl, dest);
     dest[2] = mp_obj_new_int_from_uint(request);
@@ -91,13 +91,13 @@ static mp_uint_t iobase_ioctl(mp_obj_t obj, mp_uint_t request, uintptr_t arg, in
     }
 }
 
-static const mp_stream_p_t iobase_p = {
+STATIC const mp_stream_p_t iobase_p = {
     .read = iobase_read,
     .write = iobase_write,
     .ioctl = iobase_ioctl,
 };
 
-static MP_DEFINE_CONST_OBJ_TYPE(
+STATIC MP_DEFINE_CONST_OBJ_TYPE(
     mp_type_iobase,
     MP_QSTR_IOBase,
     MP_TYPE_FLAG_NONE,
@@ -116,17 +116,17 @@ typedef struct _mp_obj_bufwriter_t {
     byte buf[0];
 } mp_obj_bufwriter_t;
 
-static mp_obj_t bufwriter_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
+STATIC mp_obj_t bufwriter_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
     mp_arg_check_num(n_args, n_kw, 2, 2, false);
     size_t alloc = mp_obj_get_int(args[1]);
-    mp_obj_bufwriter_t *o = mp_obj_malloc_var(mp_obj_bufwriter_t, buf, byte, alloc, type);
+    mp_obj_bufwriter_t *o = mp_obj_malloc_var(mp_obj_bufwriter_t, byte, alloc, type);
     o->stream = args[0];
     o->alloc = alloc;
     o->len = 0;
     return o;
 }
 
-static mp_uint_t bufwriter_write(mp_obj_t self_in, const void *buf, mp_uint_t size, int *errcode) {
+STATIC mp_uint_t bufwriter_write(mp_obj_t self_in, const void *buf, mp_uint_t size, int *errcode) {
     mp_obj_bufwriter_t *self = MP_OBJ_TO_PTR(self_in);
 
     mp_uint_t org_size = size;
@@ -162,7 +162,7 @@ static mp_uint_t bufwriter_write(mp_obj_t self_in, const void *buf, mp_uint_t si
     return org_size;
 }
 
-static mp_obj_t bufwriter_flush(mp_obj_t self_in) {
+STATIC mp_obj_t bufwriter_flush(mp_obj_t self_in) {
     mp_obj_bufwriter_t *self = MP_OBJ_TO_PTR(self_in);
 
     if (self->len != 0) {
@@ -180,19 +180,19 @@ static mp_obj_t bufwriter_flush(mp_obj_t self_in) {
 
     return mp_const_none;
 }
-static MP_DEFINE_CONST_FUN_OBJ_1(bufwriter_flush_obj, bufwriter_flush);
+STATIC MP_DEFINE_CONST_FUN_OBJ_1(bufwriter_flush_obj, bufwriter_flush);
 
-static const mp_rom_map_elem_t bufwriter_locals_dict_table[] = {
+STATIC const mp_rom_map_elem_t bufwriter_locals_dict_table[] = {
     { MP_ROM_QSTR(MP_QSTR_write), MP_ROM_PTR(&mp_stream_write_obj) },
     { MP_ROM_QSTR(MP_QSTR_flush), MP_ROM_PTR(&bufwriter_flush_obj) },
 };
-static MP_DEFINE_CONST_DICT(bufwriter_locals_dict, bufwriter_locals_dict_table);
+STATIC MP_DEFINE_CONST_DICT(bufwriter_locals_dict, bufwriter_locals_dict_table);
 
-static const mp_stream_p_t bufwriter_stream_p = {
+STATIC const mp_stream_p_t bufwriter_stream_p = {
     .write = bufwriter_write,
 };
 
-static MP_DEFINE_CONST_OBJ_TYPE(
+STATIC MP_DEFINE_CONST_OBJ_TYPE(
     mp_type_bufwriter,
     MP_QSTR_BufferedWriter,
     MP_TYPE_FLAG_NONE,
@@ -202,7 +202,7 @@ static MP_DEFINE_CONST_OBJ_TYPE(
     );
 #endif // MICROPY_PY_IO_BUFFEREDWRITER
 
-static const mp_rom_map_elem_t mp_module_io_globals_table[] = {
+STATIC const mp_rom_map_elem_t mp_module_io_globals_table[] = {
     { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_io) },
     // Note: mp_builtin_open_obj should be defined by port, it's not
     // part of the core.
@@ -219,7 +219,7 @@ static const mp_rom_map_elem_t mp_module_io_globals_table[] = {
     #endif
 };
 
-static MP_DEFINE_CONST_DICT(mp_module_io_globals, mp_module_io_globals_table);
+STATIC MP_DEFINE_CONST_DICT(mp_module_io_globals, mp_module_io_globals_table);
 
 const mp_obj_module_t mp_module_io = {
     .base = { &mp_type_module },

+ 32 - 32
py/modmath.c

@@ -37,11 +37,11 @@
 #define MP_PI_4 MICROPY_FLOAT_CONST(0.78539816339744830962)
 #define MP_3_PI_4 MICROPY_FLOAT_CONST(2.35619449019234492885)
 
-static NORETURN void math_error(void) {
+STATIC NORETURN void math_error(void) {
     mp_raise_ValueError(MP_ERROR_TEXT("math domain error"));
 }
 
-static mp_obj_t math_generic_1(mp_obj_t x_obj, mp_float_t (*f)(mp_float_t)) {
+STATIC mp_obj_t math_generic_1(mp_obj_t x_obj, mp_float_t (*f)(mp_float_t)) {
     mp_float_t x = mp_obj_get_float(x_obj);
     mp_float_t ans = f(x);
     if ((isnan(ans) && !isnan(x)) || (isinf(ans) && !isinf(x))) {
@@ -50,7 +50,7 @@ static mp_obj_t math_generic_1(mp_obj_t x_obj, mp_float_t (*f)(mp_float_t)) {
     return mp_obj_new_float(ans);
 }
 
-static mp_obj_t math_generic_2(mp_obj_t x_obj, mp_obj_t y_obj, mp_float_t (*f)(mp_float_t, mp_float_t)) {
+STATIC mp_obj_t math_generic_2(mp_obj_t x_obj, mp_obj_t y_obj, mp_float_t (*f)(mp_float_t, mp_float_t)) {
     mp_float_t x = mp_obj_get_float(x_obj);
     mp_float_t y = mp_obj_get_float(y_obj);
     mp_float_t ans = f(x, y);
@@ -61,30 +61,30 @@ static mp_obj_t math_generic_2(mp_obj_t x_obj, mp_obj_t y_obj, mp_float_t (*f)(m
 }
 
 #define MATH_FUN_1(py_name, c_name) \
-    static mp_obj_t mp_math_##py_name(mp_obj_t x_obj) { \
+    STATIC mp_obj_t mp_math_##py_name(mp_obj_t x_obj) { \
         return math_generic_1(x_obj, MICROPY_FLOAT_C_FUN(c_name)); \
     } \
-    static MP_DEFINE_CONST_FUN_OBJ_1(mp_math_##py_name##_obj, mp_math_##py_name);
+    STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_math_##py_name##_obj, mp_math_##py_name);
 
 #define MATH_FUN_1_TO_BOOL(py_name, c_name) \
-    static mp_obj_t mp_math_##py_name(mp_obj_t x_obj) { return mp_obj_new_bool(c_name(mp_obj_get_float(x_obj))); } \
-    static MP_DEFINE_CONST_FUN_OBJ_1(mp_math_##py_name##_obj, mp_math_##py_name);
+    STATIC mp_obj_t mp_math_##py_name(mp_obj_t x_obj) { return mp_obj_new_bool(c_name(mp_obj_get_float(x_obj))); } \
+    STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_math_##py_name##_obj, mp_math_##py_name);
 
 #define MATH_FUN_1_TO_INT(py_name, c_name) \
-    static mp_obj_t mp_math_##py_name(mp_obj_t x_obj) { return mp_obj_new_int_from_float(MICROPY_FLOAT_C_FUN(c_name)(mp_obj_get_float(x_obj))); } \
-    static MP_DEFINE_CONST_FUN_OBJ_1(mp_math_##py_name##_obj, mp_math_##py_name);
+    STATIC mp_obj_t mp_math_##py_name(mp_obj_t x_obj) { return mp_obj_new_int_from_float(MICROPY_FLOAT_C_FUN(c_name)(mp_obj_get_float(x_obj))); } \
+    STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_math_##py_name##_obj, mp_math_##py_name);
 
 #define MATH_FUN_2(py_name, c_name) \
-    static mp_obj_t mp_math_##py_name(mp_obj_t x_obj, mp_obj_t y_obj) { \
+    STATIC mp_obj_t mp_math_##py_name(mp_obj_t x_obj, mp_obj_t y_obj) { \
         return math_generic_2(x_obj, y_obj, MICROPY_FLOAT_C_FUN(c_name)); \
     } \
-    static MP_DEFINE_CONST_FUN_OBJ_2(mp_math_##py_name##_obj, mp_math_##py_name);
+    STATIC MP_DEFINE_CONST_FUN_OBJ_2(mp_math_##py_name##_obj, mp_math_##py_name);
 
 #define MATH_FUN_2_FLT_INT(py_name, c_name) \
-    static mp_obj_t mp_math_##py_name(mp_obj_t x_obj, mp_obj_t y_obj) { \
+    STATIC mp_obj_t mp_math_##py_name(mp_obj_t x_obj, mp_obj_t y_obj) { \
         return mp_obj_new_float(MICROPY_FLOAT_C_FUN(c_name)(mp_obj_get_float(x_obj), mp_obj_get_int(y_obj))); \
     } \
-    static MP_DEFINE_CONST_FUN_OBJ_2(mp_math_##py_name##_obj, mp_math_##py_name);
+    STATIC MP_DEFINE_CONST_FUN_OBJ_2(mp_math_##py_name##_obj, mp_math_##py_name);
 
 #if MP_NEED_LOG2
 #undef log2
@@ -160,12 +160,12 @@ MATH_FUN_2(atan2, atan2)
 // ceil(x)
 MATH_FUN_1_TO_INT(ceil, ceil)
 // copysign(x, y)
-static mp_float_t MICROPY_FLOAT_C_FUN(copysign_func)(mp_float_t x, mp_float_t y) {
+STATIC mp_float_t MICROPY_FLOAT_C_FUN(copysign_func)(mp_float_t x, mp_float_t y) {
     return MICROPY_FLOAT_C_FUN(copysign)(x, y);
 }
 MATH_FUN_2(copysign, copysign_func)
 // fabs(x)
-static mp_float_t MICROPY_FLOAT_C_FUN(fabs_func)(mp_float_t x) {
+STATIC mp_float_t MICROPY_FLOAT_C_FUN(fabs_func)(mp_float_t x) {
     return MICROPY_FLOAT_C_FUN(fabs)(x);
 }
 MATH_FUN_1(fabs, fabs_func)
@@ -203,7 +203,7 @@ MATH_FUN_1(lgamma, lgamma)
 // TODO: fsum
 
 #if MICROPY_PY_MATH_ISCLOSE
-static mp_obj_t mp_math_isclose(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
+STATIC mp_obj_t mp_math_isclose(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
     enum { ARG_rel_tol, ARG_abs_tol };
     static const mp_arg_t allowed_args[] = {
         {MP_QSTR_rel_tol, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL}},
@@ -239,7 +239,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(mp_math_isclose_obj, 2, mp_math_isclose);
 // Function that takes a variable number of arguments
 
 // log(x[, base])
-static mp_obj_t mp_math_log(size_t n_args, const mp_obj_t *args) {
+STATIC mp_obj_t mp_math_log(size_t n_args, const mp_obj_t *args) {
     mp_float_t x = mp_obj_get_float(args[0]);
     if (x <= (mp_float_t)0.0) {
         math_error();
@@ -257,12 +257,12 @@ static mp_obj_t mp_math_log(size_t n_args, const mp_obj_t *args) {
         return mp_obj_new_float(l / MICROPY_FLOAT_C_FUN(log)(base));
     }
 }
-static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_math_log_obj, 1, 2, mp_math_log);
+STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_math_log_obj, 1, 2, mp_math_log);
 
 // Functions that return a tuple
 
 // frexp(x): converts a floating-point number to fractional and integral components
-static mp_obj_t mp_math_frexp(mp_obj_t x_obj) {
+STATIC mp_obj_t mp_math_frexp(mp_obj_t x_obj) {
     int int_exponent = 0;
     mp_float_t significand = MICROPY_FLOAT_C_FUN(frexp)(mp_obj_get_float(x_obj), &int_exponent);
     mp_obj_t tuple[2];
@@ -270,10 +270,10 @@ static mp_obj_t mp_math_frexp(mp_obj_t x_obj) {
     tuple[1] = mp_obj_new_int(int_exponent);
     return mp_obj_new_tuple(2, tuple);
 }
-static MP_DEFINE_CONST_FUN_OBJ_1(mp_math_frexp_obj, mp_math_frexp);
+STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_math_frexp_obj, mp_math_frexp);
 
 // modf(x)
-static mp_obj_t mp_math_modf(mp_obj_t x_obj) {
+STATIC mp_obj_t mp_math_modf(mp_obj_t x_obj) {
     mp_float_t int_part = 0.0;
     mp_float_t x = mp_obj_get_float(x_obj);
     mp_float_t fractional_part = MICROPY_FLOAT_C_FUN(modf)(x, &int_part);
@@ -287,28 +287,28 @@ static mp_obj_t mp_math_modf(mp_obj_t x_obj) {
     tuple[1] = mp_obj_new_float(int_part);
     return mp_obj_new_tuple(2, tuple);
 }
-static MP_DEFINE_CONST_FUN_OBJ_1(mp_math_modf_obj, mp_math_modf);
+STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_math_modf_obj, mp_math_modf);
 
 // Angular conversions
 
 // radians(x)
-static mp_obj_t mp_math_radians(mp_obj_t x_obj) {
+STATIC mp_obj_t mp_math_radians(mp_obj_t x_obj) {
     return mp_obj_new_float(mp_obj_get_float(x_obj) * (MP_PI / MICROPY_FLOAT_CONST(180.0)));
 }
-static MP_DEFINE_CONST_FUN_OBJ_1(mp_math_radians_obj, mp_math_radians);
+STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_math_radians_obj, mp_math_radians);
 
 // degrees(x)
-static mp_obj_t mp_math_degrees(mp_obj_t x_obj) {
+STATIC mp_obj_t mp_math_degrees(mp_obj_t x_obj) {
     return mp_obj_new_float(mp_obj_get_float(x_obj) * (MICROPY_FLOAT_CONST(180.0) / MP_PI));
 }
-static MP_DEFINE_CONST_FUN_OBJ_1(mp_math_degrees_obj, mp_math_degrees);
+STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_math_degrees_obj, mp_math_degrees);
 
 #if MICROPY_PY_MATH_FACTORIAL
 
 #if MICROPY_OPT_MATH_FACTORIAL
 
 // factorial(x): slightly efficient recursive implementation
-static mp_obj_t mp_math_factorial_inner(mp_uint_t start, mp_uint_t end) {
+STATIC mp_obj_t mp_math_factorial_inner(mp_uint_t start, mp_uint_t end) {
     if (start == end) {
         return mp_obj_new_int(start);
     } else if (end - start == 1) {
@@ -326,7 +326,7 @@ static mp_obj_t mp_math_factorial_inner(mp_uint_t start, mp_uint_t end) {
         return mp_binary_op(MP_BINARY_OP_MULTIPLY, left, right);
     }
 }
-static mp_obj_t mp_math_factorial(mp_obj_t x_obj) {
+STATIC mp_obj_t mp_math_factorial(mp_obj_t x_obj) {
     mp_int_t max = mp_obj_get_int(x_obj);
     if (max < 0) {
         mp_raise_ValueError(MP_ERROR_TEXT("negative factorial"));
@@ -340,7 +340,7 @@ static mp_obj_t mp_math_factorial(mp_obj_t x_obj) {
 
 // factorial(x): squared difference implementation
 // based on http://www.luschny.de/math/factorial/index.html
-static mp_obj_t mp_math_factorial(mp_obj_t x_obj) {
+STATIC mp_obj_t mp_math_factorial(mp_obj_t x_obj) {
     mp_int_t max = mp_obj_get_int(x_obj);
     if (max < 0) {
         mp_raise_ValueError(MP_ERROR_TEXT("negative factorial"));
@@ -363,11 +363,11 @@ static mp_obj_t mp_math_factorial(mp_obj_t x_obj) {
 
 #endif
 
-static MP_DEFINE_CONST_FUN_OBJ_1(mp_math_factorial_obj, mp_math_factorial);
+STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_math_factorial_obj, mp_math_factorial);
 
 #endif
 
-static const mp_rom_map_elem_t mp_module_math_globals_table[] = {
+STATIC const mp_rom_map_elem_t mp_module_math_globals_table[] = {
     { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_math) },
     { MP_ROM_QSTR(MP_QSTR_e), mp_const_float_e },
     { MP_ROM_QSTR(MP_QSTR_pi), mp_const_float_pi },
@@ -428,7 +428,7 @@ static const mp_rom_map_elem_t mp_module_math_globals_table[] = {
     #endif
 };
 
-static MP_DEFINE_CONST_DICT(mp_module_math_globals, mp_module_math_globals_table);
+STATIC MP_DEFINE_CONST_DICT(mp_module_math_globals, mp_module_math_globals_table);
 
 const mp_obj_module_t mp_module_math = {
     .base = { &mp_type_module },

+ 28 - 28
py/modmicropython.c

@@ -38,7 +38,7 @@
 // living in micropython module
 
 #if MICROPY_ENABLE_COMPILER
-static mp_obj_t mp_micropython_opt_level(size_t n_args, const mp_obj_t *args) {
+STATIC mp_obj_t mp_micropython_opt_level(size_t n_args, const mp_obj_t *args) {
     if (n_args == 0) {
         return MP_OBJ_NEW_SMALL_INT(MP_STATE_VM(mp_optimise_value));
     } else {
@@ -46,26 +46,26 @@ static mp_obj_t mp_micropython_opt_level(size_t n_args, const mp_obj_t *args) {
         return mp_const_none;
     }
 }
-static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_micropython_opt_level_obj, 0, 1, mp_micropython_opt_level);
+STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_micropython_opt_level_obj, 0, 1, mp_micropython_opt_level);
 #endif
 
 #if MICROPY_PY_MICROPYTHON_MEM_INFO
 
 #if MICROPY_MEM_STATS
-static mp_obj_t mp_micropython_mem_total(void) {
+STATIC mp_obj_t mp_micropython_mem_total(void) {
     return MP_OBJ_NEW_SMALL_INT(m_get_total_bytes_allocated());
 }
-static MP_DEFINE_CONST_FUN_OBJ_0(mp_micropython_mem_total_obj, mp_micropython_mem_total);
+STATIC MP_DEFINE_CONST_FUN_OBJ_0(mp_micropython_mem_total_obj, mp_micropython_mem_total);
 
-static mp_obj_t mp_micropython_mem_current(void) {
+STATIC mp_obj_t mp_micropython_mem_current(void) {
     return MP_OBJ_NEW_SMALL_INT(m_get_current_bytes_allocated());
 }
-static MP_DEFINE_CONST_FUN_OBJ_0(mp_micropython_mem_current_obj, mp_micropython_mem_current);
+STATIC MP_DEFINE_CONST_FUN_OBJ_0(mp_micropython_mem_current_obj, mp_micropython_mem_current);
 
-static mp_obj_t mp_micropython_mem_peak(void) {
+STATIC mp_obj_t mp_micropython_mem_peak(void) {
     return MP_OBJ_NEW_SMALL_INT(m_get_peak_bytes_allocated());
 }
-static MP_DEFINE_CONST_FUN_OBJ_0(mp_micropython_mem_peak_obj, mp_micropython_mem_peak);
+STATIC MP_DEFINE_CONST_FUN_OBJ_0(mp_micropython_mem_peak_obj, mp_micropython_mem_peak);
 #endif
 
 mp_obj_t mp_micropython_mem_info(size_t n_args, const mp_obj_t *args) {
@@ -91,9 +91,9 @@ mp_obj_t mp_micropython_mem_info(size_t n_args, const mp_obj_t *args) {
     #endif
     return mp_const_none;
 }
-static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_micropython_mem_info_obj, 0, 1, mp_micropython_mem_info);
+STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_micropython_mem_info_obj, 0, 1, mp_micropython_mem_info);
 
-static mp_obj_t mp_micropython_qstr_info(size_t n_args, const mp_obj_t *args) {
+STATIC mp_obj_t mp_micropython_qstr_info(size_t n_args, const mp_obj_t *args) {
     (void)args;
     size_t n_pool, n_qstr, n_str_data_bytes, n_total_bytes;
     qstr_pool_info(&n_pool, &n_qstr, &n_str_data_bytes, &n_total_bytes);
@@ -105,68 +105,68 @@ static mp_obj_t mp_micropython_qstr_info(size_t n_args, const mp_obj_t *args) {
     }
     return mp_const_none;
 }
-static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_micropython_qstr_info_obj, 0, 1, mp_micropython_qstr_info);
+STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_micropython_qstr_info_obj, 0, 1, mp_micropython_qstr_info);
 
 #endif // MICROPY_PY_MICROPYTHON_MEM_INFO
 
 #if MICROPY_PY_MICROPYTHON_STACK_USE
-static mp_obj_t mp_micropython_stack_use(void) {
+STATIC mp_obj_t mp_micropython_stack_use(void) {
     return MP_OBJ_NEW_SMALL_INT(mp_stack_usage());
 }
-static MP_DEFINE_CONST_FUN_OBJ_0(mp_micropython_stack_use_obj, mp_micropython_stack_use);
+STATIC MP_DEFINE_CONST_FUN_OBJ_0(mp_micropython_stack_use_obj, mp_micropython_stack_use);
 #endif
 
 #if MICROPY_ENABLE_PYSTACK
-static mp_obj_t mp_micropython_pystack_use(void) {
+STATIC mp_obj_t mp_micropython_pystack_use(void) {
     return MP_OBJ_NEW_SMALL_INT(mp_pystack_usage());
 }
-static MP_DEFINE_CONST_FUN_OBJ_0(mp_micropython_pystack_use_obj, mp_micropython_pystack_use);
+STATIC MP_DEFINE_CONST_FUN_OBJ_0(mp_micropython_pystack_use_obj, mp_micropython_pystack_use);
 #endif
 
 #if MICROPY_ENABLE_GC
-static mp_obj_t mp_micropython_heap_lock(void) {
+STATIC mp_obj_t mp_micropython_heap_lock(void) {
     gc_lock();
     return mp_const_none;
 }
-static MP_DEFINE_CONST_FUN_OBJ_0(mp_micropython_heap_lock_obj, mp_micropython_heap_lock);
+STATIC MP_DEFINE_CONST_FUN_OBJ_0(mp_micropython_heap_lock_obj, mp_micropython_heap_lock);
 
-static mp_obj_t mp_micropython_heap_unlock(void) {
+STATIC mp_obj_t mp_micropython_heap_unlock(void) {
     gc_unlock();
     return MP_OBJ_NEW_SMALL_INT(MP_STATE_THREAD(gc_lock_depth));
 }
-static MP_DEFINE_CONST_FUN_OBJ_0(mp_micropython_heap_unlock_obj, mp_micropython_heap_unlock);
+STATIC MP_DEFINE_CONST_FUN_OBJ_0(mp_micropython_heap_unlock_obj, mp_micropython_heap_unlock);
 
 #if MICROPY_PY_MICROPYTHON_HEAP_LOCKED
-static mp_obj_t mp_micropython_heap_locked(void) {
+STATIC mp_obj_t mp_micropython_heap_locked(void) {
     return MP_OBJ_NEW_SMALL_INT(MP_STATE_THREAD(gc_lock_depth));
 }
-static MP_DEFINE_CONST_FUN_OBJ_0(mp_micropython_heap_locked_obj, mp_micropython_heap_locked);
+STATIC MP_DEFINE_CONST_FUN_OBJ_0(mp_micropython_heap_locked_obj, mp_micropython_heap_locked);
 #endif
 #endif
 
 #if MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF && (MICROPY_EMERGENCY_EXCEPTION_BUF_SIZE == 0)
-static MP_DEFINE_CONST_FUN_OBJ_1(mp_alloc_emergency_exception_buf_obj, mp_alloc_emergency_exception_buf);
+STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_alloc_emergency_exception_buf_obj, mp_alloc_emergency_exception_buf);
 #endif
 
 #if MICROPY_KBD_EXCEPTION
-static mp_obj_t mp_micropython_kbd_intr(mp_obj_t int_chr_in) {
+STATIC mp_obj_t mp_micropython_kbd_intr(mp_obj_t int_chr_in) {
     mp_hal_set_interrupt_char(mp_obj_get_int(int_chr_in));
     return mp_const_none;
 }
-static MP_DEFINE_CONST_FUN_OBJ_1(mp_micropython_kbd_intr_obj, mp_micropython_kbd_intr);
+STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_micropython_kbd_intr_obj, mp_micropython_kbd_intr);
 #endif
 
 #if MICROPY_ENABLE_SCHEDULER
-static mp_obj_t mp_micropython_schedule(mp_obj_t function, mp_obj_t arg) {
+STATIC mp_obj_t mp_micropython_schedule(mp_obj_t function, mp_obj_t arg) {
     if (!mp_sched_schedule(function, arg)) {
         mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("schedule queue full"));
     }
     return mp_const_none;
 }
-static MP_DEFINE_CONST_FUN_OBJ_2(mp_micropython_schedule_obj, mp_micropython_schedule);
+STATIC MP_DEFINE_CONST_FUN_OBJ_2(mp_micropython_schedule_obj, mp_micropython_schedule);
 #endif
 
-static const mp_rom_map_elem_t mp_module_micropython_globals_table[] = {
+STATIC const mp_rom_map_elem_t mp_module_micropython_globals_table[] = {
     { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_micropython) },
     { MP_ROM_QSTR(MP_QSTR_const), MP_ROM_PTR(&mp_identity_obj) },
     #if MICROPY_ENABLE_COMPILER
@@ -205,7 +205,7 @@ static const mp_rom_map_elem_t mp_module_micropython_globals_table[] = {
     #endif
 };
 
-static MP_DEFINE_CONST_DICT(mp_module_micropython_globals, mp_module_micropython_globals_table);
+STATIC MP_DEFINE_CONST_DICT(mp_module_micropython_globals, mp_module_micropython_globals_table);
 
 const mp_obj_module_t mp_module_micropython = {
     .base = { &mp_type_module },

+ 10 - 10
py/modstruct.c

@@ -52,7 +52,7 @@
         character data".
  */
 
-static char get_fmt_type(const char **fmt) {
+STATIC char get_fmt_type(const char **fmt) {
     char t = **fmt;
     switch (t) {
         case '!':
@@ -71,7 +71,7 @@ static char get_fmt_type(const char **fmt) {
     return t;
 }
 
-static mp_uint_t get_fmt_num(const char **p) {
+STATIC mp_uint_t get_fmt_num(const char **p) {
     const char *num = *p;
     uint len = 1;
     while (unichar_isdigit(*++num)) {
@@ -82,7 +82,7 @@ static mp_uint_t get_fmt_num(const char **p) {
     return val;
 }
 
-static size_t calc_size_items(const char *fmt, size_t *total_sz) {
+STATIC size_t calc_size_items(const char *fmt, size_t *total_sz) {
     char fmt_type = get_fmt_type(&fmt);
     size_t total_cnt = 0;
     size_t size;
@@ -112,7 +112,7 @@ static size_t calc_size_items(const char *fmt, size_t *total_sz) {
     return total_cnt;
 }
 
-static mp_obj_t struct_calcsize(mp_obj_t fmt_in) {
+STATIC mp_obj_t struct_calcsize(mp_obj_t fmt_in) {
     const char *fmt = mp_obj_str_get_str(fmt_in);
     size_t size;
     calc_size_items(fmt, &size);
@@ -120,7 +120,7 @@ static mp_obj_t struct_calcsize(mp_obj_t fmt_in) {
 }
 MP_DEFINE_CONST_FUN_OBJ_1(struct_calcsize_obj, struct_calcsize);
 
-static mp_obj_t struct_unpack_from(size_t n_args, const mp_obj_t *args) {
+STATIC mp_obj_t struct_unpack_from(size_t n_args, const mp_obj_t *args) {
     // unpack requires that the buffer be exactly the right size.
     // unpack_from requires that the buffer be "big enough".
     // Since we implement unpack and unpack_from using the same function
@@ -180,7 +180,7 @@ static mp_obj_t struct_unpack_from(size_t n_args, const mp_obj_t *args) {
 MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(struct_unpack_from_obj, 2, 3, struct_unpack_from);
 
 // This function assumes there is enough room in p to store all the values
-static void struct_pack_into_internal(mp_obj_t fmt_in, byte *p, size_t n_args, const mp_obj_t *args) {
+STATIC void struct_pack_into_internal(mp_obj_t fmt_in, byte *p, size_t n_args, const mp_obj_t *args) {
     const char *fmt = mp_obj_str_get_str(fmt_in);
     char fmt_type = get_fmt_type(&fmt);
 
@@ -219,7 +219,7 @@ static void struct_pack_into_internal(mp_obj_t fmt_in, byte *p, size_t n_args, c
     }
 }
 
-static mp_obj_t struct_pack(size_t n_args, const mp_obj_t *args) {
+STATIC mp_obj_t struct_pack(size_t n_args, const mp_obj_t *args) {
     // TODO: "The arguments must match the values required by the format exactly."
     mp_int_t size = MP_OBJ_SMALL_INT_VALUE(struct_calcsize(args[0]));
     vstr_t vstr;
@@ -231,7 +231,7 @@ static mp_obj_t struct_pack(size_t n_args, const mp_obj_t *args) {
 }
 MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(struct_pack_obj, 1, MP_OBJ_FUN_ARGS_MAX, struct_pack);
 
-static mp_obj_t struct_pack_into(size_t n_args, const mp_obj_t *args) {
+STATIC mp_obj_t struct_pack_into(size_t n_args, const mp_obj_t *args) {
     mp_buffer_info_t bufinfo;
     mp_get_buffer_raise(args[1], &bufinfo, MP_BUFFER_WRITE);
     mp_int_t offset = mp_obj_get_int(args[2]);
@@ -257,7 +257,7 @@ static mp_obj_t struct_pack_into(size_t n_args, const mp_obj_t *args) {
 }
 MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(struct_pack_into_obj, 3, MP_OBJ_FUN_ARGS_MAX, struct_pack_into);
 
-static const mp_rom_map_elem_t mp_module_struct_globals_table[] = {
+STATIC const mp_rom_map_elem_t mp_module_struct_globals_table[] = {
     { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_struct) },
     { MP_ROM_QSTR(MP_QSTR_calcsize), MP_ROM_PTR(&struct_calcsize_obj) },
     { MP_ROM_QSTR(MP_QSTR_pack), MP_ROM_PTR(&struct_pack_obj) },
@@ -266,7 +266,7 @@ static const mp_rom_map_elem_t mp_module_struct_globals_table[] = {
     { MP_ROM_QSTR(MP_QSTR_unpack_from), MP_ROM_PTR(&struct_unpack_from_obj) },
 };
 
-static MP_DEFINE_CONST_DICT(mp_module_struct_globals, mp_module_struct_globals_table);
+STATIC MP_DEFINE_CONST_DICT(mp_module_struct_globals, mp_module_struct_globals_table);
 
 const mp_obj_module_t mp_module_struct = {
     .base = { &mp_type_module },

+ 19 - 19
py/modsys.c

@@ -56,15 +56,15 @@ const mp_print_t mp_sys_stdout_print = {&mp_sys_stdout_obj, mp_stream_write_adap
 #endif
 
 // version - Python language version that this implementation conforms to, as a string
-static const MP_DEFINE_STR_OBJ(mp_sys_version_obj, "3.4.0; " MICROPY_BANNER_NAME_AND_VERSION);
+STATIC const MP_DEFINE_STR_OBJ(mp_sys_version_obj, "3.4.0; " MICROPY_BANNER_NAME_AND_VERSION);
 
 // version_info - Python language version that this implementation conforms to, as a tuple of ints
 // TODO: CPython is now at 5-element array (major, minor, micro, releaselevel, serial), but save 2 els so far...
-static const mp_rom_obj_tuple_t mp_sys_version_info_obj = {{&mp_type_tuple}, 3, {MP_ROM_INT(3), MP_ROM_INT(4), MP_ROM_INT(0)}};
+STATIC const mp_rom_obj_tuple_t mp_sys_version_info_obj = {{&mp_type_tuple}, 3, {MP_ROM_INT(3), MP_ROM_INT(4), MP_ROM_INT(0)}};
 
 // sys.implementation object
 // this holds the MicroPython version
-static const mp_rom_obj_tuple_t mp_sys_implementation_version_info_obj = {
+STATIC const mp_rom_obj_tuple_t mp_sys_implementation_version_info_obj = {
     {&mp_type_tuple},
     4,
     {
@@ -78,7 +78,7 @@ static const mp_rom_obj_tuple_t mp_sys_implementation_version_info_obj = {
         #endif
     }
 };
-static const MP_DEFINE_STR_OBJ(mp_sys_implementation_machine_obj, MICROPY_BANNER_MACHINE);
+STATIC const MP_DEFINE_STR_OBJ(mp_sys_implementation_machine_obj, MICROPY_BANNER_MACHINE);
 #define SYS_IMPLEMENTATION_ELEMS_BASE \
     MP_ROM_QSTR(MP_QSTR_micropython), \
     MP_ROM_PTR(&mp_sys_implementation_version_info_obj), \
@@ -99,7 +99,7 @@ static const MP_DEFINE_STR_OBJ(mp_sys_implementation_machine_obj, MICROPY_BANNER
 #define SYS_IMPLEMENTATION_ELEMS__V2
 #endif
 
-static const qstr impl_fields[] = {
+STATIC const qstr impl_fields[] = {
     MP_QSTR_name,
     MP_QSTR_version,
     MP_QSTR__machine,
@@ -110,7 +110,7 @@ static const qstr impl_fields[] = {
     MP_QSTR__v2,
     #endif
 };
-static MP_DEFINE_ATTRTUPLE(
+STATIC MP_DEFINE_ATTRTUPLE(
     mp_sys_implementation_obj,
     impl_fields,
     3 + MICROPY_PERSISTENT_CODE_LOAD + MICROPY_PREVIEW_VERSION_2,
@@ -119,7 +119,7 @@ static MP_DEFINE_ATTRTUPLE(
     SYS_IMPLEMENTATION_ELEMS__V2
     );
 #else
-static const mp_rom_obj_tuple_t mp_sys_implementation_obj = {
+STATIC const mp_rom_obj_tuple_t mp_sys_implementation_obj = {
     {&mp_type_tuple},
     3 + MICROPY_PERSISTENT_CODE_LOAD,
     // Do not include SYS_IMPLEMENTATION_ELEMS__V2 because
@@ -138,7 +138,7 @@ static const mp_rom_obj_tuple_t mp_sys_implementation_obj = {
 
 #ifdef MICROPY_PY_SYS_PLATFORM
 // platform - the platform that MicroPython is running on
-static const MP_DEFINE_STR_OBJ(mp_sys_platform_obj, MICROPY_PY_SYS_PLATFORM);
+STATIC const MP_DEFINE_STR_OBJ(mp_sys_platform_obj, MICROPY_PY_SYS_PLATFORM);
 #endif
 
 #ifdef MICROPY_PY_SYS_EXECUTABLE
@@ -152,7 +152,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(mp_sys_intern_obj, mp_obj_str_intern_checked);
 #endif
 
 // exit([retval]): raise SystemExit, with optional argument given to the exception
-static mp_obj_t mp_sys_exit(size_t n_args, const mp_obj_t *args) {
+STATIC mp_obj_t mp_sys_exit(size_t n_args, const mp_obj_t *args) {
     if (n_args == 0) {
         mp_raise_type(&mp_type_SystemExit);
     } else {
@@ -161,7 +161,7 @@ static mp_obj_t mp_sys_exit(size_t n_args, const mp_obj_t *args) {
 }
 MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_sys_exit_obj, 0, 1, mp_sys_exit);
 
-static mp_obj_t mp_sys_print_exception(size_t n_args, const mp_obj_t *args) {
+STATIC mp_obj_t mp_sys_print_exception(size_t n_args, const mp_obj_t *args) {
     #if MICROPY_PY_IO && MICROPY_PY_SYS_STDFILES
     void *stream_obj = &mp_sys_stdout_obj;
     if (n_args > 1) {
@@ -181,7 +181,7 @@ static mp_obj_t mp_sys_print_exception(size_t n_args, const mp_obj_t *args) {
 MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_sys_print_exception_obj, 1, 2, mp_sys_print_exception);
 
 #if MICROPY_PY_SYS_EXC_INFO
-static mp_obj_t mp_sys_exc_info(void) {
+STATIC mp_obj_t mp_sys_exc_info(void) {
     mp_obj_t cur_exc = MP_OBJ_FROM_PTR(MP_STATE_VM(cur_exception));
     mp_obj_tuple_t *t = MP_OBJ_TO_PTR(mp_obj_new_tuple(3, NULL));
 
@@ -201,25 +201,25 @@ MP_DEFINE_CONST_FUN_OBJ_0(mp_sys_exc_info_obj, mp_sys_exc_info);
 #endif
 
 #if MICROPY_PY_SYS_GETSIZEOF
-static mp_obj_t mp_sys_getsizeof(mp_obj_t obj) {
+STATIC mp_obj_t mp_sys_getsizeof(mp_obj_t obj) {
     return mp_unary_op(MP_UNARY_OP_SIZEOF, obj);
 }
-static MP_DEFINE_CONST_FUN_OBJ_1(mp_sys_getsizeof_obj, mp_sys_getsizeof);
+STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_sys_getsizeof_obj, mp_sys_getsizeof);
 #endif
 
 #if MICROPY_PY_SYS_ATEXIT
 // atexit(callback): Callback is called when sys.exit is called.
-static mp_obj_t mp_sys_atexit(mp_obj_t obj) {
+STATIC mp_obj_t mp_sys_atexit(mp_obj_t obj) {
     mp_obj_t old = MP_STATE_VM(sys_exitfunc);
     MP_STATE_VM(sys_exitfunc) = obj;
     return old;
 }
-static MP_DEFINE_CONST_FUN_OBJ_1(mp_sys_atexit_obj, mp_sys_atexit);
+STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_sys_atexit_obj, mp_sys_atexit);
 #endif
 
 #if MICROPY_PY_SYS_SETTRACE
 // settrace(tracefunc): Set the system's trace function.
-static mp_obj_t mp_sys_settrace(mp_obj_t obj) {
+STATIC mp_obj_t mp_sys_settrace(mp_obj_t obj) {
     return mp_prof_settrace(obj);
 }
 MP_DEFINE_CONST_FUN_OBJ_1(mp_sys_settrace_obj, mp_sys_settrace);
@@ -243,7 +243,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(mp_sys_settrace_obj, mp_sys_settrace);
 
 #if MICROPY_PY_SYS_ATTR_DELEGATION
 // Must be kept in sync with the enum at the top of mpstate.h.
-static const uint16_t sys_mutable_keys[] = {
+STATIC const uint16_t sys_mutable_keys[] = {
     #if MICROPY_PY_SYS_PATH
     // Code should access this (as an mp_obj_t) for use with e.g.
     // mp_obj_list_append by using the `mp_sys_path` macro defined in runtime.h.
@@ -266,7 +266,7 @@ void mp_module_sys_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
 }
 #endif
 
-static const mp_rom_map_elem_t mp_module_sys_globals_table[] = {
+STATIC const mp_rom_map_elem_t mp_module_sys_globals_table[] = {
     { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_sys) },
 
     #if MICROPY_PY_SYS_ARGV
@@ -339,7 +339,7 @@ static const mp_rom_map_elem_t mp_module_sys_globals_table[] = {
     #endif
 };
 
-static MP_DEFINE_CONST_DICT(mp_module_sys_globals, mp_module_sys_globals_table);
+STATIC MP_DEFINE_CONST_DICT(mp_module_sys_globals, mp_module_sys_globals_table);
 
 const mp_obj_module_t mp_module_sys = {
     .base = { &mp_type_module },

+ 41 - 28
py/modthread.c

@@ -45,7 +45,7 @@
 /****************************************************************/
 // Lock object
 
-static const mp_obj_type_t mp_type_thread_lock;
+STATIC const mp_obj_type_t mp_type_thread_lock;
 
 typedef struct _mp_obj_thread_lock_t {
     mp_obj_base_t base;
@@ -53,14 +53,14 @@ typedef struct _mp_obj_thread_lock_t {
     volatile bool locked;
 } mp_obj_thread_lock_t;
 
-static mp_obj_thread_lock_t *mp_obj_new_thread_lock(void) {
+STATIC mp_obj_thread_lock_t *mp_obj_new_thread_lock(void) {
     mp_obj_thread_lock_t *self = mp_obj_malloc(mp_obj_thread_lock_t, &mp_type_thread_lock);
     mp_thread_mutex_init(&self->mutex);
     self->locked = false;
     return self;
 }
 
-static mp_obj_t thread_lock_acquire(size_t n_args, const mp_obj_t *args) {
+STATIC mp_obj_t thread_lock_acquire(size_t n_args, const mp_obj_t *args) {
     mp_obj_thread_lock_t *self = MP_OBJ_TO_PTR(args[0]);
     bool wait = true;
     if (n_args > 1) {
@@ -79,9 +79,9 @@ static mp_obj_t thread_lock_acquire(size_t n_args, const mp_obj_t *args) {
         mp_raise_OSError(-ret);
     }
 }
-static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(thread_lock_acquire_obj, 1, 3, thread_lock_acquire);
+STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(thread_lock_acquire_obj, 1, 3, thread_lock_acquire);
 
-static mp_obj_t thread_lock_release(mp_obj_t self_in) {
+STATIC mp_obj_t thread_lock_release(mp_obj_t self_in) {
     mp_obj_thread_lock_t *self = MP_OBJ_TO_PTR(self_in);
     if (!self->locked) {
         mp_raise_msg(&mp_type_RuntimeError, NULL);
@@ -92,21 +92,21 @@ static mp_obj_t thread_lock_release(mp_obj_t self_in) {
     MP_THREAD_GIL_ENTER();
     return mp_const_none;
 }
-static MP_DEFINE_CONST_FUN_OBJ_1(thread_lock_release_obj, thread_lock_release);
+STATIC MP_DEFINE_CONST_FUN_OBJ_1(thread_lock_release_obj, thread_lock_release);
 
-static mp_obj_t thread_lock_locked(mp_obj_t self_in) {
+STATIC mp_obj_t thread_lock_locked(mp_obj_t self_in) {
     mp_obj_thread_lock_t *self = MP_OBJ_TO_PTR(self_in);
     return mp_obj_new_bool(self->locked);
 }
-static MP_DEFINE_CONST_FUN_OBJ_1(thread_lock_locked_obj, thread_lock_locked);
+STATIC MP_DEFINE_CONST_FUN_OBJ_1(thread_lock_locked_obj, thread_lock_locked);
 
-static mp_obj_t thread_lock___exit__(size_t n_args, const mp_obj_t *args) {
+STATIC mp_obj_t thread_lock___exit__(size_t n_args, const mp_obj_t *args) {
     (void)n_args; // unused
     return thread_lock_release(args[0]);
 }
-static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(thread_lock___exit___obj, 4, 4, thread_lock___exit__);
+STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(thread_lock___exit___obj, 4, 4, thread_lock___exit__);
 
-static const mp_rom_map_elem_t thread_lock_locals_dict_table[] = {
+STATIC const mp_rom_map_elem_t thread_lock_locals_dict_table[] = {
     { MP_ROM_QSTR(MP_QSTR_acquire), MP_ROM_PTR(&thread_lock_acquire_obj) },
     { MP_ROM_QSTR(MP_QSTR_release), MP_ROM_PTR(&thread_lock_release_obj) },
     { MP_ROM_QSTR(MP_QSTR_locked), MP_ROM_PTR(&thread_lock_locked_obj) },
@@ -114,9 +114,9 @@ static const mp_rom_map_elem_t thread_lock_locals_dict_table[] = {
     { MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&thread_lock___exit___obj) },
 };
 
-static MP_DEFINE_CONST_DICT(thread_lock_locals_dict, thread_lock_locals_dict_table);
+STATIC MP_DEFINE_CONST_DICT(thread_lock_locals_dict, thread_lock_locals_dict_table);
 
-static MP_DEFINE_CONST_OBJ_TYPE(
+STATIC MP_DEFINE_CONST_OBJ_TYPE(
     mp_type_thread_lock,
     MP_QSTR_lock,
     MP_TYPE_FLAG_NONE,
@@ -126,14 +126,14 @@ static MP_DEFINE_CONST_OBJ_TYPE(
 /****************************************************************/
 // _thread module
 
-static size_t thread_stack_size = 0;
+STATIC size_t thread_stack_size = 0;
 
-static mp_obj_t mod_thread_get_ident(void) {
+STATIC mp_obj_t mod_thread_get_ident(void) {
     return mp_obj_new_int_from_uint(mp_thread_get_id());
 }
-static MP_DEFINE_CONST_FUN_OBJ_0(mod_thread_get_ident_obj, mod_thread_get_ident);
+STATIC MP_DEFINE_CONST_FUN_OBJ_0(mod_thread_get_ident_obj, mod_thread_get_ident);
 
-static mp_obj_t mod_thread_stack_size(size_t n_args, const mp_obj_t *args) {
+STATIC mp_obj_t mod_thread_stack_size(size_t n_args, const mp_obj_t *args) {
     mp_obj_t ret = mp_obj_new_int_from_uint(thread_stack_size);
     if (n_args == 0) {
         thread_stack_size = 0;
@@ -142,7 +142,7 @@ static mp_obj_t mod_thread_stack_size(size_t n_args, const mp_obj_t *args) {
     }
     return ret;
 }
-static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_thread_stack_size_obj, 0, 1, mod_thread_stack_size);
+STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_thread_stack_size_obj, 0, 1, mod_thread_stack_size);
 
 typedef struct _thread_entry_args_t {
     mp_obj_dict_t *dict_locals;
@@ -154,13 +154,16 @@ typedef struct _thread_entry_args_t {
     mp_obj_t args[];
 } thread_entry_args_t;
 
-static void *thread_entry(void *args_in) {
+STATIC void *thread_entry(void *args_in) {
     // Execution begins here for a new thread.  We do not have the GIL.
 
     thread_entry_args_t *args = (thread_entry_args_t *)args_in;
 
     mp_state_thread_t ts;
-    mp_thread_init_state(&ts, args->stack_size, args->dict_locals, args->dict_globals);
+    mp_thread_set_state(&ts);
+
+    mp_stack_set_top(&ts + 1); // need to include ts in root-pointer scan
+    mp_stack_set_limit(args->stack_size);
 
     #if MICROPY_ENABLE_PYSTACK
     // TODO threading and pystack is not fully supported, for now just make a small stack
@@ -168,6 +171,16 @@ static void *thread_entry(void *args_in) {
     mp_pystack_init(mini_pystack, &mini_pystack[128]);
     #endif
 
+    // The GC starts off unlocked on this thread.
+    ts.gc_lock_depth = 0;
+
+    ts.nlr_jump_callback_top = NULL;
+    ts.mp_pending_exception = MP_OBJ_NULL;
+
+    // set locals and globals from the calling context
+    mp_locals_set(args->dict_locals);
+    mp_globals_set(args->dict_globals);
+
     MP_THREAD_GIL_ENTER();
 
     // signal that we are set up and running
@@ -207,7 +220,7 @@ static void *thread_entry(void *args_in) {
     return NULL;
 }
 
-static mp_obj_t mod_thread_start_new_thread(size_t n_args, const mp_obj_t *args) {
+STATIC mp_obj_t mod_thread_start_new_thread(size_t n_args, const mp_obj_t *args) {
     // This structure holds the Python function and arguments for thread entry.
     // We copy all arguments into this structure to keep ownership of them.
     // We must be very careful about root pointers because this pointer may
@@ -258,19 +271,19 @@ static mp_obj_t mod_thread_start_new_thread(size_t n_args, const mp_obj_t *args)
     // spawn the thread!
     return mp_obj_new_int_from_uint(mp_thread_create(thread_entry, th_args, &th_args->stack_size));
 }
-static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_thread_start_new_thread_obj, 2, 3, mod_thread_start_new_thread);
+STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_thread_start_new_thread_obj, 2, 3, mod_thread_start_new_thread);
 
-static mp_obj_t mod_thread_exit(void) {
+STATIC mp_obj_t mod_thread_exit(void) {
     mp_raise_type(&mp_type_SystemExit);
 }
-static MP_DEFINE_CONST_FUN_OBJ_0(mod_thread_exit_obj, mod_thread_exit);
+STATIC MP_DEFINE_CONST_FUN_OBJ_0(mod_thread_exit_obj, mod_thread_exit);
 
-static mp_obj_t mod_thread_allocate_lock(void) {
+STATIC mp_obj_t mod_thread_allocate_lock(void) {
     return MP_OBJ_FROM_PTR(mp_obj_new_thread_lock());
 }
-static MP_DEFINE_CONST_FUN_OBJ_0(mod_thread_allocate_lock_obj, mod_thread_allocate_lock);
+STATIC MP_DEFINE_CONST_FUN_OBJ_0(mod_thread_allocate_lock_obj, mod_thread_allocate_lock);
 
-static const mp_rom_map_elem_t mp_module_thread_globals_table[] = {
+STATIC const mp_rom_map_elem_t mp_module_thread_globals_table[] = {
     { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR__thread) },
     { MP_ROM_QSTR(MP_QSTR_LockType), MP_ROM_PTR(&mp_type_thread_lock) },
     { MP_ROM_QSTR(MP_QSTR_get_ident), MP_ROM_PTR(&mod_thread_get_ident_obj) },
@@ -280,7 +293,7 @@ static const mp_rom_map_elem_t mp_module_thread_globals_table[] = {
     { MP_ROM_QSTR(MP_QSTR_allocate_lock), MP_ROM_PTR(&mod_thread_allocate_lock_obj) },
 };
 
-static MP_DEFINE_CONST_DICT(mp_module_thread_globals, mp_module_thread_globals_table);
+STATIC MP_DEFINE_CONST_DICT(mp_module_thread_globals, mp_module_thread_globals_table);
 
 const mp_obj_module_t mp_module_thread = {
     .base = { &mp_type_module },

+ 11 - 51
py/mpconfig.h

@@ -30,9 +30,9 @@
 // as well as a fallback to generate MICROPY_GIT_TAG if the git repo or tags
 // are unavailable.
 #define MICROPY_VERSION_MAJOR 1
-#define MICROPY_VERSION_MINOR 23
-#define MICROPY_VERSION_MICRO 0
-#define MICROPY_VERSION_PRERELEASE 1
+#define MICROPY_VERSION_MINOR 22
+#define MICROPY_VERSION_MICRO 2
+#define MICROPY_VERSION_PRERELEASE 0
 
 // Combined version as a 32-bit number for convenience to allow version
 // comparison. Doesn't include prerelease state.
@@ -290,12 +290,10 @@
 
 // Number of bytes used to store qstr hash
 #ifndef MICROPY_QSTR_BYTES_IN_HASH
-#if MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES
+#if MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES
 #define MICROPY_QSTR_BYTES_IN_HASH (2)
-#elif MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES
-#define MICROPY_QSTR_BYTES_IN_HASH (1)
 #else
-#define MICROPY_QSTR_BYTES_IN_HASH (0)
+#define MICROPY_QSTR_BYTES_IN_HASH (1)
 #endif
 #endif
 
@@ -446,11 +444,6 @@
 #define MICROPY_DYNAMIC_COMPILER (0)
 #endif
 
-// Whether the compiler allows compiling top-level await expressions
-#ifndef MICROPY_COMP_ALLOW_TOP_LEVEL_AWAIT
-#define MICROPY_COMP_ALLOW_TOP_LEVEL_AWAIT (0)
-#endif
-
 // Whether to enable constant folding; eg 1+2 rewritten as 3
 #ifndef MICROPY_COMP_CONST_FOLDING
 #define MICROPY_COMP_CONST_FOLDING (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
@@ -835,15 +828,6 @@ typedef double mp_float_t;
 #define MICROPY_PY_BUILTINS_COMPLEX (MICROPY_PY_BUILTINS_FLOAT)
 #endif
 
-// Whether to use the native _Float16 for 16-bit float support
-#ifndef MICROPY_FLOAT_USE_NATIVE_FLT16
-#ifdef __FLT16_MAX__
-#define MICROPY_FLOAT_USE_NATIVE_FLT16 (1)
-#else
-#define MICROPY_FLOAT_USE_NATIVE_FLT16 (0)
-#endif
-#endif
-
 // Whether to provide a high-quality hash for float and complex numbers.
 // Otherwise the default is a very simple but correct hashing function.
 #ifndef MICROPY_FLOAT_HIGH_QUALITY_HASH
@@ -1317,16 +1301,6 @@ typedef double mp_float_t;
 #define MICROPY_PY_COLLECTIONS_DEQUE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
 #endif
 
-// Whether "collections.deque" supports iteration
-#ifndef MICROPY_PY_COLLECTIONS_DEQUE_ITER
-#define MICROPY_PY_COLLECTIONS_DEQUE_ITER (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
-#endif
-
-// Whether "collections.deque" supports subscription
-#ifndef MICROPY_PY_COLLECTIONS_DEQUE_SUBSCR
-#define MICROPY_PY_COLLECTIONS_DEQUE_SUBSCR (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
-#endif
-
 // Whether to provide "collections.OrderedDict" type
 #ifndef MICROPY_PY_COLLECTIONS_ORDEREDDICT
 #define MICROPY_PY_COLLECTIONS_ORDEREDDICT (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
@@ -1716,11 +1690,6 @@ typedef double mp_float_t;
 #define MICROPY_PY_MACHINE (0)
 #endif
 
-// Whether to include: reset, reset_cause
-#ifndef MICROPY_PY_MACHINE_RESET
-#define MICROPY_PY_MACHINE_RESET (0)
-#endif
-
 // Whether to include: bitstream
 #ifndef MICROPY_PY_MACHINE_BITSTREAM
 #define MICROPY_PY_MACHINE_BITSTREAM (0)
@@ -1731,16 +1700,6 @@ typedef double mp_float_t;
 #define MICROPY_PY_MACHINE_PULSE (0)
 #endif
 
-// Whether to provide the "machine.mem8/16/32" objects
-#ifndef MICROPY_PY_MACHINE_MEMX
-#define MICROPY_PY_MACHINE_MEMX (MICROPY_PY_MACHINE)
-#endif
-
-// Whether to provide the "machine.Signal" class
-#ifndef MICROPY_PY_MACHINE_SIGNAL
-#define MICROPY_PY_MACHINE_SIGNAL (MICROPY_PY_MACHINE)
-#endif
-
 #ifndef MICROPY_PY_MACHINE_I2C
 #define MICROPY_PY_MACHINE_I2C (0)
 #endif
@@ -1783,11 +1742,6 @@ typedef double mp_float_t;
 #define MICROPY_PY_SSL_FINALISER (MICROPY_ENABLE_FINALISER)
 #endif
 
-// Whether to provide the "vfs" module
-#ifndef MICROPY_PY_VFS
-#define MICROPY_PY_VFS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES && MICROPY_VFS)
-#endif
-
 #ifndef MICROPY_PY_WEBSOCKET
 #define MICROPY_PY_WEBSOCKET (0)
 #endif
@@ -1901,6 +1855,12 @@ typedef double mp_float_t;
 #endif
 #endif
 
+// Allow to override static modifier for global objects, e.g. to use with
+// object code analysis tools which don't support static symbols.
+#ifndef STATIC
+#define STATIC static
+#endif
+
 // Number of bytes in an object word: mp_obj_t, mp_uint_t, mp_uint_t
 #ifndef MP_BYTES_PER_OBJ_WORD
 #define MP_BYTES_PER_OBJ_WORD (sizeof(mp_uint_t))

+ 2 - 2
py/mpprint.c

@@ -43,7 +43,7 @@
 static const char pad_spaces[] = "                ";
 static const char pad_zeroes[] = "0000000000000000";
 
-static void plat_print_strn(void *env, const char *str, size_t len) {
+STATIC void plat_print_strn(void *env, const char *str, size_t len) {
     (void)env;
     MP_PLAT_PRINT_STRN(str, len);
 }
@@ -127,7 +127,7 @@ int mp_print_strn(const mp_print_t *print, const char *str, size_t len, int flag
 
 // This function is used exclusively by mp_vprintf to format ints.
 // It needs to be a separate function to mp_print_mp_int, since converting to a mp_int looses the MSB.
-static int mp_print_int(const mp_print_t *print, mp_uint_t x, int sgn, int base, int base_char, int flags, char fill, int width) {
+STATIC int mp_print_int(const mp_print_t *print, mp_uint_t x, int sgn, int base, int base_char, int flags, char fill, int width) {
     char sign = 0;
     if (sgn) {
         if ((mp_int_t)x < 0) {

+ 1 - 0
py/mpstate.h

@@ -310,6 +310,7 @@ extern mp_state_ctx_t mp_state_ctx;
 #define MP_STATE_MAIN_THREAD(x) (mp_state_ctx.thread.x)
 
 #if MICROPY_PY_THREAD
+extern mp_state_thread_t *mp_thread_get_state(void);
 #define MP_STATE_THREAD(x) (mp_thread_get_state()->x)
 #define mp_thread_is_main_thread() (mp_thread_get_state() == &mp_state_ctx.thread)
 #else

+ 19 - 19
py/mpz.c

@@ -49,7 +49,7 @@
  Definition of normalise: ?
 */
 
-static size_t mpn_remove_trailing_zeros(mpz_dig_t *oidig, mpz_dig_t *idig) {
+STATIC size_t mpn_remove_trailing_zeros(mpz_dig_t *oidig, mpz_dig_t *idig) {
     for (--idig; idig >= oidig && *idig == 0; --idig) {
     }
     return idig + 1 - oidig;
@@ -59,7 +59,7 @@ static size_t mpn_remove_trailing_zeros(mpz_dig_t *oidig, mpz_dig_t *idig) {
    returns sign(i - j)
    assumes i, j are normalised
 */
-static int mpn_cmp(const mpz_dig_t *idig, size_t ilen, const mpz_dig_t *jdig, size_t jlen) {
+STATIC int mpn_cmp(const mpz_dig_t *idig, size_t ilen, const mpz_dig_t *jdig, size_t jlen) {
     if (ilen < jlen) {
         return -1;
     }
@@ -85,7 +85,7 @@ static int mpn_cmp(const mpz_dig_t *idig, size_t ilen, const mpz_dig_t *jdig, si
    assumes enough memory in i; assumes normalised j; assumes n > 0
    can have i, j pointing to same memory
 */
-static size_t mpn_shl(mpz_dig_t *idig, mpz_dig_t *jdig, size_t jlen, mp_uint_t n) {
+STATIC size_t mpn_shl(mpz_dig_t *idig, mpz_dig_t *jdig, size_t jlen, mp_uint_t n) {
     mp_uint_t n_whole = (n + DIG_SIZE - 1) / DIG_SIZE;
     mp_uint_t n_part = n % DIG_SIZE;
     if (n_part == 0) {
@@ -124,7 +124,7 @@ static size_t mpn_shl(mpz_dig_t *idig, mpz_dig_t *jdig, size_t jlen, mp_uint_t n
    assumes enough memory in i; assumes normalised j; assumes n > 0
    can have i, j pointing to same memory
 */
-static size_t mpn_shr(mpz_dig_t *idig, mpz_dig_t *jdig, size_t jlen, mp_uint_t n) {
+STATIC size_t mpn_shr(mpz_dig_t *idig, mpz_dig_t *jdig, size_t jlen, mp_uint_t n) {
     mp_uint_t n_whole = n / DIG_SIZE;
     mp_uint_t n_part = n % DIG_SIZE;
 
@@ -156,7 +156,7 @@ static size_t mpn_shr(mpz_dig_t *idig, mpz_dig_t *jdig, size_t jlen, mp_uint_t n
    assumes enough memory in i; assumes normalised j, k; assumes jlen >= klen
    can have i, j, k pointing to same memory
 */
-static size_t mpn_add(mpz_dig_t *idig, const mpz_dig_t *jdig, size_t jlen, const mpz_dig_t *kdig, size_t klen) {
+STATIC size_t mpn_add(mpz_dig_t *idig, const mpz_dig_t *jdig, size_t jlen, const mpz_dig_t *kdig, size_t klen) {
     mpz_dig_t *oidig = idig;
     mpz_dbl_dig_t carry = 0;
 
@@ -186,7 +186,7 @@ static size_t mpn_add(mpz_dig_t *idig, const mpz_dig_t *jdig, size_t jlen, const
    assumes enough memory in i; assumes normalised j, k; assumes j >= k
    can have i, j, k pointing to same memory
 */
-static size_t mpn_sub(mpz_dig_t *idig, const mpz_dig_t *jdig, size_t jlen, const mpz_dig_t *kdig, size_t klen) {
+STATIC size_t mpn_sub(mpz_dig_t *idig, const mpz_dig_t *jdig, size_t jlen, const mpz_dig_t *kdig, size_t klen) {
     mpz_dig_t *oidig = idig;
     mpz_dbl_dig_signed_t borrow = 0;
 
@@ -214,7 +214,7 @@ static size_t mpn_sub(mpz_dig_t *idig, const mpz_dig_t *jdig, size_t jlen, const
    assumes enough memory in i; assumes normalised j, k; assumes jlen >= klen (jlen argument not needed)
    can have i, j, k pointing to same memory
 */
-static size_t mpn_and(mpz_dig_t *idig, const mpz_dig_t *jdig, const mpz_dig_t *kdig, size_t klen) {
+STATIC size_t mpn_and(mpz_dig_t *idig, const mpz_dig_t *jdig, const mpz_dig_t *kdig, size_t klen) {
     mpz_dig_t *oidig = idig;
 
     for (; klen > 0; --klen, ++idig, ++jdig, ++kdig) {
@@ -235,7 +235,7 @@ static size_t mpn_and(mpz_dig_t *idig, const mpz_dig_t *jdig, const mpz_dig_t *k
    assumes enough memory in i; assumes normalised j, k; assumes length j >= length k
    can have i, j, k pointing to same memory
 */
-static size_t mpn_and_neg(mpz_dig_t *idig, const mpz_dig_t *jdig, size_t jlen, const mpz_dig_t *kdig, size_t klen,
+STATIC size_t mpn_and_neg(mpz_dig_t *idig, const mpz_dig_t *jdig, size_t jlen, const mpz_dig_t *kdig, size_t klen,
     mpz_dbl_dig_t carryi, mpz_dbl_dig_t carryj, mpz_dbl_dig_t carryk) {
     mpz_dig_t *oidig = idig;
     mpz_dig_t imask = (0 == carryi) ? 0 : DIG_MASK;
@@ -266,7 +266,7 @@ static size_t mpn_and_neg(mpz_dig_t *idig, const mpz_dig_t *jdig, size_t jlen, c
    assumes enough memory in i; assumes normalised j, k; assumes jlen >= klen
    can have i, j, k pointing to same memory
 */
-static size_t mpn_or(mpz_dig_t *idig, const mpz_dig_t *jdig, size_t jlen, const mpz_dig_t *kdig, size_t klen) {
+STATIC size_t mpn_or(mpz_dig_t *idig, const mpz_dig_t *jdig, size_t jlen, const mpz_dig_t *kdig, size_t klen) {
     mpz_dig_t *oidig = idig;
 
     jlen -= klen;
@@ -296,7 +296,7 @@ static size_t mpn_or(mpz_dig_t *idig, const mpz_dig_t *jdig, size_t jlen, const
 
 #if MICROPY_OPT_MPZ_BITWISE
 
-static size_t mpn_or_neg(mpz_dig_t *idig, const mpz_dig_t *jdig, size_t jlen, const mpz_dig_t *kdig, size_t klen,
+STATIC size_t mpn_or_neg(mpz_dig_t *idig, const mpz_dig_t *jdig, size_t jlen, const mpz_dig_t *kdig, size_t klen,
     mpz_dbl_dig_t carryj, mpz_dbl_dig_t carryk) {
     mpz_dig_t *oidig = idig;
     mpz_dbl_dig_t carryi = 1;
@@ -326,7 +326,7 @@ static size_t mpn_or_neg(mpz_dig_t *idig, const mpz_dig_t *jdig, size_t jlen, co
 
 #else
 
-static size_t mpn_or_neg(mpz_dig_t *idig, const mpz_dig_t *jdig, size_t jlen, const mpz_dig_t *kdig, size_t klen,
+STATIC size_t mpn_or_neg(mpz_dig_t *idig, const mpz_dig_t *jdig, size_t jlen, const mpz_dig_t *kdig, size_t klen,
     mpz_dbl_dig_t carryi, mpz_dbl_dig_t carryj, mpz_dbl_dig_t carryk) {
     mpz_dig_t *oidig = idig;
     mpz_dig_t imask = (0 == carryi) ? 0 : DIG_MASK;
@@ -358,7 +358,7 @@ static size_t mpn_or_neg(mpz_dig_t *idig, const mpz_dig_t *jdig, size_t jlen, co
    assumes enough memory in i; assumes normalised j, k; assumes jlen >= klen
    can have i, j, k pointing to same memory
 */
-static size_t mpn_xor(mpz_dig_t *idig, const mpz_dig_t *jdig, size_t jlen, const mpz_dig_t *kdig, size_t klen) {
+STATIC size_t mpn_xor(mpz_dig_t *idig, const mpz_dig_t *jdig, size_t jlen, const mpz_dig_t *kdig, size_t klen) {
     mpz_dig_t *oidig = idig;
 
     jlen -= klen;
@@ -385,7 +385,7 @@ static size_t mpn_xor(mpz_dig_t *idig, const mpz_dig_t *jdig, size_t jlen, const
    assumes enough memory in i; assumes normalised j, k; assumes length j >= length k
    can have i, j, k pointing to same memory
 */
-static size_t mpn_xor_neg(mpz_dig_t *idig, const mpz_dig_t *jdig, size_t jlen, const mpz_dig_t *kdig, size_t klen,
+STATIC size_t mpn_xor_neg(mpz_dig_t *idig, const mpz_dig_t *jdig, size_t jlen, const mpz_dig_t *kdig, size_t klen,
     mpz_dbl_dig_t carryi, mpz_dbl_dig_t carryj, mpz_dbl_dig_t carryk) {
     mpz_dig_t *oidig = idig;
 
@@ -410,7 +410,7 @@ static size_t mpn_xor_neg(mpz_dig_t *idig, const mpz_dig_t *jdig, size_t jlen, c
    returns number of digits in i
    assumes enough memory in i; assumes normalised i; assumes dmul != 0
 */
-static size_t mpn_mul_dig_add_dig(mpz_dig_t *idig, size_t ilen, mpz_dig_t dmul, mpz_dig_t dadd) {
+STATIC size_t mpn_mul_dig_add_dig(mpz_dig_t *idig, size_t ilen, mpz_dig_t dmul, mpz_dig_t dadd) {
     mpz_dig_t *oidig = idig;
     mpz_dbl_dig_t carry = dadd;
 
@@ -432,7 +432,7 @@ static size_t mpn_mul_dig_add_dig(mpz_dig_t *idig, size_t ilen, mpz_dig_t dmul,
    assumes enough memory in i; assumes i is zeroed; assumes normalised j, k
    can have j, k point to same memory
 */
-static size_t mpn_mul(mpz_dig_t *idig, mpz_dig_t *jdig, size_t jlen, mpz_dig_t *kdig, size_t klen) {
+STATIC size_t mpn_mul(mpz_dig_t *idig, mpz_dig_t *jdig, size_t jlen, mpz_dig_t *kdig, size_t klen) {
     mpz_dig_t *oidig = idig;
     size_t ilen = 0;
 
@@ -463,7 +463,7 @@ static size_t mpn_mul(mpz_dig_t *idig, mpz_dig_t *jdig, size_t jlen, mpz_dig_t *
    assumes quo_dig has enough memory (as many digits as num)
    assumes quo_dig is filled with zeros
 */
-static void mpn_div(mpz_dig_t *num_dig, size_t *num_len, const mpz_dig_t *den_dig, size_t den_len, mpz_dig_t *quo_dig, size_t *quo_len) {
+STATIC void mpn_div(mpz_dig_t *num_dig, size_t *num_len, const mpz_dig_t *den_dig, size_t den_len, mpz_dig_t *quo_dig, size_t *quo_len) {
     mpz_dig_t *orig_num_dig = num_dig;
     mpz_dig_t *orig_quo_dig = quo_dig;
     mpz_dig_t norm_shift = 0;
@@ -668,14 +668,14 @@ mpz_t *mpz_from_str(const char *str, size_t len, bool neg, unsigned int base) {
 }
 #endif
 
-static void mpz_free(mpz_t *z) {
+STATIC void mpz_free(mpz_t *z) {
     if (z != NULL) {
         m_del(mpz_dig_t, z->dig, z->alloc);
         m_del_obj(mpz_t, z);
     }
 }
 
-static void mpz_need_dig(mpz_t *z, size_t need) {
+STATIC void mpz_need_dig(mpz_t *z, size_t need) {
     if (need < MIN_ALLOC) {
         need = MIN_ALLOC;
     }
@@ -689,7 +689,7 @@ static void mpz_need_dig(mpz_t *z, size_t need) {
     }
 }
 
-static mpz_t *mpz_clone(const mpz_t *src) {
+STATIC mpz_t *mpz_clone(const mpz_t *src) {
     assert(src->alloc != 0);
     mpz_t *z = m_new_obj(mpz_t);
     z->neg = src->neg;

+ 11 - 15
py/nativeglue.c

@@ -29,7 +29,6 @@
 #include <string.h>
 #include <assert.h>
 
-#include "py/binary.h"
 #include "py/runtime.h"
 #include "py/smallint.h"
 #include "py/nativeglue.h"
@@ -140,7 +139,7 @@ mp_obj_t mp_obj_new_slice(mp_obj_t ostart, mp_obj_t ostop, mp_obj_t ostep) {
 }
 #endif
 
-static mp_obj_dict_t *mp_native_swap_globals(mp_obj_dict_t *new_globals) {
+STATIC mp_obj_dict_t *mp_native_swap_globals(mp_obj_dict_t *new_globals) {
     if (new_globals == NULL) {
         // Globals were the originally the same so don't restore them
         return NULL;
@@ -156,20 +155,20 @@ static mp_obj_dict_t *mp_native_swap_globals(mp_obj_dict_t *new_globals) {
 
 // wrapper that accepts n_args and n_kw in one argument
 // (native emitter can only pass at most 3 arguments to a function)
-static mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args) {
+STATIC mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args) {
     return mp_call_function_n_kw(fun_in, n_args_kw & 0xff, (n_args_kw >> 8) & 0xff, args);
 }
 
 // wrapper that makes raise obj and raises it
 // END_FINALLY opcode requires that we don't raise if o==None
-static void mp_native_raise(mp_obj_t o) {
+STATIC void mp_native_raise(mp_obj_t o) {
     if (o != MP_OBJ_NULL && o != mp_const_none) {
         nlr_raise(mp_make_raise_obj(o));
     }
 }
 
 // wrapper that handles iterator buffer
-static mp_obj_t mp_native_getiter(mp_obj_t obj, mp_obj_iter_buf_t *iter) {
+STATIC mp_obj_t mp_native_getiter(mp_obj_t obj, mp_obj_iter_buf_t *iter) {
     if (iter == NULL) {
         return mp_getiter(obj, NULL);
     } else {
@@ -184,7 +183,7 @@ static mp_obj_t mp_native_getiter(mp_obj_t obj, mp_obj_iter_buf_t *iter) {
 }
 
 // wrapper that handles iterator buffer
-static mp_obj_t mp_native_iternext(mp_obj_iter_buf_t *iter) {
+STATIC mp_obj_t mp_native_iternext(mp_obj_iter_buf_t *iter) {
     mp_obj_t obj;
     if (iter->base.type == MP_OBJ_NULL) {
         obj = iter->buf[0];
@@ -194,7 +193,7 @@ static mp_obj_t mp_native_iternext(mp_obj_iter_buf_t *iter) {
     return mp_iternext(obj);
 }
 
-static bool mp_native_yield_from(mp_obj_t gen, mp_obj_t send_value, mp_obj_t *ret_value) {
+STATIC bool mp_native_yield_from(mp_obj_t gen, mp_obj_t send_value, mp_obj_t *ret_value) {
     mp_vm_return_kind_t ret_kind;
     nlr_buf_t nlr_buf;
     mp_obj_t throw_value = *ret_value;
@@ -232,22 +231,22 @@ static bool mp_native_yield_from(mp_obj_t gen, mp_obj_t send_value, mp_obj_t *re
 
 #if !MICROPY_PY_BUILTINS_FLOAT
 
-static mp_obj_t mp_obj_new_float_from_f(float f) {
+STATIC mp_obj_t mp_obj_new_float_from_f(float f) {
     (void)f;
     mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("float unsupported"));
 }
 
-static mp_obj_t mp_obj_new_float_from_d(double d) {
+STATIC mp_obj_t mp_obj_new_float_from_d(double d) {
     (void)d;
     mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("float unsupported"));
 }
 
-static float mp_obj_get_float_to_f(mp_obj_t o) {
+STATIC float mp_obj_get_float_to_f(mp_obj_t o) {
     (void)o;
     mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("float unsupported"));
 }
 
-static double mp_obj_get_float_to_d(mp_obj_t o) {
+STATIC double mp_obj_get_float_to_d(mp_obj_t o) {
     (void)o;
     mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("float unsupported"));
 }
@@ -282,7 +281,7 @@ const mp_fun_table_t mp_fun_table = {
     mp_obj_set_store,
     mp_obj_list_append,
     mp_obj_dict_store,
-    mp_make_function_from_proto_fun,
+    mp_make_function_from_raw_code,
     mp_native_call_function_n_kw,
     mp_call_method_n_kw,
     mp_call_method_n_kw_var,
@@ -331,9 +330,6 @@ const mp_fun_table_t mp_fun_table = {
     mp_obj_get_float_to_d,
     mp_get_buffer,
     mp_get_stream_raise,
-    mp_binary_get_size,
-    mp_binary_get_val_array,
-    mp_binary_set_val_array,
     &mp_plat_print,
     &mp_type_type,
     &mp_type_str,

+ 2 - 7
py/nativeglue.h

@@ -58,7 +58,7 @@ typedef enum {
     MP_F_STORE_SET,
     MP_F_LIST_APPEND,
     MP_F_STORE_MAP,
-    MP_F_MAKE_FUNCTION_FROM_PROTO_FUN,
+    MP_F_MAKE_FUNCTION_FROM_RAW_CODE,
     MP_F_NATIVE_CALL_FUNCTION_N_KW,
     MP_F_CALL_METHOD_N_KW,
     MP_F_CALL_METHOD_N_KW_VAR,
@@ -112,7 +112,7 @@ typedef struct _mp_fun_table_t {
     void (*set_store)(mp_obj_t self_in, mp_obj_t item);
     mp_obj_t (*list_append)(mp_obj_t self_in, mp_obj_t arg);
     mp_obj_t (*dict_store)(mp_obj_t self_in, mp_obj_t key, mp_obj_t value);
-    mp_obj_t (*make_function_from_proto_fun)(mp_proto_fun_t proto_fun, const mp_module_context_t *cm, const mp_obj_t *def_args);
+    mp_obj_t (*make_function_from_raw_code)(const mp_raw_code_t *rc, const mp_module_context_t *cm, const mp_obj_t *def_args);
     mp_obj_t (*call_function_n_kw)(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args);
     mp_obj_t (*call_method_n_kw)(size_t n_args, size_t n_kw, const mp_obj_t *args);
     mp_obj_t (*call_method_n_kw_var)(bool have_self, size_t n_args_n_kw, const mp_obj_t *args);
@@ -156,12 +156,7 @@ typedef struct _mp_fun_table_t {
     double (*obj_get_float_to_d)(mp_obj_t o);
     bool (*get_buffer)(mp_obj_t obj, mp_buffer_info_t *bufinfo, mp_uint_t flags);
     const mp_stream_p_t *(*get_stream_raise)(mp_obj_t self_in, int flags);
-    size_t (*binary_get_size)(char struct_type, char val_type, size_t *palign);
-    mp_obj_t (*binary_get_val_array)(char typecode, void *p, size_t index);
-    void (*binary_set_val_array)(char typecode, void *p, size_t index, mp_obj_t val_in);
     const mp_print_t *plat_print;
-    // The following entries start at index 70 and are referenced by tools-mpy_ld.py,
-    // see constant MP_FUN_TABLE_MP_TYPE_TYPE_OFFSET.
     const mp_obj_type_t *type_type;
     const mp_obj_type_t *type_str;
     const mp_obj_type_t *type_list;

+ 1 - 1
py/nlraarch64.c

@@ -75,7 +75,7 @@ NORETURN void nlr_jump(void *val) {
         "ret                     \n"
         :
         : "r" (top)
-        : "memory"
+        :
         );
 
     MP_UNREACHABLE

+ 1 - 1
py/nlrmips.c

@@ -78,7 +78,7 @@ NORETURN void nlr_jump(void *val) {
         "nop            \n"
         :
         : "r" (top)
-        : "memory"
+        :
         );
     MP_UNREACHABLE
 }

+ 2 - 2
py/nlrpowerpc.c

@@ -114,7 +114,7 @@ NORETURN void nlr_jump(void *val) {
         "blr ;"
         :
         : "r" (&top->regs)
-        : "memory"
+        :
         );
 
     MP_UNREACHABLE;
@@ -203,7 +203,7 @@ NORETURN void nlr_jump(void *val) {
         "blr ;"
         :
         : "r" (&top->regs)
-        : "memory"
+        :
         );
 
     MP_UNREACHABLE;

+ 1 - 1
py/nlrthumb.c

@@ -132,7 +132,7 @@ NORETURN void nlr_jump(void *val) {
         "bx     lr                  \n" // return
         :                           // output operands
         : "r" (top)                 // input operands
-        : "memory"                  // clobbered registers
+        :                           // clobbered registers
         );
 
     MP_UNREACHABLE

+ 1 - 1
py/nlrx64.c

@@ -123,7 +123,7 @@ NORETURN void nlr_jump(void *val) {
         "ret                        \n" // return
         :                           // output operands
         : "r" (top)                 // input operands
-        : "memory"                  // clobbered registers
+        :                           // clobbered registers
         );
 
     MP_UNREACHABLE

+ 1 - 1
py/nlrx86.c

@@ -95,7 +95,7 @@ NORETURN void nlr_jump(void *val) {
         "ret                        \n" // return
         :                           // output operands
         : "r" (top)                 // input operands
-        : "memory"                  // clobbered registers
+        :                           // clobbered registers
         );
 
     MP_UNREACHABLE

+ 1 - 1
py/nlrxtensa.c

@@ -74,7 +74,7 @@ NORETURN void nlr_jump(void *val) {
         "ret.n                      \n" // return
         :                           // output operands
         : "r" (top)                 // input operands
-        : "memory"                  // clobbered registers
+        :                           // clobbered registers
         );
 
     MP_UNREACHABLE

+ 0 - 9
py/obj.c

@@ -44,15 +44,6 @@ MP_NOINLINE void *mp_obj_malloc_helper(size_t num_bytes, const mp_obj_type_t *ty
     return base;
 }
 
-#if MICROPY_ENABLE_FINALISER
-// Allocates an object and also sets type, for mp_obj_malloc{,_var}_with_finaliser macros.
-MP_NOINLINE void *mp_obj_malloc_with_finaliser_helper(size_t num_bytes, const mp_obj_type_t *type) {
-    mp_obj_base_t *base = (mp_obj_base_t *)m_malloc_with_finaliser(num_bytes);
-    base->type = type;
-    return base;
-}
-#endif
-
 const mp_obj_type_t *MICROPY_WRAP_MP_OBJ_GET_TYPE(mp_obj_get_type)(mp_const_obj_t o_in) {
     #if MICROPY_OBJ_IMMEDIATE_OBJS && MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_A
 

+ 1 - 14
py/obj.h

@@ -833,9 +833,6 @@ extern const mp_obj_type_t mp_type_fun_builtin_2;
 extern const mp_obj_type_t mp_type_fun_builtin_3;
 extern const mp_obj_type_t mp_type_fun_builtin_var;
 extern const mp_obj_type_t mp_type_fun_bc;
-extern const mp_obj_type_t mp_type_fun_native;
-extern const mp_obj_type_t mp_type_fun_viper;
-extern const mp_obj_type_t mp_type_fun_asm;
 extern const mp_obj_type_t mp_type_module;
 extern const mp_obj_type_t mp_type_staticmethod;
 extern const mp_obj_type_t mp_type_classmethod;
@@ -916,19 +913,9 @@ extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj;
 // Helper versions of m_new_obj when you need to immediately set base.type.
 // Implementing this as a call rather than inline saves 8 bytes per usage.
 #define mp_obj_malloc(struct_type, obj_type) ((struct_type *)mp_obj_malloc_helper(sizeof(struct_type), obj_type))
-#define mp_obj_malloc_var(struct_type, var_field, var_type, var_num, obj_type) ((struct_type *)mp_obj_malloc_helper(offsetof(struct_type, var_field) + sizeof(var_type) * (var_num), obj_type))
+#define mp_obj_malloc_var(struct_type, var_type, var_num, obj_type) ((struct_type *)mp_obj_malloc_helper(sizeof(struct_type) + sizeof(var_type) * (var_num), obj_type))
 void *mp_obj_malloc_helper(size_t num_bytes, const mp_obj_type_t *type);
 
-// Object allocation macros for allocating objects that have a finaliser.
-#if MICROPY_ENABLE_FINALISER
-#define mp_obj_malloc_with_finaliser(struct_type, obj_type) ((struct_type *)mp_obj_malloc_with_finaliser_helper(sizeof(struct_type), obj_type))
-#define mp_obj_malloc_var_with_finaliser(struct_type, var_type, var_num, obj_type) ((struct_type *)mp_obj_malloc_with_finaliser_helper(sizeof(struct_type) + sizeof(var_type) * (var_num), obj_type))
-void *mp_obj_malloc_with_finaliser_helper(size_t num_bytes, const mp_obj_type_t *type);
-#else
-#define mp_obj_malloc_with_finaliser(struct_type, obj_type) mp_obj_malloc(struct_type, obj_type)
-#define mp_obj_malloc_var_with_finaliser(struct_type, var_type, var_num, obj_type) mp_obj_malloc_var(struct_type, var_type, var_num, obj_type)
-#endif
-
 // These macros are derived from more primitive ones and are used to
 // check for more specific object types.
 // Note: these are kept as macros because inline functions sometimes use much

+ 21 - 21
py/objarray.c

@@ -61,16 +61,16 @@
 // so not defined to catch errors
 #endif
 
-static mp_obj_t array_iterator_new(mp_obj_t array_in, mp_obj_iter_buf_t *iter_buf);
-static mp_obj_t array_append(mp_obj_t self_in, mp_obj_t arg);
-static mp_obj_t array_extend(mp_obj_t self_in, mp_obj_t arg_in);
-static mp_int_t array_get_buffer(mp_obj_t o_in, mp_buffer_info_t *bufinfo, mp_uint_t flags);
+STATIC mp_obj_t array_iterator_new(mp_obj_t array_in, mp_obj_iter_buf_t *iter_buf);
+STATIC mp_obj_t array_append(mp_obj_t self_in, mp_obj_t arg);
+STATIC mp_obj_t array_extend(mp_obj_t self_in, mp_obj_t arg_in);
+STATIC mp_int_t array_get_buffer(mp_obj_t o_in, mp_buffer_info_t *bufinfo, mp_uint_t flags);
 
 /******************************************************************************/
 // array
 
 #if MICROPY_PY_BUILTINS_BYTEARRAY || MICROPY_PY_ARRAY
-static void array_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
+STATIC void array_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
     (void)kind;
     mp_obj_array_t *o = MP_OBJ_TO_PTR(o_in);
     if (o->typecode == BYTEARRAY_TYPECODE) {
@@ -94,7 +94,7 @@ static void array_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t
 #endif
 
 #if MICROPY_PY_BUILTINS_BYTEARRAY || MICROPY_PY_ARRAY
-static mp_obj_array_t *array_new(char typecode, size_t n) {
+STATIC mp_obj_array_t *array_new(char typecode, size_t n) {
     int typecode_size = mp_binary_get_size('@', typecode, NULL);
     mp_obj_array_t *o = m_new_obj(mp_obj_array_t);
     #if MICROPY_PY_BUILTINS_BYTEARRAY && MICROPY_PY_ARRAY
@@ -113,7 +113,7 @@ static mp_obj_array_t *array_new(char typecode, size_t n) {
 #endif
 
 #if MICROPY_PY_BUILTINS_BYTEARRAY || MICROPY_PY_ARRAY
-static mp_obj_t array_construct(char typecode, mp_obj_t initializer) {
+STATIC mp_obj_t array_construct(char typecode, mp_obj_t initializer) {
     // bytearrays can be raw-initialised from anything with the buffer protocol
     // other arrays can only be raw-initialised from bytes and bytearray objects
     mp_buffer_info_t bufinfo;
@@ -159,7 +159,7 @@ static mp_obj_t array_construct(char typecode, mp_obj_t initializer) {
 #endif
 
 #if MICROPY_PY_ARRAY
-static mp_obj_t array_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
+STATIC mp_obj_t array_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
     (void)type_in;
     mp_arg_check_num(n_args, n_kw, 1, 2, false);
 
@@ -177,7 +177,7 @@ static mp_obj_t array_make_new(const mp_obj_type_t *type_in, size_t n_args, size
 #endif
 
 #if MICROPY_PY_BUILTINS_BYTEARRAY
-static mp_obj_t bytearray_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
+STATIC mp_obj_t bytearray_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
     (void)type_in;
     // Can take 2nd/3rd arg if constructs from str
     mp_arg_check_num(n_args, n_kw, 0, 3, false);
@@ -214,7 +214,7 @@ mp_obj_t mp_obj_new_memoryview(byte typecode, size_t nitems, void *items) {
     return MP_OBJ_FROM_PTR(self);
 }
 
-static mp_obj_t memoryview_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
+STATIC mp_obj_t memoryview_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
     (void)type_in;
 
     // TODO possibly allow memoryview constructor to take start/stop so that one
@@ -246,7 +246,7 @@ static mp_obj_t memoryview_make_new(const mp_obj_type_t *type_in, size_t n_args,
 }
 
 #if MICROPY_PY_BUILTINS_MEMORYVIEW_ITEMSIZE
-static void memoryview_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
+STATIC void memoryview_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
     if (dest[0] != MP_OBJ_NULL) {
         return;
     }
@@ -265,7 +265,7 @@ static void memoryview_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
 
 #endif
 
-static mp_obj_t array_unary_op(mp_unary_op_t op, mp_obj_t o_in) {
+STATIC mp_obj_t array_unary_op(mp_unary_op_t op, mp_obj_t o_in) {
     mp_obj_array_t *o = MP_OBJ_TO_PTR(o_in);
     switch (op) {
         case MP_UNARY_OP_BOOL:
@@ -277,7 +277,7 @@ static mp_obj_t array_unary_op(mp_unary_op_t op, mp_obj_t o_in) {
     }
 }
 
-static int typecode_for_comparison(int typecode, bool *is_unsigned) {
+STATIC int typecode_for_comparison(int typecode, bool *is_unsigned) {
     if (typecode == BYTEARRAY_TYPECODE) {
         typecode = 'B';
     }
@@ -288,7 +288,7 @@ static int typecode_for_comparison(int typecode, bool *is_unsigned) {
     return typecode;
 }
 
-static mp_obj_t array_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
+STATIC mp_obj_t array_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
     mp_obj_array_t *lhs = MP_OBJ_TO_PTR(lhs_in);
     switch (op) {
         case MP_BINARY_OP_ADD: {
@@ -383,7 +383,7 @@ static mp_obj_t array_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs
 }
 
 #if MICROPY_PY_BUILTINS_BYTEARRAY || MICROPY_PY_ARRAY
-static mp_obj_t array_append(mp_obj_t self_in, mp_obj_t arg) {
+STATIC mp_obj_t array_append(mp_obj_t self_in, mp_obj_t arg) {
     // self is not a memoryview, so we don't need to use (& TYPECODE_MASK)
     assert((MICROPY_PY_BUILTINS_BYTEARRAY && mp_obj_is_type(self_in, &mp_type_bytearray))
         || (MICROPY_PY_ARRAY && mp_obj_is_type(self_in, &mp_type_array)));
@@ -404,7 +404,7 @@ static mp_obj_t array_append(mp_obj_t self_in, mp_obj_t arg) {
 }
 MP_DEFINE_CONST_FUN_OBJ_2(mp_obj_array_append_obj, array_append);
 
-static mp_obj_t array_extend(mp_obj_t self_in, mp_obj_t arg_in) {
+STATIC mp_obj_t array_extend(mp_obj_t self_in, mp_obj_t arg_in) {
     // self is not a memoryview, so we don't need to use (& TYPECODE_MASK)
     assert((MICROPY_PY_BUILTINS_BYTEARRAY && mp_obj_is_type(self_in, &mp_type_bytearray))
         || (MICROPY_PY_ARRAY && mp_obj_is_type(self_in, &mp_type_array)));
@@ -437,7 +437,7 @@ static mp_obj_t array_extend(mp_obj_t self_in, mp_obj_t arg_in) {
 MP_DEFINE_CONST_FUN_OBJ_2(mp_obj_array_extend_obj, array_extend);
 #endif
 
-static mp_obj_t array_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value) {
+STATIC mp_obj_t array_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value) {
     if (value == MP_OBJ_NULL) {
         // delete item
         // TODO implement
@@ -568,7 +568,7 @@ static mp_obj_t array_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value
     }
 }
 
-static mp_int_t array_get_buffer(mp_obj_t o_in, mp_buffer_info_t *bufinfo, mp_uint_t flags) {
+STATIC mp_int_t array_get_buffer(mp_obj_t o_in, mp_buffer_info_t *bufinfo, mp_uint_t flags) {
     mp_obj_array_t *o = MP_OBJ_TO_PTR(o_in);
     size_t sz = mp_binary_get_size('@', o->typecode & TYPECODE_MASK, NULL);
     bufinfo->buf = o->items;
@@ -682,7 +682,7 @@ typedef struct _mp_obj_array_it_t {
     size_t cur;
 } mp_obj_array_it_t;
 
-static mp_obj_t array_it_iternext(mp_obj_t self_in) {
+STATIC mp_obj_t array_it_iternext(mp_obj_t self_in) {
     mp_obj_array_it_t *self = MP_OBJ_TO_PTR(self_in);
     if (self->cur < self->array->len) {
         return mp_binary_get_val_array(self->array->typecode & TYPECODE_MASK, self->array->items, self->offset + self->cur++);
@@ -691,14 +691,14 @@ static mp_obj_t array_it_iternext(mp_obj_t self_in) {
     }
 }
 
-static MP_DEFINE_CONST_OBJ_TYPE(
+STATIC MP_DEFINE_CONST_OBJ_TYPE(
     mp_type_array_it,
     MP_QSTR_iterator,
     MP_TYPE_FLAG_ITER_IS_ITERNEXT,
     iter, array_it_iternext
     );
 
-static mp_obj_t array_iterator_new(mp_obj_t array_in, mp_obj_iter_buf_t *iter_buf) {
+STATIC mp_obj_t array_iterator_new(mp_obj_t array_in, mp_obj_iter_buf_t *iter_buf) {
     assert(sizeof(mp_obj_array_t) <= sizeof(mp_obj_iter_buf_t));
     mp_obj_array_t *array = MP_OBJ_TO_PTR(array_in);
     mp_obj_array_it_t *o = (mp_obj_array_it_t *)iter_buf;

+ 4 - 4
py/objattrtuple.c

@@ -30,7 +30,7 @@
 
 // this helper function is used by collections.namedtuple
 #if !MICROPY_PY_COLLECTIONS
-static
+STATIC
 #endif
 void mp_obj_attrtuple_print_helper(const mp_print_t *print, const qstr *fields, mp_obj_tuple_t *o) {
     mp_print_str(print, "(");
@@ -48,14 +48,14 @@ void mp_obj_attrtuple_print_helper(const mp_print_t *print, const qstr *fields,
 
 #if MICROPY_PY_ATTRTUPLE
 
-static void mp_obj_attrtuple_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
+STATIC void mp_obj_attrtuple_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
     (void)kind;
     mp_obj_tuple_t *o = MP_OBJ_TO_PTR(o_in);
     const qstr *fields = (const qstr *)MP_OBJ_TO_PTR(o->items[o->len]);
     mp_obj_attrtuple_print_helper(print, fields, o);
 }
 
-static void mp_obj_attrtuple_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
+STATIC void mp_obj_attrtuple_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
     if (dest[0] == MP_OBJ_NULL) {
         // load attribute
         mp_obj_tuple_t *self = MP_OBJ_TO_PTR(self_in);
@@ -71,7 +71,7 @@ static void mp_obj_attrtuple_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
 }
 
 mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items) {
-    mp_obj_tuple_t *o = mp_obj_malloc_var(mp_obj_tuple_t, items, mp_obj_t, n + 1, &mp_type_attrtuple);
+    mp_obj_tuple_t *o = mp_obj_malloc_var(mp_obj_tuple_t, mp_obj_t, n + 1, &mp_type_attrtuple);
     o->len = n;
     for (size_t i = 0; i < n; i++) {
         o->items[i] = items[i];

+ 4 - 4
py/objbool.c

@@ -43,7 +43,7 @@ typedef struct _mp_obj_bool_t {
 
 #endif
 
-static void bool_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
+STATIC void bool_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
     bool value = BOOL_VALUE(self_in);
     if (MICROPY_PY_JSON && kind == PRINT_JSON) {
         if (value) {
@@ -60,7 +60,7 @@ static void bool_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_
     }
 }
 
-static mp_obj_t bool_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
+STATIC mp_obj_t bool_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
     (void)type_in;
     mp_arg_check_num(n_args, n_kw, 0, 1, false);
 
@@ -71,7 +71,7 @@ static mp_obj_t bool_make_new(const mp_obj_type_t *type_in, size_t n_args, size_
     }
 }
 
-static mp_obj_t bool_unary_op(mp_unary_op_t op, mp_obj_t o_in) {
+STATIC mp_obj_t bool_unary_op(mp_unary_op_t op, mp_obj_t o_in) {
     if (op == MP_UNARY_OP_LEN) {
         return MP_OBJ_NULL;
     }
@@ -79,7 +79,7 @@ static mp_obj_t bool_unary_op(mp_unary_op_t op, mp_obj_t o_in) {
     return mp_unary_op(op, MP_OBJ_NEW_SMALL_INT(value));
 }
 
-static mp_obj_t bool_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
+STATIC mp_obj_t bool_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
     bool value = BOOL_VALUE(lhs_in);
     return mp_binary_op(op, MP_OBJ_NEW_SMALL_INT(value), rhs_in);
 }

+ 5 - 5
py/objboundmeth.c

@@ -36,7 +36,7 @@ typedef struct _mp_obj_bound_meth_t {
 } mp_obj_bound_meth_t;
 
 #if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_DETAILED
-static void bound_meth_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
+STATIC void bound_meth_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
     (void)kind;
     mp_obj_bound_meth_t *o = MP_OBJ_TO_PTR(o_in);
     mp_printf(print, "<bound_method %p ", o);
@@ -78,12 +78,12 @@ mp_obj_t mp_call_method_self_n_kw(mp_obj_t meth, mp_obj_t self, size_t n_args, s
     return res;
 }
 
-static mp_obj_t bound_meth_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
+STATIC mp_obj_t bound_meth_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
     mp_obj_bound_meth_t *self = MP_OBJ_TO_PTR(self_in);
     return mp_call_method_self_n_kw(self->meth, self->self, n_args, n_kw, args);
 }
 
-static mp_obj_t bound_meth_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
+STATIC mp_obj_t bound_meth_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
     mp_obj_bound_meth_t *self = MP_OBJ_TO_PTR(self_in);
     switch (op) {
         case MP_UNARY_OP_HASH:
@@ -93,7 +93,7 @@ static mp_obj_t bound_meth_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
     }
 }
 
-static mp_obj_t bound_meth_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
+STATIC mp_obj_t bound_meth_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
     // The MP_TYPE_FLAG_EQ_CHECKS_OTHER_TYPE flag is clear for this type, so if this
     // function is called with MP_BINARY_OP_EQUAL then lhs_in and rhs_in must have the
     // same type, which is mp_type_bound_meth.
@@ -106,7 +106,7 @@ static mp_obj_t bound_meth_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_
 }
 
 #if MICROPY_PY_FUNCTION_ATTRS
-static void bound_meth_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
+STATIC void bound_meth_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
     if (dest[0] != MP_OBJ_NULL) {
         // not load attribute
         return;

+ 2 - 2
py/objcell.c

@@ -27,7 +27,7 @@
 #include "py/obj.h"
 
 #if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_DETAILED
-static void cell_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
+STATIC void cell_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
     (void)kind;
     mp_obj_cell_t *o = MP_OBJ_TO_PTR(o_in);
     mp_printf(print, "<cell %p ", o->obj);
@@ -46,7 +46,7 @@ static void cell_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t k
 #define CELL_TYPE_PRINT
 #endif
 
-static MP_DEFINE_CONST_OBJ_TYPE(
+STATIC MP_DEFINE_CONST_OBJ_TYPE(
     // cell representation is just value in < >
     mp_type_cell, MP_QSTR_, MP_TYPE_FLAG_NONE
     CELL_TYPE_PRINT

+ 4 - 4
py/objclosure.c

@@ -36,7 +36,7 @@ typedef struct _mp_obj_closure_t {
     mp_obj_t closed[];
 } mp_obj_closure_t;
 
-static mp_obj_t closure_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
+STATIC mp_obj_t closure_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
     mp_obj_closure_t *self = MP_OBJ_TO_PTR(self_in);
 
     // need to concatenate closed-over-vars and args
@@ -60,7 +60,7 @@ static mp_obj_t closure_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const
 }
 
 #if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_DETAILED
-static void closure_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
+STATIC void closure_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
     (void)kind;
     mp_obj_closure_t *o = MP_OBJ_TO_PTR(o_in);
     mp_print_str(print, "<closure ");
@@ -79,7 +79,7 @@ static void closure_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_
 #endif
 
 #if MICROPY_PY_FUNCTION_ATTRS
-static void mp_obj_closure_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
+STATIC void mp_obj_closure_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
     // forward to self_in->fun
     mp_obj_closure_t *o = MP_OBJ_TO_PTR(self_in);
     mp_load_method_maybe(o->fun, attr, dest);
@@ -105,7 +105,7 @@ MP_DEFINE_CONST_OBJ_TYPE(
     );
 
 mp_obj_t mp_obj_new_closure(mp_obj_t fun, size_t n_closed_over, const mp_obj_t *closed) {
-    mp_obj_closure_t *o = mp_obj_malloc_var(mp_obj_closure_t, closed, mp_obj_t, n_closed_over, &mp_type_closure);
+    mp_obj_closure_t *o = mp_obj_malloc_var(mp_obj_closure_t, mp_obj_t, n_closed_over, &mp_type_closure);
     o->fun = fun;
     o->n_closed = n_closed_over;
     memcpy(o->closed, closed, n_closed_over * sizeof(mp_obj_t));

+ 5 - 5
py/objcomplex.c

@@ -42,7 +42,7 @@ typedef struct _mp_obj_complex_t {
     mp_float_t imag;
 } mp_obj_complex_t;
 
-static void complex_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
+STATIC void complex_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
     (void)kind;
     mp_obj_complex_t *o = MP_OBJ_TO_PTR(o_in);
     #if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT
@@ -70,7 +70,7 @@ static void complex_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_
     }
 }
 
-static mp_obj_t complex_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
+STATIC mp_obj_t complex_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
     (void)type_in;
     mp_arg_check_num(n_args, n_kw, 0, 2, false);
 
@@ -115,7 +115,7 @@ static mp_obj_t complex_make_new(const mp_obj_type_t *type_in, size_t n_args, si
     }
 }
 
-static mp_obj_t complex_unary_op(mp_unary_op_t op, mp_obj_t o_in) {
+STATIC mp_obj_t complex_unary_op(mp_unary_op_t op, mp_obj_t o_in) {
     mp_obj_complex_t *o = MP_OBJ_TO_PTR(o_in);
     switch (op) {
         case MP_UNARY_OP_BOOL:
@@ -133,12 +133,12 @@ static mp_obj_t complex_unary_op(mp_unary_op_t op, mp_obj_t o_in) {
     }
 }
 
-static mp_obj_t complex_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
+STATIC mp_obj_t complex_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
     mp_obj_complex_t *lhs = MP_OBJ_TO_PTR(lhs_in);
     return mp_obj_complex_binary_op(op, lhs->real, lhs->imag, rhs_in);
 }
 
-static void complex_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
+STATIC void complex_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
     if (dest[0] != MP_OBJ_NULL) {
         // not load attribute
         return;

+ 28 - 175
py/objdeque.c

@@ -25,11 +25,13 @@
  */
 
 #include <unistd.h> // for ssize_t
+#include <string.h>
 
-#include "py/runtime.h"
-
+#include "py/mpconfig.h"
 #if MICROPY_PY_COLLECTIONS_DEQUE
 
+#include "py/runtime.h"
+
 typedef struct _mp_obj_deque_t {
     mp_obj_base_t base;
     size_t alloc;
@@ -40,15 +42,15 @@ typedef struct _mp_obj_deque_t {
     #define FLAG_CHECK_OVERFLOW 1
 } mp_obj_deque_t;
 
-static mp_obj_t mp_obj_deque_append(mp_obj_t self_in, mp_obj_t arg);
-static mp_obj_t mp_obj_deque_extend(mp_obj_t self_in, mp_obj_t arg_in);
-#if MICROPY_PY_COLLECTIONS_DEQUE_ITER
-static mp_obj_t mp_obj_new_deque_it(mp_obj_t deque, mp_obj_iter_buf_t *iter_buf);
-#endif
-
-static mp_obj_t deque_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
+STATIC mp_obj_t deque_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
     mp_arg_check_num(n_args, n_kw, 2, 3, false);
 
+    /* Initialization from existing sequence is not supported, so an empty
+       tuple must be passed as such. */
+    if (args[0] != mp_const_empty_tuple) {
+        mp_raise_ValueError(NULL);
+    }
+
     // Protect against -1 leading to zero-length allocation and bad array access
     mp_int_t maxlen = mp_obj_get_int(args[1]);
     if (maxlen < 0) {
@@ -64,27 +66,21 @@ static mp_obj_t deque_make_new(const mp_obj_type_t *type, size_t n_args, size_t
         o->flags = mp_obj_get_int(args[2]);
     }
 
-    mp_obj_deque_extend(MP_OBJ_FROM_PTR(o), args[0]);
-
     return MP_OBJ_FROM_PTR(o);
 }
 
-static size_t deque_len(mp_obj_deque_t *self) {
-    ssize_t len = self->i_put - self->i_get;
-    if (len < 0) {
-        len += self->alloc;
-    }
-    return len;
-}
-
-static mp_obj_t deque_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
+STATIC mp_obj_t deque_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
     mp_obj_deque_t *self = MP_OBJ_TO_PTR(self_in);
     switch (op) {
         case MP_UNARY_OP_BOOL:
             return mp_obj_new_bool(self->i_get != self->i_put);
-        case MP_UNARY_OP_LEN:
-            return MP_OBJ_NEW_SMALL_INT(deque_len(self));
-
+        case MP_UNARY_OP_LEN: {
+            ssize_t len = self->i_put - self->i_get;
+            if (len < 0) {
+                len += self->alloc;
+            }
+            return MP_OBJ_NEW_SMALL_INT(len);
+        }
         #if MICROPY_PY_SYS_GETSIZEOF
         case MP_UNARY_OP_SIZEOF: {
             size_t sz = sizeof(*self) + sizeof(mp_obj_t) * self->alloc;
@@ -96,7 +92,7 @@ static mp_obj_t deque_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
     }
 }
 
-static mp_obj_t mp_obj_deque_append(mp_obj_t self_in, mp_obj_t arg) {
+STATIC mp_obj_t mp_obj_deque_append(mp_obj_t self_in, mp_obj_t arg) {
     mp_obj_deque_t *self = MP_OBJ_TO_PTR(self_in);
 
     size_t new_i_put = self->i_put + 1;
@@ -119,48 +115,9 @@ static mp_obj_t mp_obj_deque_append(mp_obj_t self_in, mp_obj_t arg) {
 
     return mp_const_none;
 }
-static MP_DEFINE_CONST_FUN_OBJ_2(deque_append_obj, mp_obj_deque_append);
-
-static mp_obj_t mp_obj_deque_appendleft(mp_obj_t self_in, mp_obj_t arg) {
-    mp_obj_deque_t *self = MP_OBJ_TO_PTR(self_in);
-
-    size_t new_i_get = self->i_get - 1;
-    if (self->i_get == 0) {
-        new_i_get = self->alloc - 1;
-    }
-
-    if (self->flags & FLAG_CHECK_OVERFLOW && new_i_get == self->i_put) {
-        mp_raise_msg(&mp_type_IndexError, MP_ERROR_TEXT("full"));
-    }
-
-    self->i_get = new_i_get;
-    self->items[self->i_get] = arg;
-
-    // overwriting first element in deque
-    if (self->i_put == new_i_get) {
-        if (self->i_put == 0) {
-            self->i_put = self->alloc - 1;
-        } else {
-            self->i_put--;
-        }
-    }
-
-    return mp_const_none;
-}
-static MP_DEFINE_CONST_FUN_OBJ_2(deque_appendleft_obj, mp_obj_deque_appendleft);
+STATIC MP_DEFINE_CONST_FUN_OBJ_2(deque_append_obj, mp_obj_deque_append);
 
-static mp_obj_t mp_obj_deque_extend(mp_obj_t self_in, mp_obj_t arg_in) {
-    mp_obj_iter_buf_t iter_buf;
-    mp_obj_t iter = mp_getiter(arg_in, &iter_buf);
-    mp_obj_t item;
-    while ((item = mp_iternext(iter)) != MP_OBJ_STOP_ITERATION) {
-        mp_obj_deque_append(self_in, item);
-    }
-    return mp_const_none;
-}
-static MP_DEFINE_CONST_FUN_OBJ_2(deque_extend_obj, mp_obj_deque_extend);
-
-static mp_obj_t deque_popleft(mp_obj_t self_in) {
+STATIC mp_obj_t deque_popleft(mp_obj_t self_in) {
     mp_obj_deque_t *self = MP_OBJ_TO_PTR(self_in);
 
     if (self->i_get == self->i_put) {
@@ -176,139 +133,35 @@ static mp_obj_t deque_popleft(mp_obj_t self_in) {
 
     return ret;
 }
-static MP_DEFINE_CONST_FUN_OBJ_1(deque_popleft_obj, deque_popleft);
-
-static mp_obj_t deque_pop(mp_obj_t self_in) {
-    mp_obj_deque_t *self = MP_OBJ_TO_PTR(self_in);
-
-    if (self->i_get == self->i_put) {
-        mp_raise_msg(&mp_type_IndexError, MP_ERROR_TEXT("empty"));
-    }
-
-    if (self->i_put == 0) {
-        self->i_put = self->alloc - 1;
-    } else {
-        self->i_put--;
-    }
-
-    mp_obj_t ret = self->items[self->i_put];
-    self->items[self->i_put] = MP_OBJ_NULL;
-
-    return ret;
-}
-static MP_DEFINE_CONST_FUN_OBJ_1(deque_pop_obj, deque_pop);
-
-#if MICROPY_PY_COLLECTIONS_DEQUE_SUBSCR
-static mp_obj_t deque_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
-    if (value == MP_OBJ_NULL) {
-        // delete not supported, fall back to mp_obj_subscr() error message
-        return MP_OBJ_NULL;
-    }
-    mp_obj_deque_t *self = MP_OBJ_TO_PTR(self_in);
-
-    size_t offset = mp_get_index(self->base.type, deque_len(self), index, false);
-    size_t index_val = self->i_get + offset;
-    if (index_val > self->alloc) {
-        index_val -= self->alloc;
-    }
-
-    if (value == MP_OBJ_SENTINEL) {
-        // load
-        return self->items[index_val];
-    } else {
-        // store into deque
-        self->items[index_val] = value;
-        return mp_const_none;
-    }
-}
-#endif
+STATIC MP_DEFINE_CONST_FUN_OBJ_1(deque_popleft_obj, deque_popleft);
 
 #if 0
-static mp_obj_t deque_clear(mp_obj_t self_in) {
+STATIC mp_obj_t deque_clear(mp_obj_t self_in) {
     mp_obj_deque_t *self = MP_OBJ_TO_PTR(self_in);
     self->i_get = self->i_put = 0;
     mp_seq_clear(self->items, 0, self->alloc, sizeof(*self->items));
     return mp_const_none;
 }
-static MP_DEFINE_CONST_FUN_OBJ_1(deque_clear_obj, deque_clear);
+STATIC MP_DEFINE_CONST_FUN_OBJ_1(deque_clear_obj, deque_clear);
 #endif
 
-static const mp_rom_map_elem_t deque_locals_dict_table[] = {
+STATIC const mp_rom_map_elem_t deque_locals_dict_table[] = {
     { MP_ROM_QSTR(MP_QSTR_append), MP_ROM_PTR(&deque_append_obj) },
-    { MP_ROM_QSTR(MP_QSTR_appendleft), MP_ROM_PTR(&deque_appendleft_obj) },
-    { MP_ROM_QSTR(MP_QSTR_extend), MP_ROM_PTR(&deque_extend_obj) },
     #if 0
     { MP_ROM_QSTR(MP_QSTR_clear), MP_ROM_PTR(&deque_clear_obj) },
     #endif
-    { MP_ROM_QSTR(MP_QSTR_pop), MP_ROM_PTR(&deque_pop_obj) },
     { MP_ROM_QSTR(MP_QSTR_popleft), MP_ROM_PTR(&deque_popleft_obj) },
 };
 
-static MP_DEFINE_CONST_DICT(deque_locals_dict, deque_locals_dict_table);
-
-#if MICROPY_PY_COLLECTIONS_DEQUE_ITER
-#define DEQUE_TYPE_FLAGS MP_TYPE_FLAG_ITER_IS_GETITER
-#define DEQUE_TYPE_ITER iter, mp_obj_new_deque_it,
-#else
-#define DEQUE_TYPE_FLAGS MP_TYPE_FLAG_NONE
-#define DEQUE_TYPE_ITER
-#endif
-
-#if MICROPY_PY_COLLECTIONS_DEQUE_SUBSCR
-#define DEQUE_TYPE_SUBSCR subscr, deque_subscr,
-#else
-#define DEQUE_TYPE_SUBSCR
-#endif
+STATIC MP_DEFINE_CONST_DICT(deque_locals_dict, deque_locals_dict_table);
 
 MP_DEFINE_CONST_OBJ_TYPE(
     mp_type_deque,
     MP_QSTR_deque,
-    MP_TYPE_FLAG_ITER_IS_GETITER,
+    MP_TYPE_FLAG_NONE,
     make_new, deque_make_new,
     unary_op, deque_unary_op,
-    DEQUE_TYPE_SUBSCR
-    DEQUE_TYPE_ITER
     locals_dict, &deque_locals_dict
     );
 
-/******************************************************************************/
-/* deque iterator                                                             */
-
-#if MICROPY_PY_COLLECTIONS_DEQUE_ITER
-
-typedef struct _mp_obj_deque_it_t {
-    mp_obj_base_t base;
-    mp_fun_1_t iternext;
-    mp_obj_t deque;
-    size_t cur;
-} mp_obj_deque_it_t;
-
-static mp_obj_t deque_it_iternext(mp_obj_t self_in) {
-    mp_obj_deque_it_t *self = MP_OBJ_TO_PTR(self_in);
-    mp_obj_deque_t *deque = MP_OBJ_TO_PTR(self->deque);
-    if (self->cur != deque->i_put) {
-        mp_obj_t o_out = deque->items[self->cur];
-        if (++self->cur == deque->alloc) {
-            self->cur = 0;
-        }
-        return o_out;
-    } else {
-        return MP_OBJ_STOP_ITERATION;
-    }
-}
-
-static mp_obj_t mp_obj_new_deque_it(mp_obj_t deque, mp_obj_iter_buf_t *iter_buf) {
-    mp_obj_deque_t *deque_ = MP_OBJ_TO_PTR(deque);
-    size_t i_get = deque_->i_get;
-    assert(sizeof(mp_obj_deque_it_t) <= sizeof(mp_obj_iter_buf_t));
-    mp_obj_deque_it_t *o = (mp_obj_deque_it_t *)iter_buf;
-    o->base.type = &mp_type_polymorph_iter;
-    o->iternext = deque_it_iternext;
-    o->deque = deque;
-    o->cur = i_get;
-    return MP_OBJ_FROM_PTR(o);
-}
-
-#endif
-
 #endif // MICROPY_PY_COLLECTIONS_DEQUE

+ 45 - 45
py/objdict.c

@@ -49,12 +49,12 @@ const mp_obj_dict_t mp_const_empty_dict_obj = {
     }
 };
 
-static mp_obj_t dict_update(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs);
+STATIC mp_obj_t dict_update(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs);
 
 // This is a helper function to iterate through a dictionary.  The state of
 // the iteration is held in *cur and should be initialised with zero for the
 // first call.  Will return NULL when no more elements are available.
-static mp_map_elem_t *dict_iter_next(mp_obj_dict_t *dict, size_t *cur) {
+STATIC mp_map_elem_t *dict_iter_next(mp_obj_dict_t *dict, size_t *cur) {
     size_t max = dict->map.alloc;
     mp_map_t *map = &dict->map;
 
@@ -70,7 +70,7 @@ static mp_map_elem_t *dict_iter_next(mp_obj_dict_t *dict, size_t *cur) {
     return NULL;
 }
 
-static void dict_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
+STATIC void dict_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
     mp_obj_dict_t *self = MP_OBJ_TO_PTR(self_in);
     bool first = true;
     const char *item_separator = ", ";
@@ -129,7 +129,7 @@ mp_obj_t mp_obj_dict_make_new(const mp_obj_type_t *type, size_t n_args, size_t n
     return dict_out;
 }
 
-static mp_obj_t dict_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
+STATIC mp_obj_t dict_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
     mp_obj_dict_t *self = MP_OBJ_TO_PTR(self_in);
     switch (op) {
         case MP_UNARY_OP_BOOL:
@@ -147,7 +147,7 @@ static mp_obj_t dict_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
     }
 }
 
-static mp_obj_t dict_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
+STATIC mp_obj_t dict_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
     mp_obj_dict_t *o = MP_OBJ_TO_PTR(lhs_in);
     switch (op) {
         case MP_BINARY_OP_CONTAINS: {
@@ -218,7 +218,7 @@ mp_obj_t mp_obj_dict_get(mp_obj_t self_in, mp_obj_t index) {
     }
 }
 
-static mp_obj_t dict_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
+STATIC mp_obj_t dict_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
     if (value == MP_OBJ_NULL) {
         // delete
         mp_obj_dict_delete(self_in, index);
@@ -242,13 +242,13 @@ static mp_obj_t dict_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
 /******************************************************************************/
 /* dict methods                                                               */
 
-static void mp_ensure_not_fixed(const mp_obj_dict_t *dict) {
+STATIC void mp_ensure_not_fixed(const mp_obj_dict_t *dict) {
     if (dict->map.is_fixed) {
         mp_raise_TypeError(NULL);
     }
 }
 
-static mp_obj_t dict_clear(mp_obj_t self_in) {
+STATIC mp_obj_t dict_clear(mp_obj_t self_in) {
     mp_check_self(mp_obj_is_dict_or_ordereddict(self_in));
     mp_obj_dict_t *self = MP_OBJ_TO_PTR(self_in);
     mp_ensure_not_fixed(self);
@@ -257,7 +257,7 @@ static mp_obj_t dict_clear(mp_obj_t self_in) {
 
     return mp_const_none;
 }
-static MP_DEFINE_CONST_FUN_OBJ_1(dict_clear_obj, dict_clear);
+STATIC MP_DEFINE_CONST_FUN_OBJ_1(dict_clear_obj, dict_clear);
 
 mp_obj_t mp_obj_dict_copy(mp_obj_t self_in) {
     mp_check_self(mp_obj_is_dict_or_ordereddict(self_in));
@@ -272,11 +272,11 @@ mp_obj_t mp_obj_dict_copy(mp_obj_t self_in) {
     memcpy(other->map.table, self->map.table, self->map.alloc * sizeof(mp_map_elem_t));
     return other_out;
 }
-static MP_DEFINE_CONST_FUN_OBJ_1(dict_copy_obj, mp_obj_dict_copy);
+STATIC MP_DEFINE_CONST_FUN_OBJ_1(dict_copy_obj, mp_obj_dict_copy);
 
 #if MICROPY_PY_BUILTINS_DICT_FROMKEYS
 // this is a classmethod
-static mp_obj_t dict_fromkeys(size_t n_args, const mp_obj_t *args) {
+STATIC mp_obj_t dict_fromkeys(size_t n_args, const mp_obj_t *args) {
     mp_obj_t iter = mp_getiter(args[1], NULL);
     mp_obj_t value = mp_const_none;
     mp_obj_t next = MP_OBJ_NULL;
@@ -302,11 +302,11 @@ static mp_obj_t dict_fromkeys(size_t n_args, const mp_obj_t *args) {
 
     return self_out;
 }
-static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(dict_fromkeys_fun_obj, 2, 3, dict_fromkeys);
-static MP_DEFINE_CONST_CLASSMETHOD_OBJ(dict_fromkeys_obj, MP_ROM_PTR(&dict_fromkeys_fun_obj));
+STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(dict_fromkeys_fun_obj, 2, 3, dict_fromkeys);
+STATIC MP_DEFINE_CONST_CLASSMETHOD_OBJ(dict_fromkeys_obj, MP_ROM_PTR(&dict_fromkeys_fun_obj));
 #endif
 
-static mp_obj_t dict_get_helper(size_t n_args, const mp_obj_t *args, mp_map_lookup_kind_t lookup_kind) {
+STATIC mp_obj_t dict_get_helper(size_t n_args, const mp_obj_t *args, mp_map_lookup_kind_t lookup_kind) {
     mp_check_self(mp_obj_is_dict_or_ordereddict(args[0]));
     mp_obj_dict_t *self = MP_OBJ_TO_PTR(args[0]);
     if (lookup_kind != MP_MAP_LOOKUP) {
@@ -336,22 +336,22 @@ static mp_obj_t dict_get_helper(size_t n_args, const mp_obj_t *args, mp_map_look
     return value;
 }
 
-static mp_obj_t dict_get(size_t n_args, const mp_obj_t *args) {
+STATIC mp_obj_t dict_get(size_t n_args, const mp_obj_t *args) {
     return dict_get_helper(n_args, args, MP_MAP_LOOKUP);
 }
-static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(dict_get_obj, 2, 3, dict_get);
+STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(dict_get_obj, 2, 3, dict_get);
 
-static mp_obj_t dict_pop(size_t n_args, const mp_obj_t *args) {
+STATIC mp_obj_t dict_pop(size_t n_args, const mp_obj_t *args) {
     return dict_get_helper(n_args, args, MP_MAP_LOOKUP_REMOVE_IF_FOUND);
 }
-static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(dict_pop_obj, 2, 3, dict_pop);
+STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(dict_pop_obj, 2, 3, dict_pop);
 
-static mp_obj_t dict_setdefault(size_t n_args, const mp_obj_t *args) {
+STATIC mp_obj_t dict_setdefault(size_t n_args, const mp_obj_t *args) {
     return dict_get_helper(n_args, args, MP_MAP_LOOKUP_ADD_IF_NOT_FOUND);
 }
-static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(dict_setdefault_obj, 2, 3, dict_setdefault);
+STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(dict_setdefault_obj, 2, 3, dict_setdefault);
 
-static mp_obj_t dict_popitem(mp_obj_t self_in) {
+STATIC mp_obj_t dict_popitem(mp_obj_t self_in) {
     mp_check_self(mp_obj_is_dict_or_ordereddict(self_in));
     mp_obj_dict_t *self = MP_OBJ_TO_PTR(self_in);
     mp_ensure_not_fixed(self);
@@ -374,9 +374,9 @@ static mp_obj_t dict_popitem(mp_obj_t self_in) {
 
     return tuple;
 }
-static MP_DEFINE_CONST_FUN_OBJ_1(dict_popitem_obj, dict_popitem);
+STATIC MP_DEFINE_CONST_FUN_OBJ_1(dict_popitem_obj, dict_popitem);
 
-static mp_obj_t dict_update(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs) {
+STATIC mp_obj_t dict_update(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs) {
     mp_check_self(mp_obj_is_dict_or_ordereddict(args[0]));
     mp_obj_dict_t *self = MP_OBJ_TO_PTR(args[0]);
     mp_ensure_not_fixed(self);
@@ -424,14 +424,14 @@ static mp_obj_t dict_update(size_t n_args, const mp_obj_t *args, mp_map_t *kwarg
 
     return mp_const_none;
 }
-static MP_DEFINE_CONST_FUN_OBJ_KW(dict_update_obj, 1, dict_update);
+STATIC MP_DEFINE_CONST_FUN_OBJ_KW(dict_update_obj, 1, dict_update);
 
 
 /******************************************************************************/
 /* dict views                                                                 */
 
-static const mp_obj_type_t mp_type_dict_view;
-static const mp_obj_type_t mp_type_dict_view_it;
+STATIC const mp_obj_type_t mp_type_dict_view;
+STATIC const mp_obj_type_t mp_type_dict_view_it;
 
 typedef enum _mp_dict_view_kind_t {
     MP_DICT_VIEW_ITEMS,
@@ -439,7 +439,7 @@ typedef enum _mp_dict_view_kind_t {
     MP_DICT_VIEW_VALUES,
 } mp_dict_view_kind_t;
 
-static const char *const mp_dict_view_names[] = {"dict_items", "dict_keys", "dict_values"};
+STATIC const char *const mp_dict_view_names[] = {"dict_items", "dict_keys", "dict_values"};
 
 typedef struct _mp_obj_dict_view_it_t {
     mp_obj_base_t base;
@@ -454,7 +454,7 @@ typedef struct _mp_obj_dict_view_t {
     mp_dict_view_kind_t kind;
 } mp_obj_dict_view_t;
 
-static mp_obj_t dict_view_it_iternext(mp_obj_t self_in) {
+STATIC mp_obj_t dict_view_it_iternext(mp_obj_t self_in) {
     mp_check_self(mp_obj_is_type(self_in, &mp_type_dict_view_it));
     mp_obj_dict_view_it_t *self = MP_OBJ_TO_PTR(self_in);
     mp_map_elem_t *next = dict_iter_next(MP_OBJ_TO_PTR(self->dict), &self->cur);
@@ -476,14 +476,14 @@ static mp_obj_t dict_view_it_iternext(mp_obj_t self_in) {
     }
 }
 
-static MP_DEFINE_CONST_OBJ_TYPE(
+STATIC MP_DEFINE_CONST_OBJ_TYPE(
     mp_type_dict_view_it,
     MP_QSTR_iterator,
     MP_TYPE_FLAG_ITER_IS_ITERNEXT,
     iter, dict_view_it_iternext
     );
 
-static mp_obj_t dict_view_getiter(mp_obj_t view_in, mp_obj_iter_buf_t *iter_buf) {
+STATIC mp_obj_t dict_view_getiter(mp_obj_t view_in, mp_obj_iter_buf_t *iter_buf) {
     assert(sizeof(mp_obj_dict_view_it_t) <= sizeof(mp_obj_iter_buf_t));
     mp_check_self(mp_obj_is_type(view_in, &mp_type_dict_view));
     mp_obj_dict_view_t *view = MP_OBJ_TO_PTR(view_in);
@@ -495,7 +495,7 @@ static mp_obj_t dict_view_getiter(mp_obj_t view_in, mp_obj_iter_buf_t *iter_buf)
     return MP_OBJ_FROM_PTR(o);
 }
 
-static void dict_view_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
+STATIC void dict_view_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
     (void)kind;
     mp_check_self(mp_obj_is_type(self_in, &mp_type_dict_view));
     mp_obj_dict_view_t *self = MP_OBJ_TO_PTR(self_in);
@@ -515,7 +515,7 @@ static void dict_view_print(const mp_print_t *print, mp_obj_t self_in, mp_print_
     mp_print_str(print, "])");
 }
 
-static mp_obj_t dict_view_unary_op(mp_unary_op_t op, mp_obj_t o_in) {
+STATIC mp_obj_t dict_view_unary_op(mp_unary_op_t op, mp_obj_t o_in) {
     mp_obj_dict_view_t *o = MP_OBJ_TO_PTR(o_in);
     // only dict.values() supports __hash__.
     if (op == MP_UNARY_OP_HASH && o->kind == MP_DICT_VIEW_VALUES) {
@@ -524,7 +524,7 @@ static mp_obj_t dict_view_unary_op(mp_unary_op_t op, mp_obj_t o_in) {
     return MP_OBJ_NULL;
 }
 
-static mp_obj_t dict_view_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
+STATIC mp_obj_t dict_view_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
     // only supported for the 'keys' kind until sets and dicts are refactored
     mp_obj_dict_view_t *o = MP_OBJ_TO_PTR(lhs_in);
     if (o->kind != MP_DICT_VIEW_KEYS) {
@@ -536,7 +536,7 @@ static mp_obj_t dict_view_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t
     return dict_binary_op(op, o->dict, rhs_in);
 }
 
-static MP_DEFINE_CONST_OBJ_TYPE(
+STATIC MP_DEFINE_CONST_OBJ_TYPE(
     mp_type_dict_view,
     MP_QSTR_dict_view,
     MP_TYPE_FLAG_ITER_IS_GETITER,
@@ -546,37 +546,37 @@ static MP_DEFINE_CONST_OBJ_TYPE(
     iter, dict_view_getiter
     );
 
-static mp_obj_t mp_obj_new_dict_view(mp_obj_t dict, mp_dict_view_kind_t kind) {
+STATIC mp_obj_t mp_obj_new_dict_view(mp_obj_t dict, mp_dict_view_kind_t kind) {
     mp_obj_dict_view_t *o = mp_obj_malloc(mp_obj_dict_view_t, &mp_type_dict_view);
     o->dict = dict;
     o->kind = kind;
     return MP_OBJ_FROM_PTR(o);
 }
 
-static mp_obj_t dict_view(mp_obj_t self_in, mp_dict_view_kind_t kind) {
+STATIC mp_obj_t dict_view(mp_obj_t self_in, mp_dict_view_kind_t kind) {
     mp_check_self(mp_obj_is_dict_or_ordereddict(self_in));
     return mp_obj_new_dict_view(self_in, kind);
 }
 
-static mp_obj_t dict_items(mp_obj_t self_in) {
+STATIC mp_obj_t dict_items(mp_obj_t self_in) {
     return dict_view(self_in, MP_DICT_VIEW_ITEMS);
 }
-static MP_DEFINE_CONST_FUN_OBJ_1(dict_items_obj, dict_items);
+STATIC MP_DEFINE_CONST_FUN_OBJ_1(dict_items_obj, dict_items);
 
-static mp_obj_t dict_keys(mp_obj_t self_in) {
+STATIC mp_obj_t dict_keys(mp_obj_t self_in) {
     return dict_view(self_in, MP_DICT_VIEW_KEYS);
 }
-static MP_DEFINE_CONST_FUN_OBJ_1(dict_keys_obj, dict_keys);
+STATIC MP_DEFINE_CONST_FUN_OBJ_1(dict_keys_obj, dict_keys);
 
-static mp_obj_t dict_values(mp_obj_t self_in) {
+STATIC mp_obj_t dict_values(mp_obj_t self_in) {
     return dict_view(self_in, MP_DICT_VIEW_VALUES);
 }
-static MP_DEFINE_CONST_FUN_OBJ_1(dict_values_obj, dict_values);
+STATIC MP_DEFINE_CONST_FUN_OBJ_1(dict_values_obj, dict_values);
 
 /******************************************************************************/
 /* dict iterator                                                              */
 
-static mp_obj_t dict_getiter(mp_obj_t self_in, mp_obj_iter_buf_t *iter_buf) {
+STATIC mp_obj_t dict_getiter(mp_obj_t self_in, mp_obj_iter_buf_t *iter_buf) {
     assert(sizeof(mp_obj_dict_view_it_t) <= sizeof(mp_obj_iter_buf_t));
     mp_check_self(mp_obj_is_dict_or_ordereddict(self_in));
     mp_obj_dict_view_it_t *o = (mp_obj_dict_view_it_t *)iter_buf;
@@ -590,7 +590,7 @@ static mp_obj_t dict_getiter(mp_obj_t self_in, mp_obj_iter_buf_t *iter_buf) {
 /******************************************************************************/
 /* dict constructors & public C API                                           */
 
-static const mp_rom_map_elem_t dict_locals_dict_table[] = {
+STATIC const mp_rom_map_elem_t dict_locals_dict_table[] = {
     { MP_ROM_QSTR(MP_QSTR_clear), MP_ROM_PTR(&dict_clear_obj) },
     { MP_ROM_QSTR(MP_QSTR_copy), MP_ROM_PTR(&dict_copy_obj) },
     #if MICROPY_PY_BUILTINS_DICT_FROMKEYS
@@ -609,7 +609,7 @@ static const mp_rom_map_elem_t dict_locals_dict_table[] = {
     { MP_ROM_QSTR(MP_QSTR___delitem__), MP_ROM_PTR(&mp_op_delitem_obj) },
 };
 
-static MP_DEFINE_CONST_DICT(dict_locals_dict, dict_locals_dict_table);
+STATIC MP_DEFINE_CONST_DICT(dict_locals_dict, dict_locals_dict_table);
 
 MP_DEFINE_CONST_OBJ_TYPE(
     mp_type_dict,

+ 3 - 3
py/objenumerate.c

@@ -37,9 +37,9 @@ typedef struct _mp_obj_enumerate_t {
     mp_int_t cur;
 } mp_obj_enumerate_t;
 
-static mp_obj_t enumerate_iternext(mp_obj_t self_in);
+STATIC mp_obj_t enumerate_iternext(mp_obj_t self_in);
 
-static mp_obj_t enumerate_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
+STATIC mp_obj_t enumerate_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
     #if MICROPY_CPYTHON_COMPAT
     static const mp_arg_t allowed_args[] = {
         { MP_QSTR_iterable, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} },
@@ -75,7 +75,7 @@ MP_DEFINE_CONST_OBJ_TYPE(
     iter, enumerate_iternext
     );
 
-static mp_obj_t enumerate_iternext(mp_obj_t self_in) {
+STATIC mp_obj_t enumerate_iternext(mp_obj_t self_in) {
     assert(mp_obj_is_type(self_in, &mp_type_enumerate));
     mp_obj_enumerate_t *self = MP_OBJ_TO_PTR(self_in);
     mp_obj_t next = mp_iternext(self->iter);

+ 3 - 3
py/objexcept.c

@@ -117,7 +117,7 @@ bool mp_obj_is_native_exception_instance(mp_obj_t self_in) {
     return MP_OBJ_TYPE_GET_SLOT_OR_NULL(mp_obj_get_type(self_in), make_new) == mp_obj_exception_make_new;
 }
 
-static mp_obj_exception_t *get_native_exception(mp_obj_t self_in) {
+STATIC mp_obj_exception_t *get_native_exception(mp_obj_t self_in) {
     assert(mp_obj_is_exception_instance(self_in));
     if (mp_obj_is_native_exception_instance(self_in)) {
         return MP_OBJ_TO_PTR(self_in);
@@ -126,7 +126,7 @@ static mp_obj_exception_t *get_native_exception(mp_obj_t self_in) {
     }
 }
 
-static void decompress_error_text_maybe(mp_obj_exception_t *o) {
+STATIC void decompress_error_text_maybe(mp_obj_exception_t *o) {
     #if MICROPY_ROM_TEXT_COMPRESSION
     if (o->args->len == 1 && mp_obj_is_exact_type(o->args->items[0], &mp_type_str)) {
         mp_obj_str_t *o_str = MP_OBJ_TO_PTR(o->args->items[0]);
@@ -439,7 +439,7 @@ struct _exc_printer_t {
     byte *buf;
 };
 
-static void exc_add_strn(void *data, const char *str, size_t len) {
+STATIC void exc_add_strn(void *data, const char *str, size_t len) {
     struct _exc_printer_t *pr = data;
     if (pr->len + len >= pr->alloc) {
         // Not enough room for data plus a null byte so try to grow the buffer

+ 2 - 2
py/objfilter.c

@@ -34,7 +34,7 @@ typedef struct _mp_obj_filter_t {
     mp_obj_t iter;
 } mp_obj_filter_t;
 
-static mp_obj_t filter_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
+STATIC mp_obj_t filter_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
     mp_arg_check_num(n_args, n_kw, 2, 2, false);
     mp_obj_filter_t *o = mp_obj_malloc(mp_obj_filter_t, type);
     o->fun = args[0];
@@ -42,7 +42,7 @@ static mp_obj_t filter_make_new(const mp_obj_type_t *type, size_t n_args, size_t
     return MP_OBJ_FROM_PTR(o);
 }
 
-static mp_obj_t filter_iternext(mp_obj_t self_in) {
+STATIC mp_obj_t filter_iternext(mp_obj_t self_in) {
     mp_check_self(mp_obj_is_type(self_in, &mp_type_filter));
     mp_obj_filter_t *self = MP_OBJ_TO_PTR(self_in);
     mp_obj_t next;

+ 5 - 5
py/objfloat.c

@@ -102,7 +102,7 @@ mp_int_t mp_float_hash(mp_float_t src) {
 }
 #endif
 
-static void float_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
+STATIC void float_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
     (void)kind;
     mp_float_t o_val = mp_obj_float_get(o_in);
     #if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT
@@ -124,7 +124,7 @@ static void float_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t
     }
 }
 
-static mp_obj_t float_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
+STATIC mp_obj_t float_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
     (void)type_in;
     mp_arg_check_num(n_args, n_kw, 0, 1, false);
 
@@ -149,7 +149,7 @@ static mp_obj_t float_make_new(const mp_obj_type_t *type_in, size_t n_args, size
     }
 }
 
-static mp_obj_t float_unary_op(mp_unary_op_t op, mp_obj_t o_in) {
+STATIC mp_obj_t float_unary_op(mp_unary_op_t op, mp_obj_t o_in) {
     mp_float_t val = mp_obj_float_get(o_in);
     switch (op) {
         case MP_UNARY_OP_BOOL:
@@ -172,7 +172,7 @@ static mp_obj_t float_unary_op(mp_unary_op_t op, mp_obj_t o_in) {
     }
 }
 
-static mp_obj_t float_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
+STATIC mp_obj_t float_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
     mp_float_t lhs_val = mp_obj_float_get(lhs_in);
     #if MICROPY_PY_BUILTINS_COMPLEX
     if (mp_obj_is_type(rhs_in, &mp_type_complex)) {
@@ -208,7 +208,7 @@ mp_float_t mp_obj_float_get(mp_obj_t self_in) {
 
 #endif
 
-static void mp_obj_float_divmod(mp_float_t *x, mp_float_t *y) {
+STATIC void mp_obj_float_divmod(mp_float_t *x, mp_float_t *y) {
     // logic here follows that of CPython
     // https://docs.python.org/3/reference/expressions.html#binary-arithmetic-operations
     // x == (x//y)*y + (x%y)

+ 51 - 45
py/objfun.c

@@ -48,7 +48,7 @@
 /******************************************************************************/
 /* builtin functions                                                          */
 
-static mp_obj_t fun_builtin_0_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
+STATIC mp_obj_t fun_builtin_0_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
     (void)args;
     assert(mp_obj_is_type(self_in, &mp_type_fun_builtin_0));
     mp_obj_fun_builtin_fixed_t *self = MP_OBJ_TO_PTR(self_in);
@@ -61,7 +61,7 @@ MP_DEFINE_CONST_OBJ_TYPE(
     call, fun_builtin_0_call
     );
 
-static mp_obj_t fun_builtin_1_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
+STATIC mp_obj_t fun_builtin_1_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
     assert(mp_obj_is_type(self_in, &mp_type_fun_builtin_1));
     mp_obj_fun_builtin_fixed_t *self = MP_OBJ_TO_PTR(self_in);
     mp_arg_check_num(n_args, n_kw, 1, 1, false);
@@ -73,7 +73,7 @@ MP_DEFINE_CONST_OBJ_TYPE(
     call, fun_builtin_1_call
     );
 
-static mp_obj_t fun_builtin_2_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
+STATIC mp_obj_t fun_builtin_2_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
     assert(mp_obj_is_type(self_in, &mp_type_fun_builtin_2));
     mp_obj_fun_builtin_fixed_t *self = MP_OBJ_TO_PTR(self_in);
     mp_arg_check_num(n_args, n_kw, 2, 2, false);
@@ -85,7 +85,7 @@ MP_DEFINE_CONST_OBJ_TYPE(
     call, fun_builtin_2_call
     );
 
-static mp_obj_t fun_builtin_3_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
+STATIC mp_obj_t fun_builtin_3_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
     assert(mp_obj_is_type(self_in, &mp_type_fun_builtin_3));
     mp_obj_fun_builtin_fixed_t *self = MP_OBJ_TO_PTR(self_in);
     mp_arg_check_num(n_args, n_kw, 3, 3, false);
@@ -97,7 +97,7 @@ MP_DEFINE_CONST_OBJ_TYPE(
     call, fun_builtin_3_call
     );
 
-static mp_obj_t fun_builtin_var_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
+STATIC mp_obj_t fun_builtin_var_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
     assert(mp_obj_is_type(self_in, &mp_type_fun_builtin_var));
     mp_obj_fun_builtin_var_t *self = MP_OBJ_TO_PTR(self_in);
 
@@ -128,29 +128,35 @@ MP_DEFINE_CONST_OBJ_TYPE(
 /******************************************************************************/
 /* byte code functions                                                        */
 
+STATIC qstr mp_obj_code_get_name(const mp_obj_fun_bc_t *fun, const byte *code_info) {
+    MP_BC_PRELUDE_SIZE_DECODE(code_info);
+    mp_uint_t name = mp_decode_uint_value(code_info);
+    #if MICROPY_EMIT_BYTECODE_USES_QSTR_TABLE
+    name = fun->context->constants.qstr_table[name];
+    #endif
+    return name;
+}
+
+#if MICROPY_EMIT_NATIVE
+STATIC const mp_obj_type_t mp_type_fun_native;
+#endif
+
 qstr mp_obj_fun_get_name(mp_const_obj_t fun_in) {
     const mp_obj_fun_bc_t *fun = MP_OBJ_TO_PTR(fun_in);
-    const byte *bc = fun->bytecode;
-
     #if MICROPY_EMIT_NATIVE
     if (fun->base.type == &mp_type_fun_native || fun->base.type == &mp_type_native_gen_wrap) {
-        bc = mp_obj_fun_native_get_prelude_ptr(fun);
+        // TODO native functions don't have name stored
+        return MP_QSTR_;
     }
     #endif
 
+    const byte *bc = fun->bytecode;
     MP_BC_PRELUDE_SIG_DECODE(bc);
-    MP_BC_PRELUDE_SIZE_DECODE(bc);
-
-    mp_uint_t name = mp_decode_uint_value(bc);
-    #if MICROPY_EMIT_BYTECODE_USES_QSTR_TABLE
-    name = fun->context->constants.qstr_table[name];
-    #endif
-
-    return name;
+    return mp_obj_code_get_name(fun, bc);
 }
 
 #if MICROPY_CPYTHON_COMPAT
-static void fun_bc_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
+STATIC void fun_bc_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
     (void)kind;
     mp_obj_fun_bc_t *o = MP_OBJ_TO_PTR(o_in);
     mp_printf(print, "<function %q at 0x%p>", mp_obj_fun_get_name(o_in), o);
@@ -158,7 +164,7 @@ static void fun_bc_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t
 #endif
 
 #if DEBUG_PRINT
-static void dump_args(const mp_obj_t *a, size_t sz) {
+STATIC void dump_args(const mp_obj_t *a, size_t sz) {
     DEBUG_printf("%p: ", a);
     for (size_t i = 0; i < sz; i++) {
         DEBUG_printf("%p ", a[i]);
@@ -224,7 +230,7 @@ mp_code_state_t *mp_obj_fun_bc_prepare_codestate(mp_obj_t self_in, size_t n_args
 }
 #endif
 
-static mp_obj_t fun_bc_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
+STATIC mp_obj_t fun_bc_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
     MP_STACK_CHECK();
 
     DEBUG_printf("Input n_args: " UINT_FMT ", n_kw: " UINT_FMT "\n", n_args, n_kw);
@@ -378,7 +384,7 @@ mp_obj_t mp_obj_new_fun_bc(const mp_obj_t *def_args, const byte *code, const mp_
         def_kw_args = def_args[1];
         n_extra_args += 1;
     }
-    mp_obj_fun_bc_t *o = mp_obj_malloc_var(mp_obj_fun_bc_t, extra_args, mp_obj_t, n_extra_args, &mp_type_fun_bc);
+    mp_obj_fun_bc_t *o = mp_obj_malloc_var(mp_obj_fun_bc_t, mp_obj_t, n_extra_args, &mp_type_fun_bc);
     o->bytecode = code;
     o->context = context;
     o->child_table = child_table;
@@ -396,10 +402,10 @@ mp_obj_t mp_obj_new_fun_bc(const mp_obj_t *def_args, const byte *code, const mp_
 
 #if MICROPY_EMIT_NATIVE
 
-static mp_obj_t fun_native_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
+STATIC mp_obj_t fun_native_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
     MP_STACK_CHECK();
     mp_obj_fun_bc_t *self = MP_OBJ_TO_PTR(self_in);
-    mp_call_fun_t fun = mp_obj_fun_native_get_function_start(self);
+    mp_call_fun_t fun = MICROPY_MAKE_POINTER_CALLABLE((void *)self->bytecode);
     return fun(self_in, n_args, n_kw, args);
 }
 
@@ -414,7 +420,7 @@ static mp_obj_t fun_native_call(mp_obj_t self_in, size_t n_args, size_t n_kw, co
 #define FUN_BC_TYPE_ATTR
 #endif
 
-MP_DEFINE_CONST_OBJ_TYPE(
+STATIC MP_DEFINE_CONST_OBJ_TYPE(
     mp_type_fun_native,
     MP_QSTR_function,
     MP_TYPE_FLAG_BINDS_SELF,
@@ -423,27 +429,12 @@ MP_DEFINE_CONST_OBJ_TYPE(
     call, fun_native_call
     );
 
-#endif // MICROPY_EMIT_NATIVE
-
-/******************************************************************************/
-/* viper functions                                                           */
-
-#if MICROPY_EMIT_NATIVE
-
-static mp_obj_t fun_viper_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
-    MP_STACK_CHECK();
-    mp_obj_fun_bc_t *self = MP_OBJ_TO_PTR(self_in);
-    mp_call_fun_t fun = MICROPY_MAKE_POINTER_CALLABLE((void *)self->bytecode);
-    return fun(self_in, n_args, n_kw, args);
+mp_obj_t mp_obj_new_fun_native(const mp_obj_t *def_args, const void *fun_data, const mp_module_context_t *mc, struct _mp_raw_code_t *const *child_table) {
+    mp_obj_fun_bc_t *o = MP_OBJ_TO_PTR(mp_obj_new_fun_bc(def_args, (const byte *)fun_data, mc, child_table));
+    o->base.type = &mp_type_fun_native;
+    return MP_OBJ_FROM_PTR(o);
 }
 
-MP_DEFINE_CONST_OBJ_TYPE(
-    mp_type_fun_viper,
-    MP_QSTR_function,
-    MP_TYPE_FLAG_BINDS_SELF,
-    call, fun_viper_call
-    );
-
 #endif // MICROPY_EMIT_NATIVE
 
 /******************************************************************************/
@@ -451,6 +442,13 @@ MP_DEFINE_CONST_OBJ_TYPE(
 
 #if MICROPY_EMIT_INLINE_ASM
 
+typedef struct _mp_obj_fun_asm_t {
+    mp_obj_base_t base;
+    size_t n_args;
+    const void *fun_data; // GC must be able to trace this pointer
+    mp_uint_t type_sig;
+} mp_obj_fun_asm_t;
+
 typedef mp_uint_t (*inline_asm_fun_0_t)(void);
 typedef mp_uint_t (*inline_asm_fun_1_t)(mp_uint_t);
 typedef mp_uint_t (*inline_asm_fun_2_t)(mp_uint_t, mp_uint_t);
@@ -458,7 +456,7 @@ typedef mp_uint_t (*inline_asm_fun_3_t)(mp_uint_t, mp_uint_t, mp_uint_t);
 typedef mp_uint_t (*inline_asm_fun_4_t)(mp_uint_t, mp_uint_t, mp_uint_t, mp_uint_t);
 
 // convert a MicroPython object to a sensible value for inline asm
-static mp_uint_t convert_obj_for_inline_asm(mp_obj_t obj) {
+STATIC mp_uint_t convert_obj_for_inline_asm(mp_obj_t obj) {
     // TODO for byte_array, pass pointer to the array
     if (mp_obj_is_small_int(obj)) {
         return MP_OBJ_SMALL_INT_VALUE(obj);
@@ -501,7 +499,7 @@ static mp_uint_t convert_obj_for_inline_asm(mp_obj_t obj) {
     }
 }
 
-static mp_obj_t fun_asm_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
+STATIC mp_obj_t fun_asm_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
     mp_obj_fun_asm_t *self = MP_OBJ_TO_PTR(self_in);
 
     mp_arg_check_num(n_args, n_kw, self->n_args, self->n_args, false);
@@ -531,11 +529,19 @@ static mp_obj_t fun_asm_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const
     return mp_native_to_obj(ret, self->type_sig);
 }
 
-MP_DEFINE_CONST_OBJ_TYPE(
+STATIC MP_DEFINE_CONST_OBJ_TYPE(
     mp_type_fun_asm,
     MP_QSTR_function,
     MP_TYPE_FLAG_BINDS_SELF,
     call, fun_asm_call
     );
 
+mp_obj_t mp_obj_new_fun_asm(size_t n_args, const void *fun_data, mp_uint_t type_sig) {
+    mp_obj_fun_asm_t *o = mp_obj_malloc(mp_obj_fun_asm_t, &mp_type_fun_asm);
+    o->n_args = n_args;
+    o->fun_data = fun_data;
+    o->type_sig = type_sig;
+    return MP_OBJ_FROM_PTR(o);
+}
+
 #endif // MICROPY_EMIT_INLINE_ASM

+ 2 - 63
py/objfun.h

@@ -43,70 +43,9 @@ typedef struct _mp_obj_fun_bc_t {
     mp_obj_t extra_args[];
 } mp_obj_fun_bc_t;
 
-typedef struct _mp_obj_fun_asm_t {
-    mp_obj_base_t base;
-    size_t n_args;
-    const void *fun_data; // GC must be able to trace this pointer
-    mp_uint_t type_sig;
-} mp_obj_fun_asm_t;
-
 mp_obj_t mp_obj_new_fun_bc(const mp_obj_t *def_args, const byte *code, const mp_module_context_t *cm, struct _mp_raw_code_t *const *raw_code_table);
+mp_obj_t mp_obj_new_fun_native(const mp_obj_t *def_args, const void *fun_data, const mp_module_context_t *cm, struct _mp_raw_code_t *const *raw_code_table);
+mp_obj_t mp_obj_new_fun_asm(size_t n_args, const void *fun_data, mp_uint_t type_sig);
 void mp_obj_fun_bc_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest);
 
-#if MICROPY_EMIT_NATIVE
-
-static inline mp_obj_t mp_obj_new_fun_native(const mp_obj_t *def_args, const void *fun_data, const mp_module_context_t *mc, struct _mp_raw_code_t *const *child_table) {
-    mp_obj_fun_bc_t *o = MP_OBJ_TO_PTR(mp_obj_new_fun_bc(def_args, (const byte *)fun_data, mc, child_table));
-    o->base.type = &mp_type_fun_native;
-    return MP_OBJ_FROM_PTR(o);
-}
-
-static inline mp_obj_t mp_obj_new_fun_viper(const void *fun_data, const mp_module_context_t *mc, struct _mp_raw_code_t *const *child_table) {
-    mp_obj_fun_bc_t *o = mp_obj_malloc(mp_obj_fun_bc_t, &mp_type_fun_viper);
-    o->bytecode = fun_data;
-    o->context = mc;
-    o->child_table = child_table;
-    return MP_OBJ_FROM_PTR(o);
-}
-
-static inline const uint8_t *mp_obj_fun_native_get_prelude_ptr(const mp_obj_fun_bc_t *fun_native) {
-    // Obtain a pointer to the start of the function prelude, based on prelude_ptr_index.
-    uintptr_t prelude_ptr_index = ((uintptr_t *)fun_native->bytecode)[0];
-    const uint8_t *prelude_ptr;
-    if (prelude_ptr_index == 0) {
-        prelude_ptr = (const uint8_t *)fun_native->child_table;
-    } else {
-        prelude_ptr = (const uint8_t *)fun_native->child_table[prelude_ptr_index];
-    }
-    return prelude_ptr;
-}
-
-static inline void *mp_obj_fun_native_get_function_start(const mp_obj_fun_bc_t *fun_native) {
-    // Obtain a pointer to the start of the function executable machine code.
-    return MICROPY_MAKE_POINTER_CALLABLE((void *)(fun_native->bytecode + sizeof(uintptr_t)));
-}
-
-static inline void *mp_obj_fun_native_get_generator_start(const mp_obj_fun_bc_t *fun_native) {
-    // Obtain a pointer to the start of the generator executable machine code.
-    uintptr_t start_offset = ((uintptr_t *)fun_native->bytecode)[1];
-    return MICROPY_MAKE_POINTER_CALLABLE((void *)(fun_native->bytecode + start_offset));
-}
-
-static inline void *mp_obj_fun_native_get_generator_resume(const mp_obj_fun_bc_t *fun_native) {
-    // Obtain a pointer to the resume location of the generator executable machine code.
-    return MICROPY_MAKE_POINTER_CALLABLE((void *)&((uintptr_t *)fun_native->bytecode)[2]);
-}
-
-#endif
-
-#if MICROPY_EMIT_INLINE_ASM
-static inline mp_obj_t mp_obj_new_fun_asm(size_t n_args, const void *fun_data, mp_uint_t type_sig) {
-    mp_obj_fun_asm_t *o = mp_obj_malloc(mp_obj_fun_asm_t, &mp_type_fun_asm);
-    o->n_args = n_args;
-    o->fun_data = fun_data;
-    o->type_sig = type_sig;
-    return MP_OBJ_FROM_PTR(o);
-}
-#endif
-
 #endif // MICROPY_INCLUDED_PY_OBJFUN_H

+ 30 - 21
py/objgenerator.c

@@ -50,7 +50,7 @@ typedef struct _mp_obj_gen_instance_t {
     mp_code_state_t code_state;
 } mp_obj_gen_instance_t;
 
-static mp_obj_t gen_wrap_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
+STATIC mp_obj_t gen_wrap_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
     // A generating function is just a bytecode function with type mp_type_gen_wrap
     mp_obj_fun_bc_t *self_fun = MP_OBJ_TO_PTR(self_in);
 
@@ -59,7 +59,7 @@ static mp_obj_t gen_wrap_call(mp_obj_t self_in, size_t n_args, size_t n_kw, cons
     MP_BC_PRELUDE_SIG_DECODE(ip);
 
     // allocate the generator object, with room for local stack and exception stack
-    mp_obj_gen_instance_t *o = mp_obj_malloc_var(mp_obj_gen_instance_t, code_state.state, byte,
+    mp_obj_gen_instance_t *o = mp_obj_malloc_var(mp_obj_gen_instance_t, byte,
         n_state * sizeof(mp_obj_t) + n_exc_stack * sizeof(mp_exc_stack_t),
         &mp_type_gen_instance);
 
@@ -96,31 +96,40 @@ typedef struct _mp_obj_gen_instance_native_t {
     mp_code_state_native_t code_state;
 } mp_obj_gen_instance_native_t;
 
-static mp_obj_t native_gen_wrap_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
+STATIC mp_obj_t native_gen_wrap_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
     // The state for a native generating function is held in the same struct as a bytecode function
     mp_obj_fun_bc_t *self_fun = MP_OBJ_TO_PTR(self_in);
 
     // Determine start of prelude.
-    const uint8_t *prelude_ptr = mp_obj_fun_native_get_prelude_ptr(self_fun);
+    uintptr_t prelude_ptr_index = ((uintptr_t *)self_fun->bytecode)[0];
+    const uint8_t *prelude_ptr;
+    if (prelude_ptr_index == 0) {
+        prelude_ptr = (void *)self_fun->child_table;
+    } else {
+        prelude_ptr = (void *)self_fun->child_table[prelude_ptr_index];
+    }
 
     // Extract n_state from the prelude.
     const uint8_t *ip = prelude_ptr;
     MP_BC_PRELUDE_SIG_DECODE(ip);
 
     // Allocate the generator object, with room for local stack (exception stack not needed).
-    mp_obj_gen_instance_native_t *o = mp_obj_malloc_var(mp_obj_gen_instance_native_t, code_state.state, byte, n_state * sizeof(mp_obj_t), &mp_type_gen_instance);
+    mp_obj_gen_instance_native_t *o = mp_obj_malloc_var(mp_obj_gen_instance_native_t, byte, n_state * sizeof(mp_obj_t), &mp_type_gen_instance);
 
     // Parse the input arguments and set up the code state
     o->pend_exc = mp_const_none;
     o->code_state.fun_bc = self_fun;
+    o->code_state.ip = prelude_ptr;
     o->code_state.n_state = n_state;
+    o->code_state.sp = &o->code_state.state[0] - 1;
     mp_setup_code_state_native(&o->code_state, n_args, n_kw, args);
 
     // Indicate we are a native function, which doesn't use this variable
     o->code_state.exc_sp_idx = MP_CODE_STATE_EXC_SP_IDX_SENTINEL;
 
     // Prepare the generator instance for execution
-    o->code_state.ip = mp_obj_fun_native_get_generator_start(self_fun);
+    uintptr_t start_offset = ((uintptr_t *)self_fun->bytecode)[1];
+    o->code_state.ip = MICROPY_MAKE_POINTER_CALLABLE((void *)(self_fun->bytecode + start_offset));
 
     return MP_OBJ_FROM_PTR(o);
 }
@@ -144,7 +153,7 @@ MP_DEFINE_CONST_OBJ_TYPE(
 /******************************************************************************/
 /* generator instance                                                         */
 
-static void gen_instance_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
+STATIC void gen_instance_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
     (void)kind;
     mp_obj_gen_instance_t *self = MP_OBJ_TO_PTR(self_in);
     mp_printf(print, "<generator object '%q' at %p>", mp_obj_fun_get_name(MP_OBJ_FROM_PTR(self->code_state.fun_bc)), self);
@@ -199,9 +208,9 @@ mp_vm_return_kind_t mp_obj_gen_resume(mp_obj_t self_in, mp_obj_t send_value, mp_
 
     #if MICROPY_EMIT_NATIVE
     if (self->code_state.exc_sp_idx == MP_CODE_STATE_EXC_SP_IDX_SENTINEL) {
-        // A native generator.
+        // A native generator, with entry point 2 words into the "bytecode" pointer
         typedef uintptr_t (*mp_fun_native_gen_t)(void *, mp_obj_t);
-        mp_fun_native_gen_t fun = mp_obj_fun_native_get_generator_resume(self->code_state.fun_bc);
+        mp_fun_native_gen_t fun = MICROPY_MAKE_POINTER_CALLABLE((const void *)(self->code_state.fun_bc->bytecode + 2 * sizeof(uintptr_t)));
         ret_kind = fun((void *)&self->code_state, throw_value);
     } else
     #endif
@@ -254,7 +263,7 @@ mp_vm_return_kind_t mp_obj_gen_resume(mp_obj_t self_in, mp_obj_t send_value, mp_
     return ret_kind;
 }
 
-static mp_obj_t gen_resume_and_raise(mp_obj_t self_in, mp_obj_t send_value, mp_obj_t throw_value, bool raise_stop_iteration) {
+STATIC mp_obj_t gen_resume_and_raise(mp_obj_t self_in, mp_obj_t send_value, mp_obj_t throw_value, bool raise_stop_iteration) {
     mp_obj_t ret;
     switch (mp_obj_gen_resume(self_in, send_value, throw_value, &ret)) {
         case MP_VM_RETURN_NORMAL:
@@ -278,16 +287,16 @@ static mp_obj_t gen_resume_and_raise(mp_obj_t self_in, mp_obj_t send_value, mp_o
     }
 }
 
-static mp_obj_t gen_instance_iternext(mp_obj_t self_in) {
+STATIC mp_obj_t gen_instance_iternext(mp_obj_t self_in) {
     return gen_resume_and_raise(self_in, mp_const_none, MP_OBJ_NULL, false);
 }
 
-static mp_obj_t gen_instance_send(mp_obj_t self_in, mp_obj_t send_value) {
+STATIC mp_obj_t gen_instance_send(mp_obj_t self_in, mp_obj_t send_value) {
     return gen_resume_and_raise(self_in, send_value, MP_OBJ_NULL, true);
 }
-static MP_DEFINE_CONST_FUN_OBJ_2(gen_instance_send_obj, gen_instance_send);
+STATIC MP_DEFINE_CONST_FUN_OBJ_2(gen_instance_send_obj, gen_instance_send);
 
-static mp_obj_t gen_instance_throw(size_t n_args, const mp_obj_t *args) {
+STATIC mp_obj_t gen_instance_throw(size_t n_args, const mp_obj_t *args) {
     // The signature of this function is: throw(type[, value[, traceback]])
     // CPython will pass all given arguments through the call chain and process them
     // at the point they are used (native generators will handle them differently to
@@ -307,9 +316,9 @@ static mp_obj_t gen_instance_throw(size_t n_args, const mp_obj_t *args) {
 
     return gen_resume_and_raise(args[0], mp_const_none, exc, true);
 }
-static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(gen_instance_throw_obj, 2, 4, gen_instance_throw);
+STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(gen_instance_throw_obj, 2, 4, gen_instance_throw);
 
-static mp_obj_t gen_instance_close(mp_obj_t self_in) {
+STATIC mp_obj_t gen_instance_close(mp_obj_t self_in) {
     mp_obj_t ret;
     switch (mp_obj_gen_resume(self_in, mp_const_none, MP_OBJ_FROM_PTR(&mp_const_GeneratorExit_obj), &ret)) {
         case MP_VM_RETURN_YIELD:
@@ -328,10 +337,10 @@ static mp_obj_t gen_instance_close(mp_obj_t self_in) {
             return mp_const_none;
     }
 }
-static MP_DEFINE_CONST_FUN_OBJ_1(gen_instance_close_obj, gen_instance_close);
+STATIC MP_DEFINE_CONST_FUN_OBJ_1(gen_instance_close_obj, gen_instance_close);
 
 #if MICROPY_PY_GENERATOR_PEND_THROW
-static mp_obj_t gen_instance_pend_throw(mp_obj_t self_in, mp_obj_t exc_in) {
+STATIC mp_obj_t gen_instance_pend_throw(mp_obj_t self_in, mp_obj_t exc_in) {
     mp_obj_gen_instance_t *self = MP_OBJ_TO_PTR(self_in);
     if (self->pend_exc == MP_OBJ_NULL) {
         mp_raise_ValueError(MP_ERROR_TEXT("generator already executing"));
@@ -340,10 +349,10 @@ static mp_obj_t gen_instance_pend_throw(mp_obj_t self_in, mp_obj_t exc_in) {
     self->pend_exc = exc_in;
     return prev;
 }
-static MP_DEFINE_CONST_FUN_OBJ_2(gen_instance_pend_throw_obj, gen_instance_pend_throw);
+STATIC MP_DEFINE_CONST_FUN_OBJ_2(gen_instance_pend_throw_obj, gen_instance_pend_throw);
 #endif
 
-static const mp_rom_map_elem_t gen_instance_locals_dict_table[] = {
+STATIC const mp_rom_map_elem_t gen_instance_locals_dict_table[] = {
     { MP_ROM_QSTR(MP_QSTR_close), MP_ROM_PTR(&gen_instance_close_obj) },
     { MP_ROM_QSTR(MP_QSTR_send), MP_ROM_PTR(&gen_instance_send_obj) },
     { MP_ROM_QSTR(MP_QSTR_throw), MP_ROM_PTR(&gen_instance_throw_obj) },
@@ -352,7 +361,7 @@ static const mp_rom_map_elem_t gen_instance_locals_dict_table[] = {
     #endif
 };
 
-static MP_DEFINE_CONST_DICT(gen_instance_locals_dict, gen_instance_locals_dict_table);
+STATIC MP_DEFINE_CONST_DICT(gen_instance_locals_dict, gen_instance_locals_dict_table);
 
 MP_DEFINE_CONST_OBJ_TYPE(
     mp_type_gen_instance,

+ 2 - 2
py/objgetitemiter.c

@@ -35,7 +35,7 @@ typedef struct _mp_obj_getitem_iter_t {
     mp_obj_t args[3];
 } mp_obj_getitem_iter_t;
 
-static mp_obj_t it_iternext(mp_obj_t self_in) {
+STATIC mp_obj_t it_iternext(mp_obj_t self_in) {
     mp_obj_getitem_iter_t *self = MP_OBJ_TO_PTR(self_in);
     nlr_buf_t nlr;
     if (nlr_push(&nlr) == 0) {
@@ -56,7 +56,7 @@ static mp_obj_t it_iternext(mp_obj_t self_in) {
     }
 }
 
-static MP_DEFINE_CONST_OBJ_TYPE(
+STATIC MP_DEFINE_CONST_OBJ_TYPE(
     mp_type_it,
     MP_QSTR_iterator,
     MP_TYPE_FLAG_ITER_IS_ITERNEXT,

+ 10 - 10
py/objint.c

@@ -40,7 +40,7 @@
 #endif
 
 // This dispatcher function is expected to be independent of the implementation of long int
-static mp_obj_t mp_obj_int_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
+STATIC mp_obj_t mp_obj_int_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
     (void)type_in;
     mp_arg_check_num(n_args, n_kw, 0, 2, false);
 
@@ -83,7 +83,7 @@ typedef enum {
     MP_FP_CLASS_OVERFLOW
 } mp_fp_as_int_class_t;
 
-static mp_fp_as_int_class_t mp_classify_fp_as_int(mp_float_t val) {
+STATIC mp_fp_as_int_class_t mp_classify_fp_as_int(mp_float_t val) {
     union {
         mp_float_t f;
         #if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT
@@ -193,7 +193,7 @@ void mp_obj_int_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t
     }
 }
 
-static const uint8_t log_base2_floor[] = {
+STATIC const uint8_t log_base2_floor[] = {
     0, 1, 1, 2,
     2, 2, 2, 3,
     3, 3, 3, 3,
@@ -388,7 +388,7 @@ mp_obj_t mp_obj_int_binary_op_extra_cases(mp_binary_op_t op, mp_obj_t lhs_in, mp
 }
 
 // this is a classmethod
-static mp_obj_t int_from_bytes(size_t n_args, const mp_obj_t *args) {
+STATIC mp_obj_t int_from_bytes(size_t n_args, const mp_obj_t *args) {
     // TODO: Support signed param (assumes signed=False at the moment)
     (void)n_args;
 
@@ -417,10 +417,10 @@ static mp_obj_t int_from_bytes(size_t n_args, const mp_obj_t *args) {
     return mp_obj_new_int_from_uint(value);
 }
 
-static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(int_from_bytes_fun_obj, 3, 4, int_from_bytes);
-static MP_DEFINE_CONST_CLASSMETHOD_OBJ(int_from_bytes_obj, MP_ROM_PTR(&int_from_bytes_fun_obj));
+STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(int_from_bytes_fun_obj, 3, 4, int_from_bytes);
+STATIC MP_DEFINE_CONST_CLASSMETHOD_OBJ(int_from_bytes_obj, MP_ROM_PTR(&int_from_bytes_fun_obj));
 
-static mp_obj_t int_to_bytes(size_t n_args, const mp_obj_t *args) {
+STATIC mp_obj_t int_to_bytes(size_t n_args, const mp_obj_t *args) {
     // TODO: Support signed param (assumes signed=False)
     (void)n_args;
 
@@ -448,14 +448,14 @@ static mp_obj_t int_to_bytes(size_t n_args, const mp_obj_t *args) {
 
     return mp_obj_new_bytes_from_vstr(&vstr);
 }
-static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(int_to_bytes_obj, 3, 4, int_to_bytes);
+STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(int_to_bytes_obj, 3, 4, int_to_bytes);
 
-static const mp_rom_map_elem_t int_locals_dict_table[] = {
+STATIC const mp_rom_map_elem_t int_locals_dict_table[] = {
     { MP_ROM_QSTR(MP_QSTR_from_bytes), MP_ROM_PTR(&int_from_bytes_obj) },
     { MP_ROM_QSTR(MP_QSTR_to_bytes), MP_ROM_PTR(&int_to_bytes_obj) },
 };
 
-static MP_DEFINE_CONST_DICT(int_locals_dict, int_locals_dict_table);
+STATIC MP_DEFINE_CONST_DICT(int_locals_dict, int_locals_dict_table);
 
 MP_DEFINE_CONST_OBJ_TYPE(
     mp_type_int,

+ 2 - 2
py/objint_mpz.c

@@ -43,7 +43,7 @@
 // Export value for sys.maxsize
 // *FORMAT-OFF*
 #define DIG_MASK ((MPZ_LONG_1 << MPZ_DIG_SIZE) - 1)
-static const mpz_dig_t maxsize_dig[] = {
+STATIC const mpz_dig_t maxsize_dig[] = {
     #define NUM_DIG 1
     (MP_SSIZE_MAX >> MPZ_DIG_SIZE * 0) & DIG_MASK,
     #if (MP_SSIZE_MAX >> MPZ_DIG_SIZE * 0) > DIG_MASK
@@ -335,7 +335,7 @@ mp_obj_t mp_obj_int_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_i
 }
 
 #if MICROPY_PY_BUILTINS_POW3
-static mpz_t *mp_mpz_for_int(mp_obj_t arg, mpz_t *temp) {
+STATIC mpz_t *mp_mpz_for_int(mp_obj_t arg, mpz_t *temp) {
     if (mp_obj_is_small_int(arg)) {
         mpz_init_from_int(temp, MP_OBJ_SMALL_INT_VALUE(arg));
         return temp;

+ 35 - 35
py/objlist.c

@@ -31,10 +31,10 @@
 #include "py/runtime.h"
 #include "py/stackctrl.h"
 
-static mp_obj_t mp_obj_new_list_iterator(mp_obj_t list, size_t cur, mp_obj_iter_buf_t *iter_buf);
-static mp_obj_list_t *list_new(size_t n);
-static mp_obj_t list_extend(mp_obj_t self_in, mp_obj_t arg_in);
-static mp_obj_t list_pop(size_t n_args, const mp_obj_t *args);
+STATIC mp_obj_t mp_obj_new_list_iterator(mp_obj_t list, size_t cur, mp_obj_iter_buf_t *iter_buf);
+STATIC mp_obj_list_t *list_new(size_t n);
+STATIC mp_obj_t list_extend(mp_obj_t self_in, mp_obj_t arg_in);
+STATIC mp_obj_t list_pop(size_t n_args, const mp_obj_t *args);
 
 // TODO: Move to mpconfig.h
 #define LIST_MIN_ALLOC 4
@@ -42,7 +42,7 @@ static mp_obj_t list_pop(size_t n_args, const mp_obj_t *args);
 /******************************************************************************/
 /* list                                                                       */
 
-static void list_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
+STATIC void list_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
     mp_obj_list_t *o = MP_OBJ_TO_PTR(o_in);
     const char *item_separator = ", ";
     if (!(MICROPY_PY_JSON && kind == PRINT_JSON)) {
@@ -62,7 +62,7 @@ static void list_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t k
     mp_print_str(print, "]");
 }
 
-static mp_obj_t list_extend_from_iter(mp_obj_t list, mp_obj_t iterable) {
+STATIC mp_obj_t list_extend_from_iter(mp_obj_t list, mp_obj_t iterable) {
     mp_obj_t iter = mp_getiter(iterable, NULL);
     mp_obj_t item;
     while ((item = mp_iternext(iter)) != MP_OBJ_STOP_ITERATION) {
@@ -90,7 +90,7 @@ mp_obj_t mp_obj_list_make_new(const mp_obj_type_t *type_in, size_t n_args, size_
     }
 }
 
-static mp_obj_t list_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
+STATIC mp_obj_t list_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
     mp_obj_list_t *self = MP_OBJ_TO_PTR(self_in);
     switch (op) {
         case MP_UNARY_OP_BOOL:
@@ -108,7 +108,7 @@ static mp_obj_t list_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
     }
 }
 
-static mp_obj_t list_binary_op(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs) {
+STATIC mp_obj_t list_binary_op(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs) {
     mp_obj_list_t *o = MP_OBJ_TO_PTR(lhs);
     switch (op) {
         case MP_BINARY_OP_ADD: {
@@ -158,7 +158,7 @@ static mp_obj_t list_binary_op(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs) {
     }
 }
 
-static mp_obj_t list_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
+STATIC mp_obj_t list_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
     if (value == MP_OBJ_NULL) {
         // delete
         #if MICROPY_PY_BUILTINS_SLICE
@@ -234,7 +234,7 @@ static mp_obj_t list_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
     }
 }
 
-static mp_obj_t list_getiter(mp_obj_t o_in, mp_obj_iter_buf_t *iter_buf) {
+STATIC mp_obj_t list_getiter(mp_obj_t o_in, mp_obj_iter_buf_t *iter_buf) {
     return mp_obj_new_list_iterator(o_in, 0, iter_buf);
 }
 
@@ -250,7 +250,7 @@ mp_obj_t mp_obj_list_append(mp_obj_t self_in, mp_obj_t arg) {
     return mp_const_none; // return None, as per CPython
 }
 
-static mp_obj_t list_extend(mp_obj_t self_in, mp_obj_t arg_in) {
+STATIC mp_obj_t list_extend(mp_obj_t self_in, mp_obj_t arg_in) {
     mp_check_self(mp_obj_is_type(self_in, &mp_type_list));
     if (mp_obj_is_type(arg_in, &mp_type_list)) {
         mp_obj_list_t *self = MP_OBJ_TO_PTR(self_in);
@@ -271,7 +271,7 @@ static mp_obj_t list_extend(mp_obj_t self_in, mp_obj_t arg_in) {
     return mp_const_none; // return None, as per CPython
 }
 
-static mp_obj_t list_pop(size_t n_args, const mp_obj_t *args) {
+STATIC mp_obj_t list_pop(size_t n_args, const mp_obj_t *args) {
     mp_check_self(mp_obj_is_type(args[0], &mp_type_list));
     mp_obj_list_t *self = MP_OBJ_TO_PTR(args[0]);
     if (self->len == 0) {
@@ -290,7 +290,7 @@ static mp_obj_t list_pop(size_t n_args, const mp_obj_t *args) {
     return ret;
 }
 
-static void mp_quicksort(mp_obj_t *head, mp_obj_t *tail, mp_obj_t key_fn, mp_obj_t binop_less_result) {
+STATIC void mp_quicksort(mp_obj_t *head, mp_obj_t *tail, mp_obj_t key_fn, mp_obj_t binop_less_result) {
     MP_STACK_CHECK();
     while (head < tail) {
         mp_obj_t *h = head - 1;
@@ -348,7 +348,7 @@ mp_obj_t mp_obj_list_sort(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_
     return mp_const_none;
 }
 
-static mp_obj_t list_clear(mp_obj_t self_in) {
+STATIC mp_obj_t list_clear(mp_obj_t self_in) {
     mp_check_self(mp_obj_is_type(self_in, &mp_type_list));
     mp_obj_list_t *self = MP_OBJ_TO_PTR(self_in);
     self->len = 0;
@@ -358,25 +358,25 @@ static mp_obj_t list_clear(mp_obj_t self_in) {
     return mp_const_none;
 }
 
-static mp_obj_t list_copy(mp_obj_t self_in) {
+STATIC mp_obj_t list_copy(mp_obj_t self_in) {
     mp_check_self(mp_obj_is_type(self_in, &mp_type_list));
     mp_obj_list_t *self = MP_OBJ_TO_PTR(self_in);
     return mp_obj_new_list(self->len, self->items);
 }
 
-static mp_obj_t list_count(mp_obj_t self_in, mp_obj_t value) {
+STATIC mp_obj_t list_count(mp_obj_t self_in, mp_obj_t value) {
     mp_check_self(mp_obj_is_type(self_in, &mp_type_list));
     mp_obj_list_t *self = MP_OBJ_TO_PTR(self_in);
     return mp_seq_count_obj(self->items, self->len, value);
 }
 
-static mp_obj_t list_index(size_t n_args, const mp_obj_t *args) {
+STATIC mp_obj_t list_index(size_t n_args, const mp_obj_t *args) {
     mp_check_self(mp_obj_is_type(args[0], &mp_type_list));
     mp_obj_list_t *self = MP_OBJ_TO_PTR(args[0]);
     return mp_seq_index_obj(self->items, self->len, n_args, args);
 }
 
-static mp_obj_t list_insert(mp_obj_t self_in, mp_obj_t idx, mp_obj_t obj) {
+STATIC mp_obj_t list_insert(mp_obj_t self_in, mp_obj_t idx, mp_obj_t obj) {
     mp_check_self(mp_obj_is_type(self_in, &mp_type_list));
     mp_obj_list_t *self = MP_OBJ_TO_PTR(self_in);
     // insert has its own strange index logic
@@ -410,7 +410,7 @@ mp_obj_t mp_obj_list_remove(mp_obj_t self_in, mp_obj_t value) {
     return mp_const_none;
 }
 
-static mp_obj_t list_reverse(mp_obj_t self_in) {
+STATIC mp_obj_t list_reverse(mp_obj_t self_in) {
     mp_check_self(mp_obj_is_type(self_in, &mp_type_list));
     mp_obj_list_t *self = MP_OBJ_TO_PTR(self_in);
 
@@ -424,19 +424,19 @@ static mp_obj_t list_reverse(mp_obj_t self_in) {
     return mp_const_none;
 }
 
-static MP_DEFINE_CONST_FUN_OBJ_2(list_append_obj, mp_obj_list_append);
-static MP_DEFINE_CONST_FUN_OBJ_2(list_extend_obj, list_extend);
-static MP_DEFINE_CONST_FUN_OBJ_1(list_clear_obj, list_clear);
-static MP_DEFINE_CONST_FUN_OBJ_1(list_copy_obj, list_copy);
-static MP_DEFINE_CONST_FUN_OBJ_2(list_count_obj, list_count);
-static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(list_index_obj, 2, 4, list_index);
-static MP_DEFINE_CONST_FUN_OBJ_3(list_insert_obj, list_insert);
-static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(list_pop_obj, 1, 2, list_pop);
-static MP_DEFINE_CONST_FUN_OBJ_2(list_remove_obj, mp_obj_list_remove);
-static MP_DEFINE_CONST_FUN_OBJ_1(list_reverse_obj, list_reverse);
-static MP_DEFINE_CONST_FUN_OBJ_KW(list_sort_obj, 1, mp_obj_list_sort);
-
-static const mp_rom_map_elem_t list_locals_dict_table[] = {
+STATIC MP_DEFINE_CONST_FUN_OBJ_2(list_append_obj, mp_obj_list_append);
+STATIC MP_DEFINE_CONST_FUN_OBJ_2(list_extend_obj, list_extend);
+STATIC MP_DEFINE_CONST_FUN_OBJ_1(list_clear_obj, list_clear);
+STATIC MP_DEFINE_CONST_FUN_OBJ_1(list_copy_obj, list_copy);
+STATIC MP_DEFINE_CONST_FUN_OBJ_2(list_count_obj, list_count);
+STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(list_index_obj, 2, 4, list_index);
+STATIC MP_DEFINE_CONST_FUN_OBJ_3(list_insert_obj, list_insert);
+STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(list_pop_obj, 1, 2, list_pop);
+STATIC MP_DEFINE_CONST_FUN_OBJ_2(list_remove_obj, mp_obj_list_remove);
+STATIC MP_DEFINE_CONST_FUN_OBJ_1(list_reverse_obj, list_reverse);
+STATIC MP_DEFINE_CONST_FUN_OBJ_KW(list_sort_obj, 1, mp_obj_list_sort);
+
+STATIC const mp_rom_map_elem_t list_locals_dict_table[] = {
     { MP_ROM_QSTR(MP_QSTR_append), MP_ROM_PTR(&list_append_obj) },
     { MP_ROM_QSTR(MP_QSTR_clear), MP_ROM_PTR(&list_clear_obj) },
     { MP_ROM_QSTR(MP_QSTR_copy), MP_ROM_PTR(&list_copy_obj) },
@@ -450,7 +450,7 @@ static const mp_rom_map_elem_t list_locals_dict_table[] = {
     { MP_ROM_QSTR(MP_QSTR_sort), MP_ROM_PTR(&list_sort_obj) },
 };
 
-static MP_DEFINE_CONST_DICT(list_locals_dict, list_locals_dict_table);
+STATIC MP_DEFINE_CONST_DICT(list_locals_dict, list_locals_dict_table);
 
 MP_DEFINE_CONST_OBJ_TYPE(
     mp_type_list,
@@ -474,7 +474,7 @@ void mp_obj_list_init(mp_obj_list_t *o, size_t n) {
     mp_seq_clear(o->items, n, o->alloc, sizeof(*o->items));
 }
 
-static mp_obj_list_t *list_new(size_t n) {
+STATIC mp_obj_list_t *list_new(size_t n) {
     mp_obj_list_t *o = m_new_obj(mp_obj_list_t);
     mp_obj_list_init(o, n);
     return o;
@@ -519,7 +519,7 @@ typedef struct _mp_obj_list_it_t {
     size_t cur;
 } mp_obj_list_it_t;
 
-static mp_obj_t list_it_iternext(mp_obj_t self_in) {
+STATIC mp_obj_t list_it_iternext(mp_obj_t self_in) {
     mp_obj_list_it_t *self = MP_OBJ_TO_PTR(self_in);
     mp_obj_list_t *list = MP_OBJ_TO_PTR(self->list);
     if (self->cur < list->len) {

+ 3 - 3
py/objmap.c

@@ -36,9 +36,9 @@ typedef struct _mp_obj_map_t {
     mp_obj_t iters[];
 } mp_obj_map_t;
 
-static mp_obj_t map_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
+STATIC mp_obj_t map_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
     mp_arg_check_num(n_args, n_kw, 2, MP_OBJ_FUN_ARGS_MAX, false);
-    mp_obj_map_t *o = mp_obj_malloc_var(mp_obj_map_t, iters, mp_obj_t, n_args - 1, type);
+    mp_obj_map_t *o = mp_obj_malloc_var(mp_obj_map_t, mp_obj_t, n_args - 1, type);
     o->n_iters = n_args - 1;
     o->fun = args[0];
     for (size_t i = 0; i < n_args - 1; i++) {
@@ -47,7 +47,7 @@ static mp_obj_t map_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_
     return MP_OBJ_FROM_PTR(o);
 }
 
-static mp_obj_t map_iternext(mp_obj_t self_in) {
+STATIC mp_obj_t map_iternext(mp_obj_t self_in) {
     mp_check_self(mp_obj_is_type(self_in, &mp_type_map));
     mp_obj_map_t *self = MP_OBJ_TO_PTR(self_in);
     mp_obj_t *nextses = m_new(mp_obj_t, self->n_iters);

+ 7 - 7
py/objmodule.c

@@ -34,7 +34,7 @@
 #include "py/runtime.h"
 #include "py/builtin.h"
 
-static void module_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
+STATIC void module_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
     (void)kind;
     mp_obj_module_t *self = MP_OBJ_TO_PTR(self_in);
 
@@ -57,9 +57,9 @@ static void module_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kin
     mp_printf(print, "<module '%s'>", module_name);
 }
 
-static void module_attr_try_delegation(mp_obj_t self_in, qstr attr, mp_obj_t *dest);
+STATIC void module_attr_try_delegation(mp_obj_t self_in, qstr attr, mp_obj_t *dest);
 
-static void module_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
+STATIC void module_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
     mp_obj_module_t *self = MP_OBJ_TO_PTR(self_in);
     if (dest[0] == MP_OBJ_NULL) {
         // load attribute
@@ -146,13 +146,13 @@ mp_obj_t mp_obj_new_module(qstr module_name) {
 /******************************************************************************/
 // Global module table and related functions
 
-static const mp_rom_map_elem_t mp_builtin_module_table[] = {
+STATIC const mp_rom_map_elem_t mp_builtin_module_table[] = {
     // built-in modules declared with MP_REGISTER_MODULE()
     MICROPY_REGISTERED_MODULES
 };
 MP_DEFINE_CONST_MAP(mp_builtin_module_map, mp_builtin_module_table);
 
-static const mp_rom_map_elem_t mp_builtin_extensible_module_table[] = {
+STATIC const mp_rom_map_elem_t mp_builtin_extensible_module_table[] = {
     // built-in modules declared with MP_REGISTER_EXTENSIBLE_MODULE()
     MICROPY_REGISTERED_EXTENSIBLE_MODULES
 };
@@ -164,7 +164,7 @@ typedef struct _mp_module_delegation_entry_t {
     mp_attr_fun_t fun;
 } mp_module_delegation_entry_t;
 
-static const mp_module_delegation_entry_t mp_builtin_module_delegation_table[] = {
+STATIC const mp_module_delegation_entry_t mp_builtin_module_delegation_table[] = {
     // delegation entries declared with MP_REGISTER_MODULE_DELEGATION()
     MICROPY_MODULE_DELEGATIONS
 };
@@ -223,7 +223,7 @@ mp_obj_t mp_module_get_builtin(qstr module_name, bool extensible) {
     return elem->value;
 }
 
-static void module_attr_try_delegation(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
+STATIC void module_attr_try_delegation(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
     #if MICROPY_MODULE_ATTR_DELEGATION && defined(MICROPY_MODULE_DELEGATIONS)
     // Delegate lookup to a module's custom attr method.
     size_t n = MP_ARRAY_SIZE(mp_builtin_module_delegation_table);

+ 7 - 7
py/objnamedtuple.c

@@ -44,7 +44,7 @@ size_t mp_obj_namedtuple_find_field(const mp_obj_namedtuple_type_t *type, qstr n
 }
 
 #if MICROPY_PY_COLLECTIONS_NAMEDTUPLE__ASDICT
-static mp_obj_t namedtuple_asdict(mp_obj_t self_in) {
+STATIC mp_obj_t namedtuple_asdict(mp_obj_t self_in) {
     mp_obj_namedtuple_t *self = MP_OBJ_TO_PTR(self_in);
     const qstr *fields = ((mp_obj_namedtuple_type_t *)self->tuple.base.type)->fields;
     mp_obj_t dict = mp_obj_new_dict(self->tuple.len);
@@ -60,7 +60,7 @@ static mp_obj_t namedtuple_asdict(mp_obj_t self_in) {
 MP_DEFINE_CONST_FUN_OBJ_1(namedtuple_asdict_obj, namedtuple_asdict);
 #endif
 
-static void namedtuple_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
+STATIC void namedtuple_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
     (void)kind;
     mp_obj_namedtuple_t *o = MP_OBJ_TO_PTR(o_in);
     mp_printf(print, "%q", o->tuple.base.type->name);
@@ -68,7 +68,7 @@ static void namedtuple_print(const mp_print_t *print, mp_obj_t o_in, mp_print_ki
     mp_obj_attrtuple_print_helper(print, fields, &o->tuple);
 }
 
-static void namedtuple_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
+STATIC void namedtuple_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
     if (dest[0] == MP_OBJ_NULL) {
         // load attribute
         mp_obj_namedtuple_t *self = MP_OBJ_TO_PTR(self_in);
@@ -91,7 +91,7 @@ static void namedtuple_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
     }
 }
 
-static mp_obj_t namedtuple_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
+STATIC mp_obj_t namedtuple_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
     const mp_obj_namedtuple_type_t *type = (const mp_obj_namedtuple_type_t *)type_in;
     size_t num_fields = type->n_fields;
     if (n_args + n_kw != num_fields) {
@@ -110,7 +110,7 @@ static mp_obj_t namedtuple_make_new(const mp_obj_type_t *type_in, size_t n_args,
 
     // Create a namedtuple with explicit malloc. Calling mp_obj_new_tuple
     // with num_fields=0 returns a read-only object.
-    mp_obj_tuple_t *tuple = mp_obj_malloc_var(mp_obj_tuple_t, items, mp_obj_t, num_fields, type_in);
+    mp_obj_tuple_t *tuple = mp_obj_malloc_var(mp_obj_tuple_t, mp_obj_t, num_fields, type_in);
     tuple->len = num_fields;
 
     // Copy the positional args into the first slots of the namedtuple
@@ -151,7 +151,7 @@ mp_obj_namedtuple_type_t *mp_obj_new_namedtuple_base(size_t n_fields, mp_obj_t *
     return o;
 }
 
-static mp_obj_t mp_obj_new_namedtuple_type(qstr name, size_t n_fields, mp_obj_t *fields) {
+STATIC mp_obj_t mp_obj_new_namedtuple_type(qstr name, size_t n_fields, mp_obj_t *fields) {
     mp_obj_namedtuple_type_t *o = mp_obj_new_namedtuple_base(n_fields, fields);
     mp_obj_type_t *type = (mp_obj_type_t *)&o->base;
     type->base.type = &mp_type_type;
@@ -168,7 +168,7 @@ static mp_obj_t mp_obj_new_namedtuple_type(qstr name, size_t n_fields, mp_obj_t
     return MP_OBJ_FROM_PTR(o);
 }
 
-static mp_obj_t new_namedtuple_type(mp_obj_t name_in, mp_obj_t fields_in) {
+STATIC mp_obj_t new_namedtuple_type(mp_obj_t name_in, mp_obj_t fields_in) {
     qstr name = mp_obj_str_get_qstr(name_in);
     size_t n_fields;
     mp_obj_t *fields;

+ 1 - 1
py/objnone.c

@@ -34,7 +34,7 @@ typedef struct _mp_obj_none_t {
 } mp_obj_none_t;
 #endif
 
-static void none_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
+STATIC void none_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
     (void)self_in;
     if (MICROPY_PY_JSON && kind == PRINT_JSON) {
         mp_print_str(print, "null");

+ 12 - 12
py/objobject.c

@@ -33,7 +33,7 @@ typedef struct _mp_obj_object_t {
     mp_obj_base_t base;
 } mp_obj_object_t;
 
-static mp_obj_t object_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
+STATIC mp_obj_t object_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
     (void)args;
     mp_arg_check_num(n_args, n_kw, 0, 0, false);
     mp_obj_object_t *o = mp_obj_malloc(mp_obj_object_t, type);
@@ -41,13 +41,13 @@ static mp_obj_t object_make_new(const mp_obj_type_t *type, size_t n_args, size_t
 }
 
 #if MICROPY_CPYTHON_COMPAT
-static mp_obj_t object___init__(mp_obj_t self) {
+STATIC mp_obj_t object___init__(mp_obj_t self) {
     (void)self;
     return mp_const_none;
 }
-static MP_DEFINE_CONST_FUN_OBJ_1(object___init___obj, object___init__);
+STATIC MP_DEFINE_CONST_FUN_OBJ_1(object___init___obj, object___init__);
 
-static mp_obj_t object___new__(mp_obj_t cls) {
+STATIC mp_obj_t object___new__(mp_obj_t cls) {
     if (!mp_obj_is_type(cls, &mp_type_type) || !mp_obj_is_instance_type((mp_obj_type_t *)MP_OBJ_TO_PTR(cls))) {
         mp_raise_TypeError(MP_ERROR_TEXT("arg must be user-type"));
     }
@@ -58,11 +58,11 @@ static mp_obj_t object___new__(mp_obj_t cls) {
     const mp_obj_type_t *native_base;
     return MP_OBJ_FROM_PTR(mp_obj_new_instance(MP_OBJ_TO_PTR(cls), &native_base));
 }
-static MP_DEFINE_CONST_FUN_OBJ_1(object___new___fun_obj, object___new__);
-static MP_DEFINE_CONST_STATICMETHOD_OBJ(object___new___obj, MP_ROM_PTR(&object___new___fun_obj));
+STATIC MP_DEFINE_CONST_FUN_OBJ_1(object___new___fun_obj, object___new__);
+STATIC MP_DEFINE_CONST_STATICMETHOD_OBJ(object___new___obj, MP_ROM_PTR(&object___new___fun_obj));
 
 #if MICROPY_PY_DELATTR_SETATTR
-static mp_obj_t object___setattr__(mp_obj_t self_in, mp_obj_t attr, mp_obj_t value) {
+STATIC mp_obj_t object___setattr__(mp_obj_t self_in, mp_obj_t attr, mp_obj_t value) {
     if (!mp_obj_is_instance_type(mp_obj_get_type(self_in))) {
         mp_raise_TypeError(MP_ERROR_TEXT("arg must be user-type"));
     }
@@ -75,9 +75,9 @@ static mp_obj_t object___setattr__(mp_obj_t self_in, mp_obj_t attr, mp_obj_t val
     mp_map_lookup(&self->members, attr, MP_MAP_LOOKUP_ADD_IF_NOT_FOUND)->value = value;
     return mp_const_none;
 }
-static MP_DEFINE_CONST_FUN_OBJ_3(object___setattr___obj, object___setattr__);
+STATIC MP_DEFINE_CONST_FUN_OBJ_3(object___setattr___obj, object___setattr__);
 
-static mp_obj_t object___delattr__(mp_obj_t self_in, mp_obj_t attr) {
+STATIC mp_obj_t object___delattr__(mp_obj_t self_in, mp_obj_t attr) {
     if (!mp_obj_is_instance_type(mp_obj_get_type(self_in))) {
         mp_raise_TypeError(MP_ERROR_TEXT("arg must be user-type"));
     }
@@ -92,10 +92,10 @@ static mp_obj_t object___delattr__(mp_obj_t self_in, mp_obj_t attr) {
     }
     return mp_const_none;
 }
-static MP_DEFINE_CONST_FUN_OBJ_2(object___delattr___obj, object___delattr__);
+STATIC MP_DEFINE_CONST_FUN_OBJ_2(object___delattr___obj, object___delattr__);
 #endif
 
-static const mp_rom_map_elem_t object_locals_dict_table[] = {
+STATIC const mp_rom_map_elem_t object_locals_dict_table[] = {
     #if MICROPY_CPYTHON_COMPAT
     { MP_ROM_QSTR(MP_QSTR___init__), MP_ROM_PTR(&object___init___obj) },
     #endif
@@ -108,7 +108,7 @@ static const mp_rom_map_elem_t object_locals_dict_table[] = {
     #endif
 };
 
-static MP_DEFINE_CONST_DICT(object_locals_dict, object_locals_dict_table);
+STATIC MP_DEFINE_CONST_DICT(object_locals_dict, object_locals_dict_table);
 #endif
 
 #if MICROPY_CPYTHON_COMPAT

+ 5 - 5
py/objpolyiter.c

@@ -39,7 +39,7 @@ typedef struct _mp_obj_polymorph_iter_t {
     mp_fun_1_t iternext;
 } mp_obj_polymorph_iter_t;
 
-static mp_obj_t polymorph_it_iternext(mp_obj_t self_in) {
+STATIC mp_obj_t polymorph_it_iternext(mp_obj_t self_in) {
     mp_obj_polymorph_iter_t *self = MP_OBJ_TO_PTR(self_in);
     // Redirect call to object instance's iternext method
     return self->iternext(self_in);
@@ -64,17 +64,17 @@ typedef struct _mp_obj_polymorph_iter_with_finaliser_t {
     mp_fun_1_t finaliser;
 } mp_obj_polymorph_with_finaliser_iter_t;
 
-static mp_obj_t mp_obj_polymorph_iter_del(mp_obj_t self_in) {
+STATIC mp_obj_t mp_obj_polymorph_iter_del(mp_obj_t self_in) {
     mp_obj_polymorph_with_finaliser_iter_t *self = MP_OBJ_TO_PTR(self_in);
     // Redirect call to object instance's finaliser method
     return self->finaliser(self_in);
 }
-static MP_DEFINE_CONST_FUN_OBJ_1(mp_obj_polymorph_iter_del_obj, mp_obj_polymorph_iter_del);
+STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_obj_polymorph_iter_del_obj, mp_obj_polymorph_iter_del);
 
-static const mp_rom_map_elem_t mp_obj_polymorph_iter_locals_dict_table[] = {
+STATIC const mp_rom_map_elem_t mp_obj_polymorph_iter_locals_dict_table[] = {
     { MP_ROM_QSTR(MP_QSTR___del__), MP_ROM_PTR(&mp_obj_polymorph_iter_del_obj) },
 };
-static MP_DEFINE_CONST_DICT(mp_obj_polymorph_iter_locals_dict, mp_obj_polymorph_iter_locals_dict_table);
+STATIC MP_DEFINE_CONST_DICT(mp_obj_polymorph_iter_locals_dict, mp_obj_polymorph_iter_locals_dict_table);
 
 MP_DEFINE_CONST_OBJ_TYPE(
     mp_type_polymorph_iter_with_finaliser,

+ 9 - 9
py/objproperty.c

@@ -36,7 +36,7 @@ typedef struct _mp_obj_property_t {
     mp_obj_t proxy[3]; // getter, setter, deleter
 } mp_obj_property_t;
 
-static mp_obj_t property_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
+STATIC mp_obj_t property_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
     enum { ARG_fget, ARG_fset, ARG_fdel, ARG_doc };
     static const mp_arg_t allowed_args[] = {
         { MP_QSTR_, MP_ARG_OBJ, {.u_rom_obj = MP_ROM_NONE} },
@@ -55,40 +55,40 @@ static mp_obj_t property_make_new(const mp_obj_type_t *type, size_t n_args, size
     return MP_OBJ_FROM_PTR(o);
 }
 
-static mp_obj_t property_getter(mp_obj_t self_in, mp_obj_t getter) {
+STATIC mp_obj_t property_getter(mp_obj_t self_in, mp_obj_t getter) {
     mp_obj_property_t *p2 = m_new_obj(mp_obj_property_t);
     *p2 = *(mp_obj_property_t *)MP_OBJ_TO_PTR(self_in);
     p2->proxy[0] = getter;
     return MP_OBJ_FROM_PTR(p2);
 }
 
-static MP_DEFINE_CONST_FUN_OBJ_2(property_getter_obj, property_getter);
+STATIC MP_DEFINE_CONST_FUN_OBJ_2(property_getter_obj, property_getter);
 
-static mp_obj_t property_setter(mp_obj_t self_in, mp_obj_t setter) {
+STATIC mp_obj_t property_setter(mp_obj_t self_in, mp_obj_t setter) {
     mp_obj_property_t *p2 = m_new_obj(mp_obj_property_t);
     *p2 = *(mp_obj_property_t *)MP_OBJ_TO_PTR(self_in);
     p2->proxy[1] = setter;
     return MP_OBJ_FROM_PTR(p2);
 }
 
-static MP_DEFINE_CONST_FUN_OBJ_2(property_setter_obj, property_setter);
+STATIC MP_DEFINE_CONST_FUN_OBJ_2(property_setter_obj, property_setter);
 
-static mp_obj_t property_deleter(mp_obj_t self_in, mp_obj_t deleter) {
+STATIC mp_obj_t property_deleter(mp_obj_t self_in, mp_obj_t deleter) {
     mp_obj_property_t *p2 = m_new_obj(mp_obj_property_t);
     *p2 = *(mp_obj_property_t *)MP_OBJ_TO_PTR(self_in);
     p2->proxy[2] = deleter;
     return MP_OBJ_FROM_PTR(p2);
 }
 
-static MP_DEFINE_CONST_FUN_OBJ_2(property_deleter_obj, property_deleter);
+STATIC MP_DEFINE_CONST_FUN_OBJ_2(property_deleter_obj, property_deleter);
 
-static const mp_rom_map_elem_t property_locals_dict_table[] = {
+STATIC const mp_rom_map_elem_t property_locals_dict_table[] = {
     { MP_ROM_QSTR(MP_QSTR_getter), MP_ROM_PTR(&property_getter_obj) },
     { MP_ROM_QSTR(MP_QSTR_setter), MP_ROM_PTR(&property_setter_obj) },
     { MP_ROM_QSTR(MP_QSTR_deleter), MP_ROM_PTR(&property_deleter_obj) },
 };
 
-static MP_DEFINE_CONST_DICT(property_locals_dict, property_locals_dict_table);
+STATIC MP_DEFINE_CONST_DICT(property_locals_dict, property_locals_dict_table);
 
 MP_DEFINE_CONST_OBJ_TYPE(
     mp_type_property,

+ 11 - 11
py/objrange.c

@@ -39,7 +39,7 @@ typedef struct _mp_obj_range_it_t {
     mp_int_t step;
 } mp_obj_range_it_t;
 
-static mp_obj_t range_it_iternext(mp_obj_t o_in) {
+STATIC mp_obj_t range_it_iternext(mp_obj_t o_in) {
     mp_obj_range_it_t *o = MP_OBJ_TO_PTR(o_in);
     if ((o->step > 0 && o->cur < o->stop) || (o->step < 0 && o->cur > o->stop)) {
         mp_obj_t o_out = MP_OBJ_NEW_SMALL_INT(o->cur);
@@ -50,14 +50,14 @@ static mp_obj_t range_it_iternext(mp_obj_t o_in) {
     }
 }
 
-static MP_DEFINE_CONST_OBJ_TYPE(
+STATIC MP_DEFINE_CONST_OBJ_TYPE(
     mp_type_range_it,
     MP_QSTR_iterator,
     MP_TYPE_FLAG_ITER_IS_ITERNEXT,
     iter, range_it_iternext
     );
 
-static mp_obj_t mp_obj_new_range_iterator(mp_int_t cur, mp_int_t stop, mp_int_t step, mp_obj_iter_buf_t *iter_buf) {
+STATIC mp_obj_t mp_obj_new_range_iterator(mp_int_t cur, mp_int_t stop, mp_int_t step, mp_obj_iter_buf_t *iter_buf) {
     assert(sizeof(mp_obj_range_it_t) <= sizeof(mp_obj_iter_buf_t));
     mp_obj_range_it_t *o = (mp_obj_range_it_t *)iter_buf;
     o->base.type = &mp_type_range_it;
@@ -78,7 +78,7 @@ typedef struct _mp_obj_range_t {
     mp_int_t step;
 } mp_obj_range_t;
 
-static void range_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
+STATIC void range_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
     (void)kind;
     mp_obj_range_t *self = MP_OBJ_TO_PTR(self_in);
     mp_printf(print, "range(" INT_FMT ", " INT_FMT "", self->start, self->stop);
@@ -89,7 +89,7 @@ static void range_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind
     }
 }
 
-static mp_obj_t range_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
+STATIC mp_obj_t range_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
     mp_arg_check_num(n_args, n_kw, 1, 3, false);
 
     mp_obj_range_t *o = mp_obj_malloc(mp_obj_range_t, type);
@@ -112,7 +112,7 @@ static mp_obj_t range_make_new(const mp_obj_type_t *type, size_t n_args, size_t
     return MP_OBJ_FROM_PTR(o);
 }
 
-static mp_int_t range_len(mp_obj_range_t *self) {
+STATIC mp_int_t range_len(mp_obj_range_t *self) {
     // When computing length, need to take into account step!=1 and step<0.
     mp_int_t len = self->stop - self->start + self->step;
     if (self->step > 0) {
@@ -127,7 +127,7 @@ static mp_int_t range_len(mp_obj_range_t *self) {
     return len;
 }
 
-static mp_obj_t range_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
+STATIC mp_obj_t range_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
     mp_obj_range_t *self = MP_OBJ_TO_PTR(self_in);
     mp_int_t len = range_len(self);
     switch (op) {
@@ -141,7 +141,7 @@ static mp_obj_t range_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
 }
 
 #if MICROPY_PY_BUILTINS_RANGE_BINOP
-static mp_obj_t range_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
+STATIC mp_obj_t range_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
     if (!mp_obj_is_type(rhs_in, &mp_type_range) || op != MP_BINARY_OP_EQUAL) {
         return MP_OBJ_NULL; // op not supported
     }
@@ -158,7 +158,7 @@ static mp_obj_t range_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs
 }
 #endif
 
-static mp_obj_t range_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
+STATIC mp_obj_t range_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
     if (value == MP_OBJ_SENTINEL) {
         // load
         mp_obj_range_t *self = MP_OBJ_TO_PTR(self_in);
@@ -185,14 +185,14 @@ static mp_obj_t range_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
     }
 }
 
-static mp_obj_t range_getiter(mp_obj_t o_in, mp_obj_iter_buf_t *iter_buf) {
+STATIC mp_obj_t range_getiter(mp_obj_t o_in, mp_obj_iter_buf_t *iter_buf) {
     mp_obj_range_t *o = MP_OBJ_TO_PTR(o_in);
     return mp_obj_new_range_iterator(o->start, o->stop, o->step, iter_buf);
 }
 
 
 #if MICROPY_PY_BUILTINS_RANGE_ATTRS
-static void range_attr(mp_obj_t o_in, qstr attr, mp_obj_t *dest) {
+STATIC void range_attr(mp_obj_t o_in, qstr attr, mp_obj_t *dest) {
     if (dest[0] != MP_OBJ_NULL) {
         // not load attribute
         return;

+ 2 - 2
py/objreversed.c

@@ -37,7 +37,7 @@ typedef struct _mp_obj_reversed_t {
     mp_uint_t cur_index;    // current index, plus 1; 0=no more, 1=last one (index 0)
 } mp_obj_reversed_t;
 
-static mp_obj_t reversed_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
+STATIC mp_obj_t reversed_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
     mp_arg_check_num(n_args, n_kw, 1, 1, false);
 
     // check if __reversed__ exists, and if so delegate to it
@@ -54,7 +54,7 @@ static mp_obj_t reversed_make_new(const mp_obj_type_t *type, size_t n_args, size
     return MP_OBJ_FROM_PTR(o);
 }
 
-static mp_obj_t reversed_iternext(mp_obj_t self_in) {
+STATIC mp_obj_t reversed_iternext(mp_obj_t self_in) {
     mp_check_self(mp_obj_is_type(self_in, &mp_type_reversed));
     mp_obj_reversed_t *self = MP_OBJ_TO_PTR(self_in);
 

+ 52 - 52
py/objset.c

@@ -45,7 +45,7 @@ typedef struct _mp_obj_set_it_t {
     size_t cur;
 } mp_obj_set_it_t;
 
-static bool is_set_or_frozenset(mp_obj_t o) {
+STATIC bool is_set_or_frozenset(mp_obj_t o) {
     return mp_obj_is_type(o, &mp_type_set)
            #if MICROPY_PY_BUILTINS_FROZENSET
            || mp_obj_is_type(o, &mp_type_frozenset)
@@ -60,7 +60,7 @@ static bool is_set_or_frozenset(mp_obj_t o) {
 // set or frozenset for methods that operate on both of these types.
 #define check_set_or_frozenset(o) mp_check_self(is_set_or_frozenset(o))
 
-static void set_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
+STATIC void set_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
     (void)kind;
     mp_obj_set_t *self = MP_OBJ_TO_PTR(self_in);
     #if MICROPY_PY_BUILTINS_FROZENSET
@@ -99,7 +99,7 @@ static void set_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t
     #endif
 }
 
-static mp_obj_t set_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
+STATIC mp_obj_t set_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
     mp_arg_check_num(n_args, n_kw, 0, 1, false);
 
     switch (n_args) {
@@ -127,7 +127,7 @@ static mp_obj_t set_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_
     }
 }
 
-static mp_obj_t set_it_iternext(mp_obj_t self_in) {
+STATIC mp_obj_t set_it_iternext(mp_obj_t self_in) {
     mp_obj_set_it_t *self = MP_OBJ_TO_PTR(self_in);
     size_t max = self->set->set.alloc;
     mp_set_t *set = &self->set->set;
@@ -142,7 +142,7 @@ static mp_obj_t set_it_iternext(mp_obj_t self_in) {
     return MP_OBJ_STOP_ITERATION;
 }
 
-static mp_obj_t set_getiter(mp_obj_t set_in, mp_obj_iter_buf_t *iter_buf) {
+STATIC mp_obj_t set_getiter(mp_obj_t set_in, mp_obj_iter_buf_t *iter_buf) {
     assert(sizeof(mp_obj_set_it_t) <= sizeof(mp_obj_iter_buf_t));
     mp_obj_set_it_t *o = (mp_obj_set_it_t *)iter_buf;
     o->base.type = &mp_type_polymorph_iter;
@@ -155,23 +155,23 @@ static mp_obj_t set_getiter(mp_obj_t set_in, mp_obj_iter_buf_t *iter_buf) {
 /******************************************************************************/
 /* set methods                                                                */
 
-static mp_obj_t set_add(mp_obj_t self_in, mp_obj_t item) {
+STATIC mp_obj_t set_add(mp_obj_t self_in, mp_obj_t item) {
     check_set(self_in);
     mp_obj_set_t *self = MP_OBJ_TO_PTR(self_in);
     mp_set_lookup(&self->set, item, MP_MAP_LOOKUP_ADD_IF_NOT_FOUND);
     return mp_const_none;
 }
-static MP_DEFINE_CONST_FUN_OBJ_2(set_add_obj, set_add);
+STATIC MP_DEFINE_CONST_FUN_OBJ_2(set_add_obj, set_add);
 
-static mp_obj_t set_clear(mp_obj_t self_in) {
+STATIC mp_obj_t set_clear(mp_obj_t self_in) {
     check_set(self_in);
     mp_obj_set_t *self = MP_OBJ_TO_PTR(self_in);
     mp_set_clear(&self->set);
     return mp_const_none;
 }
-static MP_DEFINE_CONST_FUN_OBJ_1(set_clear_obj, set_clear);
+STATIC MP_DEFINE_CONST_FUN_OBJ_1(set_clear_obj, set_clear);
 
-static mp_obj_t set_copy(mp_obj_t self_in) {
+STATIC mp_obj_t set_copy(mp_obj_t self_in) {
     check_set_or_frozenset(self_in);
     mp_obj_set_t *self = MP_OBJ_TO_PTR(self_in);
     mp_obj_set_t *other = mp_obj_malloc(mp_obj_set_t, self->base.type);
@@ -180,17 +180,17 @@ static mp_obj_t set_copy(mp_obj_t self_in) {
     memcpy(other->set.table, self->set.table, self->set.alloc * sizeof(mp_obj_t));
     return MP_OBJ_FROM_PTR(other);
 }
-static MP_DEFINE_CONST_FUN_OBJ_1(set_copy_obj, set_copy);
+STATIC MP_DEFINE_CONST_FUN_OBJ_1(set_copy_obj, set_copy);
 
-static mp_obj_t set_discard(mp_obj_t self_in, mp_obj_t item) {
+STATIC mp_obj_t set_discard(mp_obj_t self_in, mp_obj_t item) {
     check_set(self_in);
     mp_obj_set_t *self = MP_OBJ_TO_PTR(self_in);
     mp_set_lookup(&self->set, item, MP_MAP_LOOKUP_REMOVE_IF_FOUND);
     return mp_const_none;
 }
-static MP_DEFINE_CONST_FUN_OBJ_2(set_discard_obj, set_discard);
+STATIC MP_DEFINE_CONST_FUN_OBJ_2(set_discard_obj, set_discard);
 
-static mp_obj_t set_diff_int(size_t n_args, const mp_obj_t *args, bool update) {
+STATIC mp_obj_t set_diff_int(size_t n_args, const mp_obj_t *args, bool update) {
     mp_obj_t self;
     if (update) {
         check_set(args[0]);
@@ -216,18 +216,18 @@ static mp_obj_t set_diff_int(size_t n_args, const mp_obj_t *args, bool update) {
     return self;
 }
 
-static mp_obj_t set_diff(size_t n_args, const mp_obj_t *args) {
+STATIC mp_obj_t set_diff(size_t n_args, const mp_obj_t *args) {
     return set_diff_int(n_args, args, false);
 }
-static MP_DEFINE_CONST_FUN_OBJ_VAR(set_diff_obj, 1, set_diff);
+STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(set_diff_obj, 1, set_diff);
 
-static mp_obj_t set_diff_update(size_t n_args, const mp_obj_t *args) {
+STATIC mp_obj_t set_diff_update(size_t n_args, const mp_obj_t *args) {
     set_diff_int(n_args, args, true);
     return mp_const_none;
 }
-static MP_DEFINE_CONST_FUN_OBJ_VAR(set_diff_update_obj, 1, set_diff_update);
+STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(set_diff_update_obj, 1, set_diff_update);
 
-static mp_obj_t set_intersect_int(mp_obj_t self_in, mp_obj_t other, bool update) {
+STATIC mp_obj_t set_intersect_int(mp_obj_t self_in, mp_obj_t other, bool update) {
     if (update) {
         check_set(self_in);
     } else {
@@ -259,17 +259,17 @@ static mp_obj_t set_intersect_int(mp_obj_t self_in, mp_obj_t other, bool update)
     return update ? mp_const_none : MP_OBJ_FROM_PTR(out);
 }
 
-static mp_obj_t set_intersect(mp_obj_t self_in, mp_obj_t other) {
+STATIC mp_obj_t set_intersect(mp_obj_t self_in, mp_obj_t other) {
     return set_intersect_int(self_in, other, false);
 }
-static MP_DEFINE_CONST_FUN_OBJ_2(set_intersect_obj, set_intersect);
+STATIC MP_DEFINE_CONST_FUN_OBJ_2(set_intersect_obj, set_intersect);
 
-static mp_obj_t set_intersect_update(mp_obj_t self_in, mp_obj_t other) {
+STATIC mp_obj_t set_intersect_update(mp_obj_t self_in, mp_obj_t other) {
     return set_intersect_int(self_in, other, true);
 }
-static MP_DEFINE_CONST_FUN_OBJ_2(set_intersect_update_obj, set_intersect_update);
+STATIC MP_DEFINE_CONST_FUN_OBJ_2(set_intersect_update_obj, set_intersect_update);
 
-static mp_obj_t set_isdisjoint(mp_obj_t self_in, mp_obj_t other) {
+STATIC mp_obj_t set_isdisjoint(mp_obj_t self_in, mp_obj_t other) {
     check_set_or_frozenset(self_in);
     mp_obj_set_t *self = MP_OBJ_TO_PTR(self_in);
 
@@ -283,9 +283,9 @@ static mp_obj_t set_isdisjoint(mp_obj_t self_in, mp_obj_t other) {
     }
     return mp_const_true;
 }
-static MP_DEFINE_CONST_FUN_OBJ_2(set_isdisjoint_obj, set_isdisjoint);
+STATIC MP_DEFINE_CONST_FUN_OBJ_2(set_isdisjoint_obj, set_isdisjoint);
 
-static mp_obj_t set_issubset_internal(mp_obj_t self_in, mp_obj_t other_in, bool proper) {
+STATIC mp_obj_t set_issubset_internal(mp_obj_t self_in, mp_obj_t other_in, bool proper) {
     mp_obj_set_t *self;
     bool cleanup_self = false;
     if (is_set_or_frozenset(self_in)) {
@@ -327,25 +327,25 @@ static mp_obj_t set_issubset_internal(mp_obj_t self_in, mp_obj_t other_in, bool
     return out;
 }
 
-static mp_obj_t set_issubset(mp_obj_t self_in, mp_obj_t other_in) {
+STATIC mp_obj_t set_issubset(mp_obj_t self_in, mp_obj_t other_in) {
     return set_issubset_internal(self_in, other_in, false);
 }
-static MP_DEFINE_CONST_FUN_OBJ_2(set_issubset_obj, set_issubset);
+STATIC MP_DEFINE_CONST_FUN_OBJ_2(set_issubset_obj, set_issubset);
 
-static mp_obj_t set_issubset_proper(mp_obj_t self_in, mp_obj_t other_in) {
+STATIC mp_obj_t set_issubset_proper(mp_obj_t self_in, mp_obj_t other_in) {
     return set_issubset_internal(self_in, other_in, true);
 }
 
-static mp_obj_t set_issuperset(mp_obj_t self_in, mp_obj_t other_in) {
+STATIC mp_obj_t set_issuperset(mp_obj_t self_in, mp_obj_t other_in) {
     return set_issubset_internal(other_in, self_in, false);
 }
-static MP_DEFINE_CONST_FUN_OBJ_2(set_issuperset_obj, set_issuperset);
+STATIC MP_DEFINE_CONST_FUN_OBJ_2(set_issuperset_obj, set_issuperset);
 
-static mp_obj_t set_issuperset_proper(mp_obj_t self_in, mp_obj_t other_in) {
+STATIC mp_obj_t set_issuperset_proper(mp_obj_t self_in, mp_obj_t other_in) {
     return set_issubset_internal(other_in, self_in, true);
 }
 
-static mp_obj_t set_equal(mp_obj_t self_in, mp_obj_t other_in) {
+STATIC mp_obj_t set_equal(mp_obj_t self_in, mp_obj_t other_in) {
     assert(is_set_or_frozenset(other_in));
     check_set_or_frozenset(self_in);
     mp_obj_set_t *self = MP_OBJ_TO_PTR(self_in);
@@ -356,7 +356,7 @@ static mp_obj_t set_equal(mp_obj_t self_in, mp_obj_t other_in) {
     return set_issubset(self_in, other_in);
 }
 
-static mp_obj_t set_pop(mp_obj_t self_in) {
+STATIC mp_obj_t set_pop(mp_obj_t self_in) {
     check_set(self_in);
     mp_obj_set_t *self = MP_OBJ_TO_PTR(self_in);
     mp_obj_t obj = mp_set_remove_first(&self->set);
@@ -365,9 +365,9 @@ static mp_obj_t set_pop(mp_obj_t self_in) {
     }
     return obj;
 }
-static MP_DEFINE_CONST_FUN_OBJ_1(set_pop_obj, set_pop);
+STATIC MP_DEFINE_CONST_FUN_OBJ_1(set_pop_obj, set_pop);
 
-static mp_obj_t set_remove(mp_obj_t self_in, mp_obj_t item) {
+STATIC mp_obj_t set_remove(mp_obj_t self_in, mp_obj_t item) {
     check_set(self_in);
     mp_obj_set_t *self = MP_OBJ_TO_PTR(self_in);
     if (mp_set_lookup(&self->set, item, MP_MAP_LOOKUP_REMOVE_IF_FOUND) == MP_OBJ_NULL) {
@@ -375,9 +375,9 @@ static mp_obj_t set_remove(mp_obj_t self_in, mp_obj_t item) {
     }
     return mp_const_none;
 }
-static MP_DEFINE_CONST_FUN_OBJ_2(set_remove_obj, set_remove);
+STATIC MP_DEFINE_CONST_FUN_OBJ_2(set_remove_obj, set_remove);
 
-static mp_obj_t set_symmetric_difference_update(mp_obj_t self_in, mp_obj_t other_in) {
+STATIC mp_obj_t set_symmetric_difference_update(mp_obj_t self_in, mp_obj_t other_in) {
     check_set_or_frozenset(self_in); // can be frozenset due to call from set_symmetric_difference
     mp_obj_set_t *self = MP_OBJ_TO_PTR(self_in);
     mp_obj_t iter = mp_getiter(other_in, NULL);
@@ -387,16 +387,16 @@ static mp_obj_t set_symmetric_difference_update(mp_obj_t self_in, mp_obj_t other
     }
     return mp_const_none;
 }
-static MP_DEFINE_CONST_FUN_OBJ_2(set_symmetric_difference_update_obj, set_symmetric_difference_update);
+STATIC MP_DEFINE_CONST_FUN_OBJ_2(set_symmetric_difference_update_obj, set_symmetric_difference_update);
 
-static mp_obj_t set_symmetric_difference(mp_obj_t self_in, mp_obj_t other_in) {
+STATIC mp_obj_t set_symmetric_difference(mp_obj_t self_in, mp_obj_t other_in) {
     mp_obj_t self_out = set_copy(self_in);
     set_symmetric_difference_update(self_out, other_in);
     return self_out;
 }
-static MP_DEFINE_CONST_FUN_OBJ_2(set_symmetric_difference_obj, set_symmetric_difference);
+STATIC MP_DEFINE_CONST_FUN_OBJ_2(set_symmetric_difference_obj, set_symmetric_difference);
 
-static void set_update_int(mp_obj_set_t *self, mp_obj_t other_in) {
+STATIC void set_update_int(mp_obj_set_t *self, mp_obj_t other_in) {
     mp_obj_t iter = mp_getiter(other_in, NULL);
     mp_obj_t next;
     while ((next = mp_iternext(iter)) != MP_OBJ_STOP_ITERATION) {
@@ -404,7 +404,7 @@ static void set_update_int(mp_obj_set_t *self, mp_obj_t other_in) {
     }
 }
 
-static mp_obj_t set_update(size_t n_args, const mp_obj_t *args) {
+STATIC mp_obj_t set_update(size_t n_args, const mp_obj_t *args) {
     check_set(args[0]);
     for (size_t i = 1; i < n_args; i++) {
         set_update_int(MP_OBJ_TO_PTR(args[0]), args[i]);
@@ -412,17 +412,17 @@ static mp_obj_t set_update(size_t n_args, const mp_obj_t *args) {
 
     return mp_const_none;
 }
-static MP_DEFINE_CONST_FUN_OBJ_VAR(set_update_obj, 1, set_update);
+STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(set_update_obj, 1, set_update);
 
-static mp_obj_t set_union(mp_obj_t self_in, mp_obj_t other_in) {
+STATIC mp_obj_t set_union(mp_obj_t self_in, mp_obj_t other_in) {
     check_set_or_frozenset(self_in);
     mp_obj_t self = set_copy(self_in);
     set_update_int(MP_OBJ_TO_PTR(self), other_in);
     return self;
 }
-static MP_DEFINE_CONST_FUN_OBJ_2(set_union_obj, set_union);
+STATIC MP_DEFINE_CONST_FUN_OBJ_2(set_union_obj, set_union);
 
-static mp_obj_t set_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
+STATIC mp_obj_t set_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
     mp_obj_set_t *self = MP_OBJ_TO_PTR(self_in);
     switch (op) {
         case MP_UNARY_OP_BOOL:
@@ -451,7 +451,7 @@ static mp_obj_t set_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
     }
 }
 
-static mp_obj_t set_binary_op(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs) {
+STATIC mp_obj_t set_binary_op(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs) {
     mp_obj_t args[] = {lhs, rhs};
     #if MICROPY_PY_BUILTINS_FROZENSET
     bool update = mp_obj_is_type(lhs, &mp_type_set);
@@ -517,7 +517,7 @@ static mp_obj_t set_binary_op(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs) {
 /******************************************************************************/
 /* set constructors & public C API                                            */
 
-static const mp_rom_map_elem_t set_locals_dict_table[] = {
+STATIC const mp_rom_map_elem_t set_locals_dict_table[] = {
     { MP_ROM_QSTR(MP_QSTR_add), MP_ROM_PTR(&set_add_obj) },
     { MP_ROM_QSTR(MP_QSTR_clear), MP_ROM_PTR(&set_clear_obj) },
     { MP_ROM_QSTR(MP_QSTR_copy), MP_ROM_PTR(&set_copy_obj) },
@@ -537,7 +537,7 @@ static const mp_rom_map_elem_t set_locals_dict_table[] = {
     { MP_ROM_QSTR(MP_QSTR_update), MP_ROM_PTR(&set_update_obj) },
     { MP_ROM_QSTR(MP_QSTR___contains__), MP_ROM_PTR(&mp_op_contains_obj) },
 };
-static MP_DEFINE_CONST_DICT(set_locals_dict, set_locals_dict_table);
+STATIC MP_DEFINE_CONST_DICT(set_locals_dict, set_locals_dict_table);
 
 MP_DEFINE_CONST_OBJ_TYPE(
     mp_type_set,
@@ -552,7 +552,7 @@ MP_DEFINE_CONST_OBJ_TYPE(
     );
 
 #if MICROPY_PY_BUILTINS_FROZENSET
-static const mp_rom_map_elem_t frozenset_locals_dict_table[] = {
+STATIC const mp_rom_map_elem_t frozenset_locals_dict_table[] = {
     { MP_ROM_QSTR(MP_QSTR_copy), MP_ROM_PTR(&set_copy_obj) },
     { MP_ROM_QSTR(MP_QSTR_difference), MP_ROM_PTR(&set_diff_obj) },
     { MP_ROM_QSTR(MP_QSTR_intersection), MP_ROM_PTR(&set_intersect_obj) },
@@ -563,7 +563,7 @@ static const mp_rom_map_elem_t frozenset_locals_dict_table[] = {
     { MP_ROM_QSTR(MP_QSTR_union), MP_ROM_PTR(&set_union_obj) },
     { MP_ROM_QSTR(MP_QSTR___contains__), MP_ROM_PTR(&mp_op_contains_obj) },
 };
-static MP_DEFINE_CONST_DICT(frozenset_locals_dict, frozenset_locals_dict_table);
+STATIC MP_DEFINE_CONST_DICT(frozenset_locals_dict, frozenset_locals_dict_table);
 
 MP_DEFINE_CONST_OBJ_TYPE(
     mp_type_frozenset,

+ 1 - 1
py/objsingleton.c

@@ -37,7 +37,7 @@ typedef struct _mp_obj_singleton_t {
     qstr name;
 } mp_obj_singleton_t;
 
-static void singleton_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
+STATIC void singleton_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
     (void)kind;
     mp_obj_singleton_t *self = MP_OBJ_TO_PTR(self_in);
     mp_printf(print, "%q", self->name);

+ 7 - 7
py/objslice.c

@@ -34,7 +34,7 @@
 
 #if MICROPY_PY_BUILTINS_SLICE
 
-static void slice_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
+STATIC void slice_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
     (void)kind;
     mp_obj_slice_t *o = MP_OBJ_TO_PTR(o_in);
     mp_print_str(print, "slice(");
@@ -46,14 +46,14 @@ static void slice_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t
     mp_print_str(print, ")");
 }
 
-static mp_obj_t slice_unary_op(mp_unary_op_t op, mp_obj_t o_in) {
+STATIC mp_obj_t slice_unary_op(mp_unary_op_t op, mp_obj_t o_in) {
     // Needed to explicitly opt out of default __hash__.
     // REVISIT: CPython implements comparison operators for slice.
     return MP_OBJ_NULL;
 }
 
 #if MICROPY_PY_BUILTINS_SLICE_INDICES
-static mp_obj_t slice_indices(mp_obj_t self_in, mp_obj_t length_obj) {
+STATIC mp_obj_t slice_indices(mp_obj_t self_in, mp_obj_t length_obj) {
     mp_int_t length = mp_obj_get_int(length_obj);
     mp_bound_slice_t bound_indices;
     mp_obj_slice_indices(self_in, length, &bound_indices);
@@ -65,11 +65,11 @@ static mp_obj_t slice_indices(mp_obj_t self_in, mp_obj_t length_obj) {
     };
     return mp_obj_new_tuple(3, results);
 }
-static MP_DEFINE_CONST_FUN_OBJ_2(slice_indices_obj, slice_indices);
+STATIC MP_DEFINE_CONST_FUN_OBJ_2(slice_indices_obj, slice_indices);
 #endif
 
 #if MICROPY_PY_BUILTINS_SLICE_ATTRS
-static void slice_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
+STATIC void slice_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
     if (dest[0] != MP_OBJ_NULL) {
         // not load attribute
         return;
@@ -92,10 +92,10 @@ static void slice_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
 #endif
 
 #if MICROPY_PY_BUILTINS_SLICE_INDICES && !MICROPY_PY_BUILTINS_SLICE_ATTRS
-static const mp_rom_map_elem_t slice_locals_dict_table[] = {
+STATIC const mp_rom_map_elem_t slice_locals_dict_table[] = {
     { MP_ROM_QSTR(MP_QSTR_indices), MP_ROM_PTR(&slice_indices_obj) },
 };
-static MP_DEFINE_CONST_DICT(slice_locals_dict, slice_locals_dict_table);
+STATIC MP_DEFINE_CONST_DICT(slice_locals_dict, slice_locals_dict_table);
 #endif
 
 #if MICROPY_PY_BUILTINS_SLICE_ATTRS

+ 60 - 60
py/objstr.c

@@ -35,15 +35,15 @@
 #include "py/stackctrl.h"
 
 #if MICROPY_PY_BUILTINS_STR_OP_MODULO
-static mp_obj_t str_modulo_format(mp_obj_t pattern, size_t n_args, const mp_obj_t *args, mp_obj_t dict);
+STATIC mp_obj_t str_modulo_format(mp_obj_t pattern, size_t n_args, const mp_obj_t *args, mp_obj_t dict);
 #endif
 
-static mp_obj_t mp_obj_new_bytes_iterator(mp_obj_t str, mp_obj_iter_buf_t *iter_buf);
-static NORETURN void bad_implicit_conversion(mp_obj_t self_in);
+STATIC mp_obj_t mp_obj_new_bytes_iterator(mp_obj_t str, mp_obj_iter_buf_t *iter_buf);
+STATIC NORETURN void bad_implicit_conversion(mp_obj_t self_in);
 
-static mp_obj_t mp_obj_new_str_type_from_vstr(const mp_obj_type_t *type, vstr_t *vstr);
+STATIC mp_obj_t mp_obj_new_str_type_from_vstr(const mp_obj_type_t *type, vstr_t *vstr);
 
-static void str_check_arg_type(const mp_obj_type_t *self_type, const mp_obj_t arg) {
+STATIC void str_check_arg_type(const mp_obj_type_t *self_type, const mp_obj_t arg) {
     // String operations generally need the args type to match the object they're called on,
     // e.g. str.find(str), byte.startswith(byte)
     // with the exception that bytes may be used for bytearray and vice versa.
@@ -63,7 +63,7 @@ static void str_check_arg_type(const mp_obj_type_t *self_type, const mp_obj_t ar
     }
 }
 
-static void check_is_str_or_bytes(mp_obj_t self_in) {
+STATIC void check_is_str_or_bytes(mp_obj_t self_in) {
     mp_check_self(mp_obj_is_str_or_bytes(self_in));
 }
 
@@ -135,7 +135,7 @@ void mp_str_print_json(const mp_print_t *print, const byte *str_data, size_t str
 }
 #endif
 
-static void str_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
+STATIC void str_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
     GET_STR_DATA_LEN(self_in, str_data, str_len);
     #if MICROPY_PY_JSON
     if (kind == PRINT_JSON) {
@@ -212,7 +212,7 @@ mp_obj_t mp_obj_str_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_
     }
 }
 
-static mp_obj_t bytes_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
+STATIC mp_obj_t bytes_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
     (void)type_in;
 
     #if MICROPY_CPYTHON_COMPAT
@@ -458,7 +458,7 @@ const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, s
 #endif
 
 // This is used for both bytes and 8-bit strings. This is not used for unicode strings.
-static mp_obj_t bytes_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
+STATIC mp_obj_t bytes_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
     const mp_obj_type_t *type = mp_obj_get_type(self_in);
     GET_STR_DATA_LEN(self_in, self_data, self_len);
     if (value == MP_OBJ_SENTINEL) {
@@ -484,7 +484,7 @@ static mp_obj_t bytes_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
     }
 }
 
-static mp_obj_t str_join(mp_obj_t self_in, mp_obj_t arg) {
+STATIC mp_obj_t str_join(mp_obj_t self_in, mp_obj_t arg) {
     check_is_str_or_bytes(self_in);
     const mp_obj_type_t *self_type = mp_obj_get_type(self_in);
     const mp_obj_type_t *ret_type = self_type;
@@ -628,7 +628,7 @@ mp_obj_t mp_obj_str_split(size_t n_args, const mp_obj_t *args) {
 MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_split_obj, 1, 3, mp_obj_str_split);
 
 #if MICROPY_PY_BUILTINS_STR_SPLITLINES
-static mp_obj_t str_splitlines(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
+STATIC mp_obj_t str_splitlines(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
     enum { ARG_keepends };
     static const mp_arg_t allowed_args[] = {
         { MP_QSTR_keepends, MP_ARG_BOOL, {.u_bool = false} },
@@ -674,7 +674,7 @@ static mp_obj_t str_splitlines(size_t n_args, const mp_obj_t *pos_args, mp_map_t
 MP_DEFINE_CONST_FUN_OBJ_KW(str_splitlines_obj, 1, str_splitlines);
 #endif
 
-static mp_obj_t str_rsplit(size_t n_args, const mp_obj_t *args) {
+STATIC mp_obj_t str_rsplit(size_t n_args, const mp_obj_t *args) {
     if (n_args < 3) {
         // If we don't have split limit, it doesn't matter from which side
         // we split.
@@ -739,7 +739,7 @@ static mp_obj_t str_rsplit(size_t n_args, const mp_obj_t *args) {
 }
 MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_rsplit_obj, 1, 3, str_rsplit);
 
-static mp_obj_t str_finder(size_t n_args, const mp_obj_t *args, int direction, bool is_index) {
+STATIC mp_obj_t str_finder(size_t n_args, const mp_obj_t *args, int direction, bool is_index) {
     const mp_obj_type_t *self_type = mp_obj_get_type(args[0]);
     check_is_str_or_bytes(args[0]);
 
@@ -782,28 +782,28 @@ static mp_obj_t str_finder(size_t n_args, const mp_obj_t *args, int direction, b
     }
 }
 
-static mp_obj_t str_find(size_t n_args, const mp_obj_t *args) {
+STATIC mp_obj_t str_find(size_t n_args, const mp_obj_t *args) {
     return str_finder(n_args, args, 1, false);
 }
 MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_find_obj, 2, 4, str_find);
 
-static mp_obj_t str_rfind(size_t n_args, const mp_obj_t *args) {
+STATIC mp_obj_t str_rfind(size_t n_args, const mp_obj_t *args) {
     return str_finder(n_args, args, -1, false);
 }
 MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_rfind_obj, 2, 4, str_rfind);
 
-static mp_obj_t str_index(size_t n_args, const mp_obj_t *args) {
+STATIC mp_obj_t str_index(size_t n_args, const mp_obj_t *args) {
     return str_finder(n_args, args, 1, true);
 }
 MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_index_obj, 2, 4, str_index);
 
-static mp_obj_t str_rindex(size_t n_args, const mp_obj_t *args) {
+STATIC mp_obj_t str_rindex(size_t n_args, const mp_obj_t *args) {
     return str_finder(n_args, args, -1, true);
 }
 MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_rindex_obj, 2, 4, str_rindex);
 
 // TODO: (Much) more variety in args
-static mp_obj_t str_startswith(size_t n_args, const mp_obj_t *args) {
+STATIC mp_obj_t str_startswith(size_t n_args, const mp_obj_t *args) {
     const mp_obj_type_t *self_type = mp_obj_get_type(args[0]);
     GET_STR_DATA_LEN(args[0], str, str_len);
     size_t prefix_len;
@@ -819,7 +819,7 @@ static mp_obj_t str_startswith(size_t n_args, const mp_obj_t *args) {
 }
 MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_startswith_obj, 2, 3, str_startswith);
 
-static mp_obj_t str_endswith(size_t n_args, const mp_obj_t *args) {
+STATIC mp_obj_t str_endswith(size_t n_args, const mp_obj_t *args) {
     GET_STR_DATA_LEN(args[0], str, str_len);
     size_t suffix_len;
     const char *suffix = mp_obj_str_get_data(args[1], &suffix_len);
@@ -836,7 +836,7 @@ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_endswith_obj, 2, 3, str_endswith);
 
 enum { LSTRIP, RSTRIP, STRIP };
 
-static mp_obj_t str_uni_strip(int type, size_t n_args, const mp_obj_t *args) {
+STATIC mp_obj_t str_uni_strip(int type, size_t n_args, const mp_obj_t *args) {
     check_is_str_or_bytes(args[0]);
     const mp_obj_type_t *self_type = mp_obj_get_type(args[0]);
 
@@ -905,23 +905,23 @@ static mp_obj_t str_uni_strip(int type, size_t n_args, const mp_obj_t *args) {
     return mp_obj_new_str_of_type(self_type, orig_str + first_good_char_pos, stripped_len);
 }
 
-static mp_obj_t str_strip(size_t n_args, const mp_obj_t *args) {
+STATIC mp_obj_t str_strip(size_t n_args, const mp_obj_t *args) {
     return str_uni_strip(STRIP, n_args, args);
 }
 MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_strip_obj, 1, 2, str_strip);
 
-static mp_obj_t str_lstrip(size_t n_args, const mp_obj_t *args) {
+STATIC mp_obj_t str_lstrip(size_t n_args, const mp_obj_t *args) {
     return str_uni_strip(LSTRIP, n_args, args);
 }
 MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_lstrip_obj, 1, 2, str_lstrip);
 
-static mp_obj_t str_rstrip(size_t n_args, const mp_obj_t *args) {
+STATIC mp_obj_t str_rstrip(size_t n_args, const mp_obj_t *args) {
     return str_uni_strip(RSTRIP, n_args, args);
 }
 MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_rstrip_obj, 1, 2, str_rstrip);
 
 #if MICROPY_PY_BUILTINS_STR_CENTER
-static mp_obj_t str_center(mp_obj_t str_in, mp_obj_t width_in) {
+STATIC mp_obj_t str_center(mp_obj_t str_in, mp_obj_t width_in) {
     GET_STR_DATA_LEN(str_in, str, str_len);
     mp_uint_t width = mp_obj_get_int(width_in);
     if (str_len >= width) {
@@ -940,7 +940,7 @@ MP_DEFINE_CONST_FUN_OBJ_2(str_center_obj, str_center);
 
 // Takes an int arg, but only parses unsigned numbers, and only changes
 // *num if at least one digit was parsed.
-static const char *str_to_int(const char *str, const char *top, int *num) {
+STATIC const char *str_to_int(const char *str, const char *top, int *num) {
     if (str < top && '0' <= *str && *str <= '9') {
         *num = 0;
         do {
@@ -952,19 +952,19 @@ static const char *str_to_int(const char *str, const char *top, int *num) {
     return str;
 }
 
-static bool isalignment(char ch) {
+STATIC bool isalignment(char ch) {
     return ch && strchr("<>=^", ch) != NULL;
 }
 
-static bool istype(char ch) {
+STATIC bool istype(char ch) {
     return ch && strchr("bcdeEfFgGnosxX%", ch) != NULL;
 }
 
-static bool arg_looks_integer(mp_obj_t arg) {
+STATIC bool arg_looks_integer(mp_obj_t arg) {
     return mp_obj_is_bool(arg) || mp_obj_is_int(arg);
 }
 
-static bool arg_looks_numeric(mp_obj_t arg) {
+STATIC bool arg_looks_numeric(mp_obj_t arg) {
     return arg_looks_integer(arg)
            #if MICROPY_PY_BUILTINS_FLOAT
            || mp_obj_is_float(arg)
@@ -973,7 +973,7 @@ static bool arg_looks_numeric(mp_obj_t arg) {
 }
 
 #if MICROPY_PY_BUILTINS_STR_OP_MODULO
-static mp_obj_t arg_as_int(mp_obj_t arg) {
+STATIC mp_obj_t arg_as_int(mp_obj_t arg) {
     #if MICROPY_PY_BUILTINS_FLOAT
     if (mp_obj_is_float(arg)) {
         return mp_obj_new_int_from_float(mp_obj_float_get(arg));
@@ -984,7 +984,7 @@ static mp_obj_t arg_as_int(mp_obj_t arg) {
 #endif
 
 #if MICROPY_ERROR_REPORTING <= MICROPY_ERROR_REPORTING_TERSE
-static NORETURN void terse_str_format_value_error(void) {
+STATIC NORETURN void terse_str_format_value_error(void) {
     mp_raise_ValueError(MP_ERROR_TEXT("bad format string"));
 }
 #else
@@ -992,7 +992,7 @@ static NORETURN void terse_str_format_value_error(void) {
 #define terse_str_format_value_error()
 #endif
 
-static vstr_t mp_obj_str_format_helper(const char *str, const char *top, int *arg_i, size_t n_args, const mp_obj_t *args, mp_map_t *kwargs) {
+STATIC vstr_t mp_obj_str_format_helper(const char *str, const char *top, int *arg_i, size_t n_args, const mp_obj_t *args, mp_map_t *kwargs) {
     vstr_t vstr;
     mp_print_t print;
     vstr_init_print(&vstr, 16, &print);
@@ -1449,7 +1449,7 @@ mp_obj_t mp_obj_str_format(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs
 MP_DEFINE_CONST_FUN_OBJ_KW(str_format_obj, 1, mp_obj_str_format);
 
 #if MICROPY_PY_BUILTINS_STR_OP_MODULO
-static mp_obj_t str_modulo_format(mp_obj_t pattern, size_t n_args, const mp_obj_t *args, mp_obj_t dict) {
+STATIC mp_obj_t str_modulo_format(mp_obj_t pattern, size_t n_args, const mp_obj_t *args, mp_obj_t dict) {
     check_is_str_or_bytes(pattern);
 
     GET_STR_DATA_LEN(pattern, str, len);
@@ -1657,7 +1657,7 @@ static mp_obj_t str_modulo_format(mp_obj_t pattern, size_t n_args, const mp_obj_
 
 // The implementation is optimized, returning the original string if there's
 // nothing to replace.
-static mp_obj_t str_replace(size_t n_args, const mp_obj_t *args) {
+STATIC mp_obj_t str_replace(size_t n_args, const mp_obj_t *args) {
     check_is_str_or_bytes(args[0]);
 
     mp_int_t max_rep = -1;
@@ -1759,7 +1759,7 @@ static mp_obj_t str_replace(size_t n_args, const mp_obj_t *args) {
 MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_replace_obj, 3, 4, str_replace);
 
 #if MICROPY_PY_BUILTINS_STR_COUNT
-static mp_obj_t str_count(size_t n_args, const mp_obj_t *args) {
+STATIC mp_obj_t str_count(size_t n_args, const mp_obj_t *args) {
     const mp_obj_type_t *self_type = mp_obj_get_type(args[0]);
     check_is_str_or_bytes(args[0]);
 
@@ -1802,7 +1802,7 @@ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_count_obj, 2, 4, str_count);
 #endif
 
 #if MICROPY_PY_BUILTINS_STR_PARTITION
-static mp_obj_t str_partitioner(mp_obj_t self_in, mp_obj_t arg, int direction) {
+STATIC mp_obj_t str_partitioner(mp_obj_t self_in, mp_obj_t arg, int direction) {
     check_is_str_or_bytes(self_in);
     const mp_obj_type_t *self_type = mp_obj_get_type(self_in);
     str_check_arg_type(self_type, arg);
@@ -1848,19 +1848,19 @@ static mp_obj_t str_partitioner(mp_obj_t self_in, mp_obj_t arg, int direction) {
     return mp_obj_new_tuple(3, result);
 }
 
-static mp_obj_t str_partition(mp_obj_t self_in, mp_obj_t arg) {
+STATIC mp_obj_t str_partition(mp_obj_t self_in, mp_obj_t arg) {
     return str_partitioner(self_in, arg, 1);
 }
 MP_DEFINE_CONST_FUN_OBJ_2(str_partition_obj, str_partition);
 
-static mp_obj_t str_rpartition(mp_obj_t self_in, mp_obj_t arg) {
+STATIC mp_obj_t str_rpartition(mp_obj_t self_in, mp_obj_t arg) {
     return str_partitioner(self_in, arg, -1);
 }
 MP_DEFINE_CONST_FUN_OBJ_2(str_rpartition_obj, str_rpartition);
 #endif
 
 // Supposedly not too critical operations, so optimize for code size
-static mp_obj_t str_caseconv(unichar (*op)(unichar), mp_obj_t self_in) {
+STATIC mp_obj_t str_caseconv(unichar (*op)(unichar), mp_obj_t self_in) {
     GET_STR_DATA_LEN(self_in, self_data, self_len);
     vstr_t vstr;
     vstr_init_len(&vstr, self_len);
@@ -1871,17 +1871,17 @@ static mp_obj_t str_caseconv(unichar (*op)(unichar), mp_obj_t self_in) {
     return mp_obj_new_str_type_from_vstr(mp_obj_get_type(self_in), &vstr);
 }
 
-static mp_obj_t str_lower(mp_obj_t self_in) {
+STATIC mp_obj_t str_lower(mp_obj_t self_in) {
     return str_caseconv(unichar_tolower, self_in);
 }
 MP_DEFINE_CONST_FUN_OBJ_1(str_lower_obj, str_lower);
 
-static mp_obj_t str_upper(mp_obj_t self_in) {
+STATIC mp_obj_t str_upper(mp_obj_t self_in) {
     return str_caseconv(unichar_toupper, self_in);
 }
 MP_DEFINE_CONST_FUN_OBJ_1(str_upper_obj, str_upper);
 
-static mp_obj_t str_uni_istype(bool (*f)(unichar), mp_obj_t self_in) {
+STATIC mp_obj_t str_uni_istype(bool (*f)(unichar), mp_obj_t self_in) {
     GET_STR_DATA_LEN(self_in, self_data, self_len);
 
     if (self_len == 0) {
@@ -1914,27 +1914,27 @@ static mp_obj_t str_uni_istype(bool (*f)(unichar), mp_obj_t self_in) {
     return mp_const_true;
 }
 
-static mp_obj_t str_isspace(mp_obj_t self_in) {
+STATIC mp_obj_t str_isspace(mp_obj_t self_in) {
     return str_uni_istype(unichar_isspace, self_in);
 }
 MP_DEFINE_CONST_FUN_OBJ_1(str_isspace_obj, str_isspace);
 
-static mp_obj_t str_isalpha(mp_obj_t self_in) {
+STATIC mp_obj_t str_isalpha(mp_obj_t self_in) {
     return str_uni_istype(unichar_isalpha, self_in);
 }
 MP_DEFINE_CONST_FUN_OBJ_1(str_isalpha_obj, str_isalpha);
 
-static mp_obj_t str_isdigit(mp_obj_t self_in) {
+STATIC mp_obj_t str_isdigit(mp_obj_t self_in) {
     return str_uni_istype(unichar_isdigit, self_in);
 }
 MP_DEFINE_CONST_FUN_OBJ_1(str_isdigit_obj, str_isdigit);
 
-static mp_obj_t str_isupper(mp_obj_t self_in) {
+STATIC mp_obj_t str_isupper(mp_obj_t self_in) {
     return str_uni_istype(unichar_isupper, self_in);
 }
 MP_DEFINE_CONST_FUN_OBJ_1(str_isupper_obj, str_isupper);
 
-static mp_obj_t str_islower(mp_obj_t self_in) {
+STATIC mp_obj_t str_islower(mp_obj_t self_in) {
     return str_uni_istype(unichar_islower, self_in);
 }
 MP_DEFINE_CONST_FUN_OBJ_1(str_islower_obj, str_islower);
@@ -1943,7 +1943,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(str_islower_obj, str_islower);
 // These methods are superfluous in the presence of str() and bytes()
 // constructors.
 // TODO: should accept kwargs too
-static mp_obj_t bytes_decode(size_t n_args, const mp_obj_t *args) {
+STATIC mp_obj_t bytes_decode(size_t n_args, const mp_obj_t *args) {
     mp_obj_t new_args[2];
     if (n_args == 1) {
         new_args[0] = args[0];
@@ -1956,7 +1956,7 @@ static mp_obj_t bytes_decode(size_t n_args, const mp_obj_t *args) {
 MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(bytes_decode_obj, 1, 3, bytes_decode);
 
 // TODO: should accept kwargs too
-static mp_obj_t str_encode(size_t n_args, const mp_obj_t *args) {
+STATIC mp_obj_t str_encode(size_t n_args, const mp_obj_t *args) {
     mp_obj_t new_args[2];
     if (n_args == 1) {
         new_args[0] = args[0];
@@ -2038,13 +2038,13 @@ mp_obj_t mp_obj_bytes_fromhex(mp_obj_t type_in, mp_obj_t data) {
     return mp_obj_new_str_type_from_vstr(MP_OBJ_TO_PTR(type_in), &vstr);
 }
 
-static mp_obj_t bytes_hex_as_str(size_t n_args, const mp_obj_t *args) {
+STATIC mp_obj_t bytes_hex_as_str(size_t n_args, const mp_obj_t *args) {
     return mp_obj_bytes_hex(n_args, args, &mp_type_str);
 }
-static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(bytes_hex_as_str_obj, 1, 2, bytes_hex_as_str);
+STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(bytes_hex_as_str_obj, 1, 2, bytes_hex_as_str);
 
-static MP_DEFINE_CONST_FUN_OBJ_2(bytes_fromhex_obj, mp_obj_bytes_fromhex);
-static MP_DEFINE_CONST_CLASSMETHOD_OBJ(bytes_fromhex_classmethod_obj, MP_ROM_PTR(&bytes_fromhex_obj));
+STATIC MP_DEFINE_CONST_FUN_OBJ_2(bytes_fromhex_obj, mp_obj_bytes_fromhex);
+STATIC MP_DEFINE_CONST_CLASSMETHOD_OBJ(bytes_fromhex_classmethod_obj, MP_ROM_PTR(&bytes_fromhex_obj));
 #endif // MICROPY_PY_BUILTINS_BYTES_HEX
 
 mp_int_t mp_obj_str_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo, mp_uint_t flags) {
@@ -2068,7 +2068,7 @@ void mp_obj_str_set_data(mp_obj_str_t *str, const byte *data, size_t len) {
 
 // This locals table is used for the following types: str, bytes, bytearray, array.array.
 // Each type takes a different section (start to end offset) of this table.
-static const mp_rom_map_elem_t array_bytearray_str_bytes_locals_table[] = {
+STATIC const mp_rom_map_elem_t array_bytearray_str_bytes_locals_table[] = {
     #if MICROPY_PY_ARRAY || MICROPY_PY_BUILTINS_BYTEARRAY
     { MP_ROM_QSTR(MP_QSTR_append), MP_ROM_PTR(&mp_obj_array_append_obj) },
     { MP_ROM_QSTR(MP_QSTR_extend), MP_ROM_PTR(&mp_obj_array_extend_obj) },
@@ -2168,7 +2168,7 @@ MP_DEFINE_CONST_DICT_WITH_SIZE(mp_obj_memoryview_locals_dict,
 #endif
 
 #if !MICROPY_PY_BUILTINS_STR_UNICODE
-static mp_obj_t mp_obj_new_str_iterator(mp_obj_t str, mp_obj_iter_buf_t *iter_buf);
+STATIC mp_obj_t mp_obj_new_str_iterator(mp_obj_t str, mp_obj_iter_buf_t *iter_buf);
 
 MP_DEFINE_CONST_OBJ_TYPE(
     mp_type_str,
@@ -2240,7 +2240,7 @@ mp_obj_t mp_obj_new_str_via_qstr(const char *data, size_t len) {
 // Create a str/bytes object from the given vstr.  The vstr buffer is resized to
 // the exact length required and then reused for the str/bytes object.  The vstr
 // is cleared and can safely be passed to vstr_free if it was heap allocated.
-static mp_obj_t mp_obj_new_str_type_from_vstr(const mp_obj_type_t *type, vstr_t *vstr) {
+STATIC mp_obj_t mp_obj_new_str_type_from_vstr(const mp_obj_type_t *type, vstr_t *vstr) {
     // if not a bytes object, look if a qstr with this data already exists
     if (type == &mp_type_str) {
         qstr q = qstr_find_strn(vstr->buf, vstr->len);
@@ -2342,7 +2342,7 @@ bool mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2) {
     }
 }
 
-static NORETURN void bad_implicit_conversion(mp_obj_t self_in) {
+STATIC NORETURN void bad_implicit_conversion(mp_obj_t self_in) {
     #if MICROPY_ERROR_REPORTING <= MICROPY_ERROR_REPORTING_TERSE
     mp_raise_TypeError(MP_ERROR_TEXT("can't convert to str implicitly"));
     #else
@@ -2411,7 +2411,7 @@ typedef struct _mp_obj_str8_it_t {
 } mp_obj_str8_it_t;
 
 #if !MICROPY_PY_BUILTINS_STR_UNICODE
-static mp_obj_t str_it_iternext(mp_obj_t self_in) {
+STATIC mp_obj_t str_it_iternext(mp_obj_t self_in) {
     mp_obj_str8_it_t *self = MP_OBJ_TO_PTR(self_in);
     GET_STR_DATA_LEN(self->str, str, len);
     if (self->cur < len) {
@@ -2423,7 +2423,7 @@ static mp_obj_t str_it_iternext(mp_obj_t self_in) {
     }
 }
 
-static mp_obj_t mp_obj_new_str_iterator(mp_obj_t str, mp_obj_iter_buf_t *iter_buf) {
+STATIC mp_obj_t mp_obj_new_str_iterator(mp_obj_t str, mp_obj_iter_buf_t *iter_buf) {
     assert(sizeof(mp_obj_str8_it_t) <= sizeof(mp_obj_iter_buf_t));
     mp_obj_str8_it_t *o = (mp_obj_str8_it_t *)iter_buf;
     o->base.type = &mp_type_polymorph_iter;
@@ -2434,7 +2434,7 @@ static mp_obj_t mp_obj_new_str_iterator(mp_obj_t str, mp_obj_iter_buf_t *iter_bu
 }
 #endif
 
-static mp_obj_t bytes_it_iternext(mp_obj_t self_in) {
+STATIC mp_obj_t bytes_it_iternext(mp_obj_t self_in) {
     mp_obj_str8_it_t *self = MP_OBJ_TO_PTR(self_in);
     GET_STR_DATA_LEN(self->str, str, len);
     if (self->cur < len) {

+ 0 - 2
py/objstr.h

@@ -100,8 +100,6 @@ const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, s
     mp_obj_t index, bool is_slice);
 const byte *find_subbytes(const byte *haystack, size_t hlen, const byte *needle, size_t nlen, int direction);
 
-#define MP_DEFINE_BYTES_OBJ(obj_name, target, len) mp_obj_str_t obj_name = {{&mp_type_bytes}, 0, (len), (const byte *)(target)}
-
 mp_obj_t mp_obj_bytes_hex(size_t n_args, const mp_obj_t *args, const mp_obj_type_t *type);
 mp_obj_t mp_obj_bytes_fromhex(mp_obj_t type_in, mp_obj_t data);
 

+ 14 - 14
py/objstringio.c

@@ -36,7 +36,7 @@
 #if MICROPY_PY_IO
 
 #if MICROPY_CPYTHON_COMPAT
-static void check_stringio_is_open(const mp_obj_stringio_t *o) {
+STATIC void check_stringio_is_open(const mp_obj_stringio_t *o) {
     if (o->vstr == NULL) {
         mp_raise_ValueError(MP_ERROR_TEXT("I/O operation on closed file"));
     }
@@ -45,13 +45,13 @@ static void check_stringio_is_open(const mp_obj_stringio_t *o) {
 #define check_stringio_is_open(o)
 #endif
 
-static void stringio_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
+STATIC void stringio_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
     (void)kind;
     mp_obj_stringio_t *self = MP_OBJ_TO_PTR(self_in);
     mp_printf(print, self->base.type == &mp_type_stringio ? "<io.StringIO 0x%x>" : "<io.BytesIO 0x%x>", self);
 }
 
-static mp_uint_t stringio_read(mp_obj_t o_in, void *buf, mp_uint_t size, int *errcode) {
+STATIC mp_uint_t stringio_read(mp_obj_t o_in, void *buf, mp_uint_t size, int *errcode) {
     (void)errcode;
     mp_obj_stringio_t *o = MP_OBJ_TO_PTR(o_in);
     check_stringio_is_open(o);
@@ -67,7 +67,7 @@ static mp_uint_t stringio_read(mp_obj_t o_in, void *buf, mp_uint_t size, int *er
     return size;
 }
 
-static void stringio_copy_on_write(mp_obj_stringio_t *o) {
+STATIC void stringio_copy_on_write(mp_obj_stringio_t *o) {
     const void *buf = o->vstr->buf;
     o->vstr->buf = m_new(char, o->vstr->len);
     o->vstr->fixed_buf = false;
@@ -75,7 +75,7 @@ static void stringio_copy_on_write(mp_obj_stringio_t *o) {
     memcpy(o->vstr->buf, buf, o->vstr->len);
 }
 
-static mp_uint_t stringio_write(mp_obj_t o_in, const void *buf, mp_uint_t size, int *errcode) {
+STATIC mp_uint_t stringio_write(mp_obj_t o_in, const void *buf, mp_uint_t size, int *errcode) {
     (void)errcode;
     mp_obj_stringio_t *o = MP_OBJ_TO_PTR(o_in);
     check_stringio_is_open(o);
@@ -109,7 +109,7 @@ static mp_uint_t stringio_write(mp_obj_t o_in, const void *buf, mp_uint_t size,
     return size;
 }
 
-static mp_uint_t stringio_ioctl(mp_obj_t o_in, mp_uint_t request, uintptr_t arg, int *errcode) {
+STATIC mp_uint_t stringio_ioctl(mp_obj_t o_in, mp_uint_t request, uintptr_t arg, int *errcode) {
     (void)errcode;
     mp_obj_stringio_t *o = MP_OBJ_TO_PTR(o_in);
     switch (request) {
@@ -162,22 +162,22 @@ static mp_uint_t stringio_ioctl(mp_obj_t o_in, mp_uint_t request, uintptr_t arg,
 
 #define STREAM_TO_CONTENT_TYPE(o) (((o)->base.type == &mp_type_stringio) ? &mp_type_str : &mp_type_bytes)
 
-static mp_obj_t stringio_getvalue(mp_obj_t self_in) {
+STATIC mp_obj_t stringio_getvalue(mp_obj_t self_in) {
     mp_obj_stringio_t *self = MP_OBJ_TO_PTR(self_in);
     check_stringio_is_open(self);
     // TODO: Try to avoid copying string
     return mp_obj_new_str_of_type(STREAM_TO_CONTENT_TYPE(self), (byte *)self->vstr->buf, self->vstr->len);
 }
-static MP_DEFINE_CONST_FUN_OBJ_1(stringio_getvalue_obj, stringio_getvalue);
+STATIC MP_DEFINE_CONST_FUN_OBJ_1(stringio_getvalue_obj, stringio_getvalue);
 
-static mp_obj_stringio_t *stringio_new(const mp_obj_type_t *type) {
+STATIC mp_obj_stringio_t *stringio_new(const mp_obj_type_t *type) {
     mp_obj_stringio_t *o = mp_obj_malloc(mp_obj_stringio_t, type);
     o->pos = 0;
     o->ref_obj = MP_OBJ_NULL;
     return o;
 }
 
-static mp_obj_t stringio_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
+STATIC mp_obj_t stringio_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
     (void)n_kw; // TODO check n_kw==0
 
     mp_uint_t sz = 16;
@@ -215,7 +215,7 @@ static mp_obj_t stringio_make_new(const mp_obj_type_t *type_in, size_t n_args, s
     return MP_OBJ_FROM_PTR(o);
 }
 
-static const mp_rom_map_elem_t stringio_locals_dict_table[] = {
+STATIC const mp_rom_map_elem_t stringio_locals_dict_table[] = {
     { MP_ROM_QSTR(MP_QSTR_read), MP_ROM_PTR(&mp_stream_read_obj) },
     { MP_ROM_QSTR(MP_QSTR_readinto), MP_ROM_PTR(&mp_stream_readinto_obj) },
     { MP_ROM_QSTR(MP_QSTR_readline), MP_ROM_PTR(&mp_stream_unbuffered_readline_obj) },
@@ -229,9 +229,9 @@ static const mp_rom_map_elem_t stringio_locals_dict_table[] = {
     { MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&mp_stream___exit___obj) },
 };
 
-static MP_DEFINE_CONST_DICT(stringio_locals_dict, stringio_locals_dict_table);
+STATIC MP_DEFINE_CONST_DICT(stringio_locals_dict, stringio_locals_dict_table);
 
-static const mp_stream_p_t stringio_stream_p = {
+STATIC const mp_stream_p_t stringio_stream_p = {
     .read = stringio_read,
     .write = stringio_write,
     .ioctl = stringio_ioctl,
@@ -249,7 +249,7 @@ MP_DEFINE_CONST_OBJ_TYPE(
     );
 
 #if MICROPY_PY_IO_BYTESIO
-static const mp_stream_p_t bytesio_stream_p = {
+STATIC const mp_stream_p_t bytesio_stream_p = {
     .read = stringio_read,
     .write = stringio_write,
     .ioctl = stringio_ioctl,

+ 7 - 7
py/objstrunicode.c

@@ -34,12 +34,12 @@
 
 #if MICROPY_PY_BUILTINS_STR_UNICODE
 
-static mp_obj_t mp_obj_new_str_iterator(mp_obj_t str, mp_obj_iter_buf_t *iter_buf);
+STATIC mp_obj_t mp_obj_new_str_iterator(mp_obj_t str, mp_obj_iter_buf_t *iter_buf);
 
 /******************************************************************************/
 /* str                                                                        */
 
-static void uni_print_quoted(const mp_print_t *print, const byte *str_data, uint str_len) {
+STATIC void uni_print_quoted(const mp_print_t *print, const byte *str_data, uint str_len) {
     // this escapes characters, but it will be very slow to print (calling print many times)
     bool has_single_quote = false;
     bool has_double_quote = false;
@@ -83,7 +83,7 @@ static void uni_print_quoted(const mp_print_t *print, const byte *str_data, uint
     mp_printf(print, "%c", quote_char);
 }
 
-static void uni_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
+STATIC void uni_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
     GET_STR_DATA_LEN(self_in, str_data, str_len);
     #if MICROPY_PY_JSON
     if (kind == PRINT_JSON) {
@@ -98,7 +98,7 @@ static void uni_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t
     }
 }
 
-static mp_obj_t uni_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
+STATIC mp_obj_t uni_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
     GET_STR_DATA_LEN(self_in, str_data, str_len);
     switch (op) {
         case MP_UNARY_OP_BOOL:
@@ -178,7 +178,7 @@ const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, s
     return s;
 }
 
-static mp_obj_t str_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
+STATIC mp_obj_t str_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
     const mp_obj_type_t *type = mp_obj_get_type(self_in);
     assert(type == &mp_type_str);
     GET_STR_DATA_LEN(self_in, self_data, self_len);
@@ -253,7 +253,7 @@ typedef struct _mp_obj_str_it_t {
     size_t cur;
 } mp_obj_str_it_t;
 
-static mp_obj_t str_it_iternext(mp_obj_t self_in) {
+STATIC mp_obj_t str_it_iternext(mp_obj_t self_in) {
     mp_obj_str_it_t *self = MP_OBJ_TO_PTR(self_in);
     GET_STR_DATA_LEN(self->str, str, len);
     if (self->cur < len) {
@@ -267,7 +267,7 @@ static mp_obj_t str_it_iternext(mp_obj_t self_in) {
     }
 }
 
-static mp_obj_t mp_obj_new_str_iterator(mp_obj_t str, mp_obj_iter_buf_t *iter_buf) {
+STATIC mp_obj_t mp_obj_new_str_iterator(mp_obj_t str, mp_obj_iter_buf_t *iter_buf) {
     assert(sizeof(mp_obj_str_it_t) <= sizeof(mp_obj_iter_buf_t));
     mp_obj_str_it_t *o = (mp_obj_str_it_t *)iter_buf;
     o->base.type = &mp_type_polymorph_iter;

+ 10 - 10
py/objtuple.c

@@ -65,7 +65,7 @@ void mp_obj_tuple_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t
     }
 }
 
-static mp_obj_t mp_obj_tuple_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
+STATIC mp_obj_t mp_obj_tuple_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
     (void)type_in;
 
     mp_arg_check_num(n_args, n_kw, 0, 1, false);
@@ -107,7 +107,7 @@ static mp_obj_t mp_obj_tuple_make_new(const mp_obj_type_t *type_in, size_t n_arg
 }
 
 // Don't pass MP_BINARY_OP_NOT_EQUAL here
-static mp_obj_t tuple_cmp_helper(mp_uint_t op, mp_obj_t self_in, mp_obj_t another_in) {
+STATIC mp_obj_t tuple_cmp_helper(mp_uint_t op, mp_obj_t self_in, mp_obj_t another_in) {
     mp_check_self(mp_obj_is_tuple_compatible(self_in));
     const mp_obj_type_t *another_type = mp_obj_get_type(another_in);
     mp_obj_tuple_t *self = MP_OBJ_TO_PTR(self_in);
@@ -203,26 +203,26 @@ mp_obj_t mp_obj_tuple_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
     }
 }
 
-static mp_obj_t tuple_count(mp_obj_t self_in, mp_obj_t value) {
+STATIC mp_obj_t tuple_count(mp_obj_t self_in, mp_obj_t value) {
     mp_check_self(mp_obj_is_type(self_in, &mp_type_tuple));
     mp_obj_tuple_t *self = MP_OBJ_TO_PTR(self_in);
     return mp_seq_count_obj(self->items, self->len, value);
 }
-static MP_DEFINE_CONST_FUN_OBJ_2(tuple_count_obj, tuple_count);
+STATIC MP_DEFINE_CONST_FUN_OBJ_2(tuple_count_obj, tuple_count);
 
-static mp_obj_t tuple_index(size_t n_args, const mp_obj_t *args) {
+STATIC mp_obj_t tuple_index(size_t n_args, const mp_obj_t *args) {
     mp_check_self(mp_obj_is_type(args[0], &mp_type_tuple));
     mp_obj_tuple_t *self = MP_OBJ_TO_PTR(args[0]);
     return mp_seq_index_obj(self->items, self->len, n_args, args);
 }
-static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(tuple_index_obj, 2, 4, tuple_index);
+STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(tuple_index_obj, 2, 4, tuple_index);
 
-static const mp_rom_map_elem_t tuple_locals_dict_table[] = {
+STATIC const mp_rom_map_elem_t tuple_locals_dict_table[] = {
     { MP_ROM_QSTR(MP_QSTR_count), MP_ROM_PTR(&tuple_count_obj) },
     { MP_ROM_QSTR(MP_QSTR_index), MP_ROM_PTR(&tuple_index_obj) },
 };
 
-static MP_DEFINE_CONST_DICT(tuple_locals_dict, tuple_locals_dict_table);
+STATIC MP_DEFINE_CONST_DICT(tuple_locals_dict, tuple_locals_dict_table);
 
 MP_DEFINE_CONST_OBJ_TYPE(
     mp_type_tuple,
@@ -244,7 +244,7 @@ mp_obj_t mp_obj_new_tuple(size_t n, const mp_obj_t *items) {
     if (n == 0) {
         return mp_const_empty_tuple;
     }
-    mp_obj_tuple_t *o = mp_obj_malloc_var(mp_obj_tuple_t, items, mp_obj_t, n, &mp_type_tuple);
+    mp_obj_tuple_t *o = mp_obj_malloc_var(mp_obj_tuple_t, mp_obj_t, n, &mp_type_tuple);
     o->len = n;
     if (items) {
         for (size_t i = 0; i < n; i++) {
@@ -277,7 +277,7 @@ typedef struct _mp_obj_tuple_it_t {
     size_t cur;
 } mp_obj_tuple_it_t;
 
-static mp_obj_t tuple_it_iternext(mp_obj_t self_in) {
+STATIC mp_obj_t tuple_it_iternext(mp_obj_t self_in) {
     mp_obj_tuple_it_t *self = MP_OBJ_TO_PTR(self_in);
     if (self->cur < self->tuple->len) {
         mp_obj_t o_out = self->tuple->items[self->cur];

Некоторые файлы не были показаны из-за большого количества измененных файлов