You've already forked Core2forAWS-MicroPython
mirror of
https://github.com/m5stack/Core2forAWS-MicroPython.git
synced 2026-05-20 10:30:31 -07:00
Replace global "static" -> "STATIC", to allow "analysis builds". Part 2.
This commit is contained in:
+7
-7
@@ -93,7 +93,7 @@ void asm_thumb_end_pass(asm_thumb_t *as) {
|
||||
}
|
||||
|
||||
// all functions must go through this one to emit bytes
|
||||
static byte *asm_thumb_get_cur_to_write_bytes(asm_thumb_t *as, int num_bytes_to_write) {
|
||||
STATIC byte *asm_thumb_get_cur_to_write_bytes(asm_thumb_t *as, int num_bytes_to_write) {
|
||||
//printf("emit %d\n", num_bytes_to_write);
|
||||
if (as->pass < ASM_THUMB_PASS_3) {
|
||||
as->code_offset += num_bytes_to_write;
|
||||
@@ -116,20 +116,20 @@ void *asm_thumb_get_code(asm_thumb_t *as) {
|
||||
}
|
||||
|
||||
/*
|
||||
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;
|
||||
}
|
||||
*/
|
||||
|
||||
static void asm_thumb_write_op16(asm_thumb_t *as, uint op) {
|
||||
STATIC void asm_thumb_write_op16(asm_thumb_t *as, uint op) {
|
||||
byte *c = asm_thumb_get_cur_to_write_bytes(as, 2);
|
||||
// little endian
|
||||
c[0] = op;
|
||||
c[1] = op >> 8;
|
||||
}
|
||||
|
||||
static void asm_thumb_write_op32(asm_thumb_t *as, uint op1, uint op2) {
|
||||
STATIC void asm_thumb_write_op32(asm_thumb_t *as, uint op1, uint op2) {
|
||||
byte *c = asm_thumb_get_cur_to_write_bytes(as, 4);
|
||||
// little endian, op1 then op2
|
||||
c[0] = op1;
|
||||
@@ -144,7 +144,7 @@ static void asm_thumb_write_op32(asm_thumb_t *as, uint op1, uint op2) {
|
||||
#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);
|
||||
@@ -226,7 +226,7 @@ void asm_thumb_label_assign(asm_thumb_t *as, int label) {
|
||||
}
|
||||
}
|
||||
|
||||
static int get_label_dest(asm_thumb_t *as, int label) {
|
||||
STATIC int get_label_dest(asm_thumb_t *as, int label) {
|
||||
assert(label < as->max_num_labels);
|
||||
return as->label_offsets[label];
|
||||
}
|
||||
@@ -244,7 +244,7 @@ void asm_thumb_movs_rlo_i8(asm_thumb_t *as, uint rlo_dest, int i8_src) {
|
||||
#define OP_MOVT (0xf2c0)
|
||||
|
||||
// if loading lo half with movw, the i16 value will be zero extended into the r32 register!
|
||||
static void asm_thumb_mov_reg_i16(asm_thumb_t *as, uint mov_op, uint reg_dest, int i16_src) {
|
||||
STATIC void asm_thumb_mov_reg_i16(asm_thumb_t *as, uint mov_op, uint reg_dest, int i16_src) {
|
||||
assert(reg_dest < REG_R15);
|
||||
// mov[wt] reg_dest, #i16_src
|
||||
asm_thumb_write_op32(as, mov_op | ((i16_src >> 1) & 0x0400) | ((i16_src >> 12) & 0xf), ((i16_src << 4) & 0x7000) | (reg_dest << 8) | (i16_src & 0xff));
|
||||
|
||||
+11
-11
@@ -176,7 +176,7 @@ void asm_x64_end_pass(asm_x64_t *as) {
|
||||
}
|
||||
|
||||
// all functions must go through this one to emit bytes
|
||||
static byte *asm_x64_get_cur_to_write_bytes(asm_x64_t *as, int num_bytes_to_write) {
|
||||
STATIC byte *asm_x64_get_cur_to_write_bytes(asm_x64_t *as, int num_bytes_to_write) {
|
||||
//printf("emit %d\n", num_bytes_to_write);
|
||||
if (as->pass < ASM_X64_PASS_3) {
|
||||
as->code_offset += num_bytes_to_write;
|
||||
@@ -197,25 +197,25 @@ void *asm_x64_get_code(asm_x64_t *as) {
|
||||
return as->code_base;
|
||||
}
|
||||
|
||||
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);
|
||||
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);
|
||||
c[0] = b1;
|
||||
c[1] = 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);
|
||||
c[0] = b1;
|
||||
c[1] = b2;
|
||||
c[2] = 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);
|
||||
c[0] = IMM32_L0(w32);
|
||||
c[1] = IMM32_L1(w32);
|
||||
@@ -223,7 +223,7 @@ static void asm_x64_write_word32(asm_x64_t *as, int w32) {
|
||||
c[3] = IMM32_L3(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);
|
||||
c[0] = IMM32_L0(w64);
|
||||
c[1] = IMM32_L1(w64);
|
||||
@@ -236,7 +236,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;
|
||||
@@ -247,7 +247,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) {
|
||||
assert(disp_r64 != REG_RSP);
|
||||
|
||||
if (disp_offset == 0 && disp_r64 != REG_RBP) {
|
||||
@@ -282,7 +282,7 @@ void asm_x64_pop_r64(asm_x64_t *as, int dest_r64) {
|
||||
asm_x64_write_byte_1(as, OPCODE_POP_R64 | 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);
|
||||
}
|
||||
|
||||
@@ -472,7 +472,7 @@ void asm_x64_label_assign(asm_x64_t *as, int label) {
|
||||
}
|
||||
}
|
||||
|
||||
static int get_label_dest(asm_x64_t *as, int label) {
|
||||
STATIC int get_label_dest(asm_x64_t *as, int label) {
|
||||
assert(label < as->max_num_labels);
|
||||
return as->label_offsets[label];
|
||||
}
|
||||
@@ -565,7 +565,7 @@ void asm_x64_mov_r32_to_arg(asm_x64_t *as, int src_r32, int dest_arg_num) {
|
||||
// ^ ^
|
||||
// | low address | high address in RAM
|
||||
//
|
||||
static int asm_x64_local_offset_from_ebp(asm_x64_t *as, int local_num) {
|
||||
STATIC int asm_x64_local_offset_from_ebp(asm_x64_t *as, int local_num) {
|
||||
return (-as->num_locals + local_num) * WORD_SIZE;
|
||||
}
|
||||
|
||||
|
||||
+24
-24
@@ -18,7 +18,7 @@
|
||||
// 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__(uint n_args, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t mp_builtin___build_class__(uint n_args, const mp_obj_t *args) {
|
||||
assert(2 <= n_args);
|
||||
|
||||
// we differ from CPython: we set the new __locals__ object here
|
||||
@@ -61,7 +61,7 @@ static mp_obj_t mp_builtin___build_class__(uint 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___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(o, PRINT_REPR);
|
||||
printf("\n");
|
||||
@@ -100,7 +100,7 @@ mp_obj_t mp_builtin_abs(mp_obj_t 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_t iterable = rt_getiter(o_in);
|
||||
mp_obj_t item;
|
||||
while ((item = rt_iternext(iterable)) != mp_const_stop_iteration) {
|
||||
@@ -113,7 +113,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_t iterable = rt_getiter(o_in);
|
||||
mp_obj_t item;
|
||||
while ((item = rt_iternext(iterable)) != mp_const_stop_iteration) {
|
||||
@@ -126,7 +126,7 @@ 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_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 {
|
||||
@@ -136,7 +136,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) {
|
||||
int ord = mp_obj_get_int(o_in);
|
||||
if (0 <= ord && ord <= 0x10ffff) {
|
||||
byte str[1] = {ord};
|
||||
@@ -148,7 +148,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(uint n_args, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t mp_builtin_dir(uint n_args, const mp_obj_t *args) {
|
||||
// TODO make this function more general and less of a hack
|
||||
|
||||
mp_map_t *map;
|
||||
@@ -178,7 +178,7 @@ static mp_obj_t mp_builtin_dir(uint 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) {
|
||||
if (MP_OBJ_IS_SMALL_INT(o1_in) && MP_OBJ_IS_SMALL_INT(o2_in)) {
|
||||
mp_small_int_t i1 = MP_OBJ_SMALL_INT_VALUE(o1_in);
|
||||
mp_small_int_t i2 = MP_OBJ_SMALL_INT_VALUE(o2_in);
|
||||
@@ -193,20 +193,20 @@ static mp_obj_t mp_builtin_divmod(mp_obj_t o1_in, mp_obj_t 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) {
|
||||
// TODO hash will generally overflow small integer; can we safely truncate it?
|
||||
return mp_obj_new_int(mp_obj_hash(o_in));
|
||||
}
|
||||
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_hash_obj, mp_builtin_hash);
|
||||
|
||||
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 rt_getiter(o_in);
|
||||
}
|
||||
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_iter_obj, mp_builtin_iter);
|
||||
|
||||
static mp_obj_t mp_builtin_len(mp_obj_t o_in) {
|
||||
STATIC mp_obj_t mp_builtin_len(mp_obj_t o_in) {
|
||||
mp_obj_t len = mp_obj_len_maybe(o_in);
|
||||
if (len == NULL) {
|
||||
nlr_jump(mp_obj_new_exception_msg_varg(MP_QSTR_TypeError, "object of type '%s' has no len()", mp_obj_get_type_str(o_in)));
|
||||
@@ -217,7 +217,7 @@ static mp_obj_t mp_builtin_len(mp_obj_t o_in) {
|
||||
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_len_obj, mp_builtin_len);
|
||||
|
||||
static mp_obj_t mp_builtin_max(uint n_args, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t mp_builtin_max(uint n_args, const mp_obj_t *args) {
|
||||
if (n_args == 1) {
|
||||
// given an iterable
|
||||
mp_obj_t iterable = rt_getiter(args[0]);
|
||||
@@ -246,7 +246,7 @@ static mp_obj_t mp_builtin_max(uint n_args, const mp_obj_t *args) {
|
||||
|
||||
MP_DEFINE_CONST_FUN_OBJ_VAR(mp_builtin_max_obj, 1, mp_builtin_max);
|
||||
|
||||
static mp_obj_t mp_builtin_min(uint n_args, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t mp_builtin_min(uint n_args, const mp_obj_t *args) {
|
||||
if (n_args == 1) {
|
||||
// given an iterable
|
||||
mp_obj_t iterable = rt_getiter(args[0]);
|
||||
@@ -275,7 +275,7 @@ static mp_obj_t mp_builtin_min(uint n_args, const mp_obj_t *args) {
|
||||
|
||||
MP_DEFINE_CONST_FUN_OBJ_VAR(mp_builtin_min_obj, 1, mp_builtin_min);
|
||||
|
||||
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 = rt_iternext(o);
|
||||
if (ret == mp_const_stop_iteration) {
|
||||
nlr_jump(mp_obj_new_exception(MP_QSTR_StopIteration));
|
||||
@@ -286,7 +286,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);
|
||||
|
||||
static mp_obj_t mp_builtin_ord(mp_obj_t o_in) {
|
||||
STATIC mp_obj_t mp_builtin_ord(mp_obj_t o_in) {
|
||||
uint len;
|
||||
const char *str = mp_obj_str_get_data(o_in, &len);
|
||||
if (len == 1) {
|
||||
@@ -300,7 +300,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(uint n_args, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t mp_builtin_pow(uint n_args, const mp_obj_t *args) {
|
||||
assert(2 <= n_args && n_args <= 3);
|
||||
switch (n_args) {
|
||||
case 2: return rt_binary_op(RT_BINARY_OP_POWER, args[0], args[1]);
|
||||
@@ -310,7 +310,7 @@ static mp_obj_t mp_builtin_pow(uint 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(uint n_args, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t mp_builtin_print(uint n_args, const mp_obj_t *args) {
|
||||
for (int i = 0; i < n_args; i++) {
|
||||
if (i > 0) {
|
||||
printf(" ");
|
||||
@@ -323,7 +323,7 @@ static mp_obj_t mp_builtin_print(uint n_args, const mp_obj_t *args) {
|
||||
|
||||
MP_DEFINE_CONST_FUN_OBJ_VAR(mp_builtin_print_obj, 0, mp_builtin_print);
|
||||
|
||||
static mp_obj_t mp_builtin_range(uint n_args, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t mp_builtin_range(uint n_args, const mp_obj_t *args) {
|
||||
assert(1 <= n_args && n_args <= 3);
|
||||
switch (n_args) {
|
||||
case 1: return mp_obj_new_range(0, mp_obj_get_int(args[0]), 1);
|
||||
@@ -334,7 +334,7 @@ static mp_obj_t mp_builtin_range(uint n_args, const mp_obj_t *args) {
|
||||
|
||||
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_range_obj, 1, 3, mp_builtin_range);
|
||||
|
||||
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 = vstr_new();
|
||||
mp_obj_print_helper((void (*)(void *env, const char *fmt, ...))vstr_printf, vstr, o_in, PRINT_REPR);
|
||||
mp_obj_t s = mp_obj_new_str((byte*)vstr->buf, vstr->len, false);
|
||||
@@ -344,7 +344,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_sum(uint n_args, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t mp_builtin_sum(uint n_args, const mp_obj_t *args) {
|
||||
assert(1 <= n_args && n_args <= 2);
|
||||
mp_obj_t value;
|
||||
switch (n_args) {
|
||||
@@ -361,7 +361,7 @@ static mp_obj_t mp_builtin_sum(uint 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(uint n_args, const mp_obj_t *args, mp_map_t *kwargs) {
|
||||
STATIC mp_obj_t mp_builtin_sorted(uint n_args, const mp_obj_t *args, mp_map_t *kwargs) {
|
||||
assert(n_args >= 1);
|
||||
if (n_args > 1) {
|
||||
nlr_jump(mp_obj_new_exception_msg(MP_QSTR_TypeError,
|
||||
@@ -375,7 +375,7 @@ static mp_obj_t mp_builtin_sorted(uint n_args, const mp_obj_t *args, mp_map_t *k
|
||||
|
||||
MP_DEFINE_CONST_FUN_OBJ_KW(mp_builtin_sorted_obj, 1, mp_builtin_sorted);
|
||||
|
||||
static mp_obj_t mp_builtin_str(mp_obj_t o_in) {
|
||||
STATIC mp_obj_t mp_builtin_str(mp_obj_t o_in) {
|
||||
vstr_t *vstr = vstr_new();
|
||||
mp_obj_print_helper((void (*)(void*, const char*, ...))vstr_printf, vstr, o_in, PRINT_STR);
|
||||
mp_obj_t s = mp_obj_new_str((byte*)vstr->buf, vstr->len, false);
|
||||
@@ -386,7 +386,7 @@ static mp_obj_t mp_builtin_str(mp_obj_t o_in) {
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_str_obj, mp_builtin_str);
|
||||
|
||||
// TODO: This should be type, this is just quick CPython compat hack
|
||||
static mp_obj_t mp_builtin_bytes(uint n_args, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t mp_builtin_bytes(uint n_args, const mp_obj_t *args) {
|
||||
if (!MP_OBJ_IS_QSTR(args[0]) && !MP_OBJ_IS_TYPE(args[0], &str_type)) {
|
||||
assert(0);
|
||||
}
|
||||
@@ -397,7 +397,7 @@ static mp_obj_t mp_builtin_bytes(uint n_args, const mp_obj_t *args) {
|
||||
|
||||
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_bytes_obj, 1, 3, mp_builtin_bytes);
|
||||
|
||||
static mp_obj_t mp_builtin_id(mp_obj_t o_in) {
|
||||
STATIC mp_obj_t mp_builtin_id(mp_obj_t o_in) {
|
||||
return mp_obj_new_int((machine_int_t)o_in);
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -19,7 +19,7 @@
|
||||
#include "map.h"
|
||||
#include "builtin.h"
|
||||
|
||||
static mp_obj_t parse_compile_execute(mp_obj_t o_in, mp_parse_input_kind_t parse_input_kind) {
|
||||
STATIC mp_obj_t parse_compile_execute(mp_obj_t o_in, mp_parse_input_kind_t parse_input_kind) {
|
||||
uint str_len;
|
||||
const char *str = mp_obj_str_get_data(o_in, &str_len);
|
||||
|
||||
@@ -51,13 +51,13 @@ static mp_obj_t parse_compile_execute(mp_obj_t o_in, mp_parse_input_kind_t parse
|
||||
return rt_call_function_0(module_fun);
|
||||
}
|
||||
|
||||
static mp_obj_t mp_builtin_eval(mp_obj_t o_in) {
|
||||
STATIC mp_obj_t mp_builtin_eval(mp_obj_t o_in) {
|
||||
return parse_compile_execute(o_in, MP_PARSE_EVAL_INPUT);
|
||||
}
|
||||
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_eval_obj, mp_builtin_eval);
|
||||
|
||||
static mp_obj_t mp_builtin_exec(mp_obj_t o_in) {
|
||||
STATIC mp_obj_t mp_builtin_exec(mp_obj_t o_in) {
|
||||
return parse_compile_execute(o_in, MP_PARSE_FILE_INPUT);
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -16,15 +16,15 @@
|
||||
// living in micropython module
|
||||
|
||||
#if MICROPY_MEM_STATS
|
||||
static mp_obj_t mem_total() {
|
||||
STATIC mp_obj_t mem_total() {
|
||||
return MP_OBJ_NEW_SMALL_INT((machine_int_t)m_get_total_bytes_allocated());
|
||||
}
|
||||
|
||||
static mp_obj_t mem_current() {
|
||||
STATIC mp_obj_t mem_current() {
|
||||
return MP_OBJ_NEW_SMALL_INT((machine_int_t)m_get_current_bytes_allocated());
|
||||
}
|
||||
|
||||
static mp_obj_t mem_peak() {
|
||||
STATIC mp_obj_t mem_peak() {
|
||||
return MP_OBJ_NEW_SMALL_INT((machine_int_t)m_get_peak_bytes_allocated());
|
||||
}
|
||||
|
||||
|
||||
+17
-17
@@ -188,14 +188,14 @@ mp_parse_node_t fold_constants(mp_parse_node_t pn) {
|
||||
return 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_trailer_paren_helper(compiler_t *comp, mp_parse_node_t pn_arglist, bool is_method_call, int n_positional_extra);
|
||||
void compile_node(compiler_t *comp, mp_parse_node_t pn);
|
||||
|
||||
static int comp_next_label(compiler_t *comp) {
|
||||
STATIC int comp_next_label(compiler_t *comp) {
|
||||
return comp->next_label++;
|
||||
}
|
||||
|
||||
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, comp->source_file, rt_get_unique_code_id(), emit_options);
|
||||
scope->parent = comp->scope_cur;
|
||||
scope->next = NULL;
|
||||
@@ -211,7 +211,7 @@ static scope_t *scope_new_and_link(compiler_t *comp, scope_kind_t kind, mp_parse
|
||||
return scope;
|
||||
}
|
||||
|
||||
static int list_len(mp_parse_node_t pn, int pn_kind) {
|
||||
STATIC int list_len(mp_parse_node_t pn, int pn_kind) {
|
||||
if (MP_PARSE_NODE_IS_NULL(pn)) {
|
||||
return 0;
|
||||
} else if (MP_PARSE_NODE_IS_LEAF(pn)) {
|
||||
@@ -226,7 +226,7 @@ static int list_len(mp_parse_node_t pn, int pn_kind) {
|
||||
}
|
||||
}
|
||||
|
||||
static void apply_to_single_or_list(compiler_t *comp, mp_parse_node_t pn, int pn_list_kind, void (*f)(compiler_t*, mp_parse_node_t)) {
|
||||
STATIC void apply_to_single_or_list(compiler_t *comp, mp_parse_node_t pn, int pn_list_kind, void (*f)(compiler_t*, mp_parse_node_t)) {
|
||||
if (MP_PARSE_NODE_IS_STRUCT(pn) && MP_PARSE_NODE_STRUCT_KIND((mp_parse_node_struct_t*)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);
|
||||
@@ -238,7 +238,7 @@ static void apply_to_single_or_list(compiler_t *comp, mp_parse_node_t pn, int pn
|
||||
}
|
||||
}
|
||||
|
||||
static int list_get(mp_parse_node_t *pn, int pn_kind, mp_parse_node_t **nodes) {
|
||||
STATIC int list_get(mp_parse_node_t *pn, int pn_kind, mp_parse_node_t **nodes) {
|
||||
if (MP_PARSE_NODE_IS_NULL(*pn)) {
|
||||
*nodes = NULL;
|
||||
return 0;
|
||||
@@ -268,7 +268,7 @@ void compile_generic_all_nodes(compiler_t *comp, mp_parse_node_struct_t *pns) {
|
||||
}
|
||||
|
||||
#if MICROPY_EMIT_CPYTHON
|
||||
static bool cpython_c_tuple_is_const(mp_parse_node_t pn) {
|
||||
STATIC bool cpython_c_tuple_is_const(mp_parse_node_t pn) {
|
||||
if (!MP_PARSE_NODE_IS_LEAF(pn)) {
|
||||
return false;
|
||||
}
|
||||
@@ -278,7 +278,7 @@ static bool cpython_c_tuple_is_const(mp_parse_node_t pn) {
|
||||
return true;
|
||||
}
|
||||
|
||||
static void cpython_c_print_quoted_str(vstr_t *vstr, qstr qstr, bool bytes) {
|
||||
STATIC void cpython_c_print_quoted_str(vstr_t *vstr, qstr qstr, bool bytes) {
|
||||
uint len;
|
||||
const byte *str = qstr_data(qstr, &len);
|
||||
bool has_single_quote = false;
|
||||
@@ -318,7 +318,7 @@ static void cpython_c_print_quoted_str(vstr_t *vstr, qstr qstr, bool bytes) {
|
||||
}
|
||||
}
|
||||
|
||||
static void cpython_c_tuple_emit_const(compiler_t *comp, mp_parse_node_t pn, vstr_t *vstr) {
|
||||
STATIC void cpython_c_tuple_emit_const(compiler_t *comp, mp_parse_node_t pn, vstr_t *vstr) {
|
||||
assert(MP_PARSE_NODE_IS_LEAF(pn));
|
||||
int arg = MP_PARSE_NODE_LEAF_ARG(pn);
|
||||
switch (MP_PARSE_NODE_LEAF_KIND(pn)) {
|
||||
@@ -340,7 +340,7 @@ static void cpython_c_tuple_emit_const(compiler_t *comp, mp_parse_node_t pn, vst
|
||||
}
|
||||
}
|
||||
|
||||
static void cpython_c_tuple(compiler_t *comp, mp_parse_node_t pn, mp_parse_node_struct_t *pns_list) {
|
||||
STATIC void cpython_c_tuple(compiler_t *comp, mp_parse_node_t pn, mp_parse_node_struct_t *pns_list) {
|
||||
int n = 0;
|
||||
if (pns_list != NULL) {
|
||||
n = MP_PARSE_NODE_STRUCT_NUM_NODES(pns_list);
|
||||
@@ -419,18 +419,18 @@ void compile_generic_tuple(compiler_t *comp, mp_parse_node_struct_t *pns) {
|
||||
c_tuple(comp, MP_PARSE_NODE_NULL, pns);
|
||||
}
|
||||
|
||||
static bool node_is_const_false(mp_parse_node_t pn) {
|
||||
STATIC bool node_is_const_false(mp_parse_node_t pn) {
|
||||
return MP_PARSE_NODE_IS_TOKEN_KIND(pn, MP_TOKEN_KW_FALSE);
|
||||
// untested: || (MP_PARSE_NODE_IS_SMALL_INT(pn) && MP_PARSE_NODE_LEAF_ARG(pn) == 1);
|
||||
}
|
||||
|
||||
static bool node_is_const_true(mp_parse_node_t pn) {
|
||||
STATIC bool node_is_const_true(mp_parse_node_t pn) {
|
||||
return MP_PARSE_NODE_IS_TOKEN_KIND(pn, MP_TOKEN_KW_TRUE) || (MP_PARSE_NODE_IS_SMALL_INT(pn) && MP_PARSE_NODE_LEAF_ARG(pn) == 1);
|
||||
}
|
||||
|
||||
#if MICROPY_EMIT_CPYTHON
|
||||
// the is_nested variable is purely to match with CPython, which doesn't fully optimise not's
|
||||
static void cpython_c_if_cond(compiler_t *comp, mp_parse_node_t pn, bool jump_if, int label, bool is_nested) {
|
||||
STATIC void cpython_c_if_cond(compiler_t *comp, mp_parse_node_t pn, bool jump_if, int label, bool is_nested) {
|
||||
if (node_is_const_false(pn)) {
|
||||
if (jump_if == false) {
|
||||
EMIT_ARG(jump, label);
|
||||
@@ -488,7 +488,7 @@ static void cpython_c_if_cond(compiler_t *comp, mp_parse_node_t pn, bool jump_if
|
||||
}
|
||||
#endif
|
||||
|
||||
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 MICROPY_EMIT_CPYTHON
|
||||
cpython_c_if_cond(comp, pn, jump_if, label, false);
|
||||
#else
|
||||
@@ -889,7 +889,7 @@ qstr compile_classdef_helper(compiler_t *comp, mp_parse_node_struct_t *pns, uint
|
||||
}
|
||||
|
||||
// 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, int name_len, mp_parse_node_t *name_nodes, uint *emit_options) {
|
||||
STATIC bool compile_built_in_decorator(compiler_t *comp, int 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;
|
||||
}
|
||||
@@ -2066,7 +2066,7 @@ void compile_power(compiler_t *comp, mp_parse_node_struct_t *pns) {
|
||||
compile_generic_all_nodes(comp, pns);
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
#if !MICROPY_EMIT_CPYTHON
|
||||
@@ -2498,7 +2498,7 @@ void compile_yield_expr(compiler_t *comp, mp_parse_node_struct_t *pns) {
|
||||
}
|
||||
|
||||
typedef void (*compile_function_t)(compiler_t*, mp_parse_node_struct_t*);
|
||||
static compile_function_t compile_function[] = {
|
||||
STATIC compile_function_t compile_function[] = {
|
||||
NULL,
|
||||
#define nc NULL
|
||||
#define c(f) compile_##f
|
||||
|
||||
+97
-96
File diff suppressed because it is too large
Load Diff
+89
-88
File diff suppressed because it is too large
Load Diff
@@ -40,14 +40,14 @@ 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, scope_t *scope) {
|
||||
STATIC void emit_inline_thumb_start_pass(emit_inline_asm_t *emit, pass_kind_t pass, scope_t *scope) {
|
||||
emit->pass = pass;
|
||||
emit->scope = scope;
|
||||
asm_thumb_start_pass(emit->as, pass);
|
||||
asm_thumb_entry(emit->as, 0);
|
||||
}
|
||||
|
||||
static void emit_inline_thumb_end_pass(emit_inline_asm_t *emit) {
|
||||
STATIC void emit_inline_thumb_end_pass(emit_inline_asm_t *emit) {
|
||||
asm_thumb_exit(emit->as);
|
||||
asm_thumb_end_pass(emit->as);
|
||||
|
||||
@@ -57,7 +57,7 @@ static void emit_inline_thumb_end_pass(emit_inline_asm_t *emit) {
|
||||
}
|
||||
}
|
||||
|
||||
static int emit_inline_thumb_count_params(emit_inline_asm_t *emit, int n_params, mp_parse_node_t *pn_params) {
|
||||
STATIC int emit_inline_thumb_count_params(emit_inline_asm_t *emit, int n_params, mp_parse_node_t *pn_params) {
|
||||
if (n_params > 4) {
|
||||
printf("SyntaxError: can only have up to 4 parameters to inline thumb assembly\n");
|
||||
return 0;
|
||||
@@ -76,13 +76,13 @@ static int emit_inline_thumb_count_params(emit_inline_asm_t *emit, int n_params,
|
||||
return n_params;
|
||||
}
|
||||
|
||||
static void emit_inline_thumb_label(emit_inline_asm_t *emit, int label_num, qstr label_id) {
|
||||
STATIC void emit_inline_thumb_label(emit_inline_asm_t *emit, int label_num, qstr label_id) {
|
||||
assert(label_num < emit->max_num_labels);
|
||||
emit->label_lookup[label_num] = label_id;
|
||||
asm_thumb_label_assign(emit->as, label_num);
|
||||
}
|
||||
|
||||
static bool check_n_arg(qstr op, int n_args, int wanted_n_args) {
|
||||
STATIC bool check_n_arg(qstr op, int n_args, int wanted_n_args) {
|
||||
if (wanted_n_args == n_args) {
|
||||
return true;
|
||||
} else {
|
||||
@@ -91,7 +91,7 @@ static bool check_n_arg(qstr op, int n_args, int wanted_n_args) {
|
||||
}
|
||||
}
|
||||
|
||||
static uint get_arg_rlo(qstr op, mp_parse_node_t *pn_args, int wanted_arg_num) {
|
||||
STATIC uint get_arg_rlo(qstr op, mp_parse_node_t *pn_args, int wanted_arg_num) {
|
||||
if (!MP_PARSE_NODE_IS_ID(pn_args[wanted_arg_num])) {
|
||||
printf("SyntaxError: '%s' expects a register in position %d\n", qstr_str(op), wanted_arg_num);
|
||||
return 0;
|
||||
@@ -105,7 +105,7 @@ static uint get_arg_rlo(qstr op, mp_parse_node_t *pn_args, int wanted_arg_num) {
|
||||
return reg_str[1] - '0';
|
||||
}
|
||||
|
||||
static int get_arg_i(qstr op, mp_parse_node_t *pn_args, int wanted_arg_num, int fit_mask) {
|
||||
STATIC int get_arg_i(qstr op, mp_parse_node_t *pn_args, int wanted_arg_num, int fit_mask) {
|
||||
if (!MP_PARSE_NODE_IS_SMALL_INT(pn_args[wanted_arg_num])) {
|
||||
printf("SyntaxError: '%s' expects an integer in position %d\n", qstr_str(op), wanted_arg_num);
|
||||
return 0;
|
||||
@@ -118,7 +118,7 @@ static int get_arg_i(qstr op, mp_parse_node_t *pn_args, int wanted_arg_num, int
|
||||
return i;
|
||||
}
|
||||
|
||||
static int get_arg_label(emit_inline_asm_t *emit, qstr op, mp_parse_node_t *pn_args, int wanted_arg_num) {
|
||||
STATIC int get_arg_label(emit_inline_asm_t *emit, qstr op, mp_parse_node_t *pn_args, int wanted_arg_num) {
|
||||
if (!MP_PARSE_NODE_IS_ID(pn_args[wanted_arg_num])) {
|
||||
printf("SyntaxError: '%s' expects a label in position %d\n", qstr_str(op), wanted_arg_num);
|
||||
return 0;
|
||||
@@ -136,7 +136,7 @@ static int get_arg_label(emit_inline_asm_t *emit, qstr op, mp_parse_node_t *pn_a
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void emit_inline_thumb_op(emit_inline_asm_t *emit, qstr op, int n_args, mp_parse_node_t *pn_args) {
|
||||
STATIC void emit_inline_thumb_op(emit_inline_asm_t *emit, qstr op, int n_args, mp_parse_node_t *pn_args) {
|
||||
// TODO perhaps make two tables:
|
||||
// one_args =
|
||||
// "b", LAB, asm_thumb_b_n,
|
||||
|
||||
+109
-108
File diff suppressed because it is too large
Load Diff
+7
-7
@@ -27,18 +27,18 @@ void emit_pass1_free(emit_t *emit) {
|
||||
m_del_obj(emit_t, emit);
|
||||
}
|
||||
|
||||
static void emit_pass1_dummy(emit_t *emit) {
|
||||
STATIC void emit_pass1_dummy(emit_t *emit) {
|
||||
}
|
||||
|
||||
static void emit_pass1_start_pass(emit_t *emit, pass_kind_t pass, scope_t *scope) {
|
||||
STATIC void emit_pass1_start_pass(emit_t *emit, pass_kind_t pass, scope_t *scope) {
|
||||
assert(pass == PASS_1);
|
||||
emit->scope = scope;
|
||||
}
|
||||
|
||||
static void emit_pass1_end_pass(emit_t *emit) {
|
||||
STATIC void emit_pass1_end_pass(emit_t *emit) {
|
||||
}
|
||||
|
||||
static void emit_pass1_load_id(emit_t *emit, qstr qstr) {
|
||||
STATIC void emit_pass1_load_id(emit_t *emit, qstr qstr) {
|
||||
// name adding/lookup
|
||||
bool added;
|
||||
id_info_t *id = scope_find_or_add_id(emit->scope, qstr, &added);
|
||||
@@ -69,7 +69,7 @@ static void emit_pass1_load_id(emit_t *emit, qstr qstr) {
|
||||
}
|
||||
}
|
||||
|
||||
static id_info_t *get_id_for_modification(scope_t *scope, qstr qstr) {
|
||||
STATIC id_info_t *get_id_for_modification(scope_t *scope, qstr qstr) {
|
||||
// name adding/lookup
|
||||
bool added;
|
||||
id_info_t *id = scope_find_or_add_id(scope, qstr, &added);
|
||||
@@ -89,11 +89,11 @@ static id_info_t *get_id_for_modification(scope_t *scope, qstr qstr) {
|
||||
return id;
|
||||
}
|
||||
|
||||
static void emit_pass1_store_id(emit_t *emit, qstr qstr) {
|
||||
STATIC void emit_pass1_store_id(emit_t *emit, qstr qstr) {
|
||||
get_id_for_modification(emit->scope, qstr);
|
||||
}
|
||||
|
||||
static void emit_pass1_delete_id(emit_t *emit, qstr qstr) {
|
||||
STATIC void emit_pass1_delete_id(emit_t *emit, qstr qstr) {
|
||||
get_id_for_modification(emit->scope, qstr);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,14 +21,14 @@ typedef unsigned char byte;
|
||||
#define BYTES_PER_BLOCK (WORDS_PER_BLOCK * BYTES_PER_WORD)
|
||||
#define STACK_SIZE (64) // tunable; minimum is 1
|
||||
|
||||
static byte *gc_alloc_table_start;
|
||||
static machine_uint_t gc_alloc_table_byte_len;
|
||||
static machine_uint_t *gc_pool_start;
|
||||
static machine_uint_t *gc_pool_end;
|
||||
STATIC byte *gc_alloc_table_start;
|
||||
STATIC machine_uint_t gc_alloc_table_byte_len;
|
||||
STATIC machine_uint_t *gc_pool_start;
|
||||
STATIC machine_uint_t *gc_pool_end;
|
||||
|
||||
static int gc_stack_overflow;
|
||||
static machine_uint_t gc_stack[STACK_SIZE];
|
||||
static machine_uint_t *gc_sp;
|
||||
STATIC int gc_stack_overflow;
|
||||
STATIC machine_uint_t gc_stack[STACK_SIZE];
|
||||
STATIC machine_uint_t *gc_sp;
|
||||
|
||||
// ATB = allocation table byte
|
||||
// 0b00 = FREE -- free block
|
||||
@@ -116,7 +116,7 @@ void gc_init(void *start, void *end) {
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
static void gc_drain_stack(void) {
|
||||
STATIC void gc_drain_stack(void) {
|
||||
while (gc_sp > gc_stack) {
|
||||
// pop the next block off the stack
|
||||
machine_uint_t block = *--gc_sp;
|
||||
@@ -136,7 +136,7 @@ static void gc_drain_stack(void) {
|
||||
}
|
||||
}
|
||||
|
||||
static void gc_deal_with_stack_overflow(void) {
|
||||
STATIC void gc_deal_with_stack_overflow(void) {
|
||||
while (gc_stack_overflow) {
|
||||
gc_stack_overflow = 0;
|
||||
gc_sp = gc_stack;
|
||||
@@ -152,7 +152,7 @@ static void gc_deal_with_stack_overflow(void) {
|
||||
}
|
||||
}
|
||||
|
||||
static void gc_sweep(void) {
|
||||
STATIC void gc_sweep(void) {
|
||||
// free unmarked heads and their tails
|
||||
int free_tail = 0;
|
||||
for (machine_uint_t block = 0; block < gc_alloc_table_byte_len * BLOCKS_PER_ATB; block++) {
|
||||
@@ -351,7 +351,7 @@ void gc_dump_info() {
|
||||
}
|
||||
|
||||
#if DEBUG_PRINT
|
||||
static void gc_dump_at(void) {
|
||||
STATIC void gc_dump_at(void) {
|
||||
for (machine_uint_t bl = 0; bl < gc_alloc_table_byte_len * BLOCKS_PER_ATB; bl++) {
|
||||
printf("block %06u ", bl);
|
||||
switch (ATB_GET_KIND(bl)) {
|
||||
|
||||
+23
-23
@@ -72,75 +72,75 @@ void mp_token_show(const mp_token_t *tok) {
|
||||
|
||||
#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_CHAR_EOF;
|
||||
}
|
||||
|
||||
static bool is_physical_newline(mp_lexer_t *lex) {
|
||||
STATIC bool is_physical_newline(mp_lexer_t *lex) {
|
||||
return lex->chr0 == '\n' || lex->chr0 == '\r';
|
||||
}
|
||||
|
||||
static bool is_char(mp_lexer_t *lex, char c) {
|
||||
STATIC bool is_char(mp_lexer_t *lex, char c) {
|
||||
return lex->chr0 == c;
|
||||
}
|
||||
|
||||
static bool is_char_or(mp_lexer_t *lex, char c1, char c2) {
|
||||
STATIC bool is_char_or(mp_lexer_t *lex, char c1, char c2) {
|
||||
return lex->chr0 == c1 || lex->chr0 == c2;
|
||||
}
|
||||
|
||||
static bool is_char_or3(mp_lexer_t *lex, char c1, char c2, char c3) {
|
||||
STATIC bool is_char_or3(mp_lexer_t *lex, char c1, char c2, char c3) {
|
||||
return lex->chr0 == c1 || lex->chr0 == c2 || lex->chr0 == c3;
|
||||
}
|
||||
|
||||
/*
|
||||
static bool is_char_following(mp_lexer_t *lex, char c) {
|
||||
STATIC bool is_char_following(mp_lexer_t *lex, char c) {
|
||||
return lex->chr1 == c;
|
||||
}
|
||||
*/
|
||||
|
||||
static bool is_char_following_or(mp_lexer_t *lex, char c1, char c2) {
|
||||
STATIC bool is_char_following_or(mp_lexer_t *lex, char c1, char c2) {
|
||||
return lex->chr1 == c1 || lex->chr1 == c2;
|
||||
}
|
||||
|
||||
static bool is_char_following_following_or(mp_lexer_t *lex, char c1, char c2) {
|
||||
STATIC bool is_char_following_following_or(mp_lexer_t *lex, char c1, char c2) {
|
||||
return lex->chr2 == c1 || lex->chr2 == c2;
|
||||
}
|
||||
|
||||
static bool is_char_and(mp_lexer_t *lex, char c1, char c2) {
|
||||
STATIC bool is_char_and(mp_lexer_t *lex, char c1, char 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_odigit(mp_lexer_t *lex) {
|
||||
STATIC bool is_following_odigit(mp_lexer_t *lex) {
|
||||
return lex->chr1 >= '0' && lex->chr1 <= '7';
|
||||
}
|
||||
|
||||
// TODO UNICODE include unicode characters in definition of identifiers
|
||||
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 == '_';
|
||||
}
|
||||
|
||||
// TODO UNICODE include unicode characters in definition of identifiers
|
||||
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 == MP_LEXER_CHAR_EOF) {
|
||||
return;
|
||||
}
|
||||
@@ -203,7 +203,7 @@ 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 *tok_enc =
|
||||
STATIC const char *tok_enc =
|
||||
"()[]{},:;@~" // singles
|
||||
"<e=c<e=" // < <= << <<=
|
||||
">e=c>e=" // > >= >> >>=
|
||||
@@ -220,7 +220,7 @@ static const char *tok_enc =
|
||||
".c.E."; // . ...
|
||||
|
||||
// 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,
|
||||
@@ -242,7 +242,7 @@ static const uint8_t tok_enc_kind[] = {
|
||||
};
|
||||
|
||||
// must have the same order as enum in lexer.h
|
||||
static const char *tok_kw[] = {
|
||||
STATIC const char *tok_kw[] = {
|
||||
"False",
|
||||
"None",
|
||||
"True",
|
||||
@@ -279,7 +279,7 @@ static const char *tok_kw[] = {
|
||||
NULL,
|
||||
};
|
||||
|
||||
static int hex_digit(unichar c) {
|
||||
STATIC int hex_digit(unichar c) {
|
||||
// c is assumed to be hex digit
|
||||
int n = c - '0';
|
||||
if (n > 9) {
|
||||
@@ -291,7 +291,7 @@ static int hex_digit(unichar c) {
|
||||
|
||||
// This is called with CUR_CHAR() before first hex digit, and should return with
|
||||
// it pointing to last hex digit
|
||||
static bool get_hex(mp_lexer_t *lex, int num_digits, uint *result) {
|
||||
STATIC bool get_hex(mp_lexer_t *lex, int num_digits, uint *result) {
|
||||
uint num = 0;
|
||||
while (num_digits-- != 0) {
|
||||
next_char(lex);
|
||||
@@ -305,7 +305,7 @@ static bool get_hex(mp_lexer_t *lex, int num_digits, uint *result) {
|
||||
return true;
|
||||
}
|
||||
|
||||
static void mp_lexer_next_token_into(mp_lexer_t *lex, mp_token_t *tok, bool first_token) {
|
||||
STATIC void mp_lexer_next_token_into(mp_lexer_t *lex, mp_token_t *tok, bool first_token) {
|
||||
// skip white space and comments
|
||||
bool had_physical_newline = false;
|
||||
while (!is_end(lex)) {
|
||||
|
||||
+2
-2
@@ -13,7 +13,7 @@ typedef struct _mp_lexer_str_buf_t {
|
||||
const char *src_end; // end (exclusive) of source
|
||||
} mp_lexer_str_buf_t;
|
||||
|
||||
static unichar str_buf_next_char(mp_lexer_str_buf_t *sb) {
|
||||
STATIC unichar str_buf_next_char(mp_lexer_str_buf_t *sb) {
|
||||
if (sb->src_cur < sb->src_end) {
|
||||
return *sb->src_cur++;
|
||||
} else {
|
||||
@@ -21,7 +21,7 @@ static unichar str_buf_next_char(mp_lexer_str_buf_t *sb) {
|
||||
}
|
||||
}
|
||||
|
||||
static void str_buf_free(mp_lexer_str_buf_t *sb) {
|
||||
STATIC void str_buf_free(mp_lexer_str_buf_t *sb) {
|
||||
if (sb->free_len > 0) {
|
||||
m_free((char*)sb->src_beg, sb->free_len);
|
||||
}
|
||||
|
||||
+3
-3
@@ -12,9 +12,9 @@
|
||||
#endif
|
||||
|
||||
#if MICROPY_MEM_STATS
|
||||
static int total_bytes_allocated = 0;
|
||||
static int current_bytes_allocated = 0;
|
||||
static int peak_bytes_allocated = 0;
|
||||
STATIC int total_bytes_allocated = 0;
|
||||
STATIC int current_bytes_allocated = 0;
|
||||
STATIC int peak_bytes_allocated = 0;
|
||||
|
||||
#define UPDATE_PEAK() { if (current_bytes_allocated > peak_bytes_allocated) peak_bytes_allocated = current_bytes_allocated; }
|
||||
#endif
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
// approximatelly doubling primes; made with Mathematica command: Table[Prime[Floor[(1.7)^n]], {n, 3, 24}]
|
||||
// prefixed with zero for the empty case.
|
||||
static int doubling_primes[] = {0, 7, 19, 43, 89, 179, 347, 647, 1229, 2297, 4243, 7829, 14347, 26017, 47149, 84947, 152443, 273253, 488399, 869927, 1547173, 2745121, 4861607};
|
||||
STATIC int doubling_primes[] = {0, 7, 19, 43, 89, 179, 347, 647, 1229, 2297, 4243, 7829, 14347, 26017, 47149, 84947, 152443, 273253, 488399, 869927, 1547173, 2745121, 4861607};
|
||||
|
||||
int get_doubling_prime_greater_or_equal_to(int x) {
|
||||
for (int i = 0; i < sizeof(doubling_primes) / sizeof(int); i++) {
|
||||
@@ -78,7 +78,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) {
|
||||
int old_alloc = map->alloc;
|
||||
mp_map_elem_t *old_table = map->table;
|
||||
map->alloc = get_doubling_prime_greater_or_equal_to(map->alloc + 1);
|
||||
@@ -175,7 +175,7 @@ void mp_set_init(mp_set_t *set, int 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) {
|
||||
int old_alloc = set->alloc;
|
||||
mp_obj_t *old_table = set->table;
|
||||
set->alloc = get_doubling_prime_greater_or_equal_to(set->alloc + 1);
|
||||
|
||||
+10
-10
@@ -74,7 +74,7 @@ enum {
|
||||
#undef one_or_more
|
||||
#undef DEF_RULE
|
||||
|
||||
static const rule_t *rules[] = {
|
||||
STATIC const rule_t *rules[] = {
|
||||
NULL,
|
||||
#define DEF_RULE(rule, comp, kind, ...) &rule_##rule,
|
||||
#include "grammar.h"
|
||||
@@ -99,7 +99,7 @@ typedef struct _parser_t {
|
||||
mp_lexer_t *lexer;
|
||||
} parser_t;
|
||||
|
||||
static void push_rule(parser_t *parser, int src_line, const rule_t *rule, int arg_i) {
|
||||
STATIC void push_rule(parser_t *parser, int src_line, const rule_t *rule, int arg_i) {
|
||||
if (parser->rule_stack_top >= parser->rule_stack_alloc) {
|
||||
parser->rule_stack = m_renew(rule_stack_t, parser->rule_stack, parser->rule_stack_alloc, parser->rule_stack_alloc * 2);
|
||||
parser->rule_stack_alloc *= 2;
|
||||
@@ -110,14 +110,14 @@ static void push_rule(parser_t *parser, int src_line, const rule_t *rule, int ar
|
||||
rs->arg_i = arg_i;
|
||||
}
|
||||
|
||||
static void push_rule_from_arg(parser_t *parser, uint arg) {
|
||||
STATIC void push_rule_from_arg(parser_t *parser, uint arg) {
|
||||
assert((arg & RULE_ARG_KIND_MASK) == RULE_ARG_RULE || (arg & RULE_ARG_KIND_MASK) == RULE_ARG_OPT_RULE);
|
||||
uint rule_id = arg & RULE_ARG_ARG_MASK;
|
||||
assert(rule_id < RULE_maximum_number_of);
|
||||
push_rule(parser, mp_lexer_cur(parser->lexer)->src_line, rules[rule_id], 0);
|
||||
}
|
||||
|
||||
static void pop_rule(parser_t *parser, const rule_t **rule, uint *arg_i, uint *src_line) {
|
||||
STATIC void pop_rule(parser_t *parser, const rule_t **rule, uint *arg_i, uint *src_line) {
|
||||
parser->rule_stack_top -= 1;
|
||||
*rule = rules[parser->rule_stack[parser->rule_stack_top].rule_id];
|
||||
*arg_i = parser->rule_stack[parser->rule_stack_top].arg_i;
|
||||
@@ -199,7 +199,7 @@ void mp_parse_node_print(mp_parse_node_t pn, int indent) {
|
||||
#endif // MICROPY_DEBUG_PRINTERS
|
||||
|
||||
/*
|
||||
static void result_stack_show(parser_t *parser) {
|
||||
STATIC void result_stack_show(parser_t *parser) {
|
||||
printf("result stack, most recent first\n");
|
||||
for (int i = parser->result_stack_top - 1; i >= 0; i--) {
|
||||
mp_parse_node_print(parser->result_stack[i], 0);
|
||||
@@ -207,17 +207,17 @@ static void result_stack_show(parser_t *parser) {
|
||||
}
|
||||
*/
|
||||
|
||||
static mp_parse_node_t pop_result(parser_t *parser) {
|
||||
STATIC mp_parse_node_t pop_result(parser_t *parser) {
|
||||
assert(parser->result_stack_top > 0);
|
||||
return parser->result_stack[--parser->result_stack_top];
|
||||
}
|
||||
|
||||
static mp_parse_node_t peek_result(parser_t *parser, int pos) {
|
||||
STATIC mp_parse_node_t peek_result(parser_t *parser, int pos) {
|
||||
assert(parser->result_stack_top > pos);
|
||||
return parser->result_stack[parser->result_stack_top - 1 - pos];
|
||||
}
|
||||
|
||||
static void push_result_node(parser_t *parser, mp_parse_node_t pn) {
|
||||
STATIC void push_result_node(parser_t *parser, mp_parse_node_t pn) {
|
||||
if (parser->result_stack_top >= parser->result_stack_alloc) {
|
||||
parser->result_stack = m_renew(mp_parse_node_t, parser->result_stack, parser->result_stack_alloc, parser->result_stack_alloc * 2);
|
||||
parser->result_stack_alloc *= 2;
|
||||
@@ -225,7 +225,7 @@ static void push_result_node(parser_t *parser, mp_parse_node_t pn) {
|
||||
parser->result_stack[parser->result_stack_top++] = pn;
|
||||
}
|
||||
|
||||
static void push_result_token(parser_t *parser, const mp_lexer_t *lex) {
|
||||
STATIC void push_result_token(parser_t *parser, const mp_lexer_t *lex) {
|
||||
const mp_token_t *tok = mp_lexer_cur(lex);
|
||||
mp_parse_node_t pn;
|
||||
if (tok->kind == MP_TOKEN_NAME) {
|
||||
@@ -294,7 +294,7 @@ static void push_result_token(parser_t *parser, const mp_lexer_t *lex) {
|
||||
push_result_node(parser, pn);
|
||||
}
|
||||
|
||||
static void push_result_rule(parser_t *parser, int src_line, const rule_t *rule, int num_args) {
|
||||
STATIC void push_result_rule(parser_t *parser, int src_line, const rule_t *rule, int num_args) {
|
||||
mp_parse_node_struct_t *pn = parse_node_new_struct(src_line, rule->rule_id, num_args);
|
||||
for (int i = num_args; i > 0; i--) {
|
||||
pn->nodes[i - 1] = pop_result(parser);
|
||||
|
||||
@@ -60,13 +60,13 @@ const static qstr_pool_t const_pool = {
|
||||
},
|
||||
};
|
||||
|
||||
static qstr_pool_t *last_pool;
|
||||
STATIC qstr_pool_t *last_pool;
|
||||
|
||||
void qstr_init(void) {
|
||||
last_pool = (qstr_pool_t*)&const_pool; // we won't modify the const_pool since it has no allocated room left
|
||||
}
|
||||
|
||||
static const byte *find_qstr(qstr q) {
|
||||
STATIC const byte *find_qstr(qstr q) {
|
||||
// search pool for this qstr
|
||||
for (qstr_pool_t *pool = last_pool; pool != NULL; pool = pool->prev) {
|
||||
if (q >= pool->total_prev_len) {
|
||||
@@ -78,7 +78,7 @@ static const byte *find_qstr(qstr q) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static qstr qstr_add(const byte *q_ptr) {
|
||||
STATIC qstr qstr_add(const byte *q_ptr) {
|
||||
DEBUG_printf("QSTR: add hash=%d len=%d data=%.*s\n", Q_GET_HASH(q_ptr), Q_GET_LENGTH(q_ptr), Q_GET_LENGTH(q_ptr), Q_GET_DATA(q_ptr));
|
||||
|
||||
// make sure we have room in the pool for a new qstr
|
||||
|
||||
+11
-11
@@ -31,10 +31,10 @@
|
||||
#endif
|
||||
|
||||
// locals and globals need to be pointers because they can be the same in outer module scope
|
||||
static mp_map_t *map_locals;
|
||||
static mp_map_t *map_globals;
|
||||
static mp_map_t map_builtins;
|
||||
static mp_map_t map_loaded_modules; // TODO: expose as sys.modules
|
||||
STATIC mp_map_t *map_locals;
|
||||
STATIC mp_map_t *map_globals;
|
||||
STATIC mp_map_t map_builtins;
|
||||
STATIC mp_map_t map_loaded_modules; // TODO: expose as sys.modules
|
||||
|
||||
typedef enum {
|
||||
MP_CODE_NONE,
|
||||
@@ -66,9 +66,9 @@ typedef struct _mp_code_t {
|
||||
};
|
||||
} mp_code_t;
|
||||
|
||||
static uint next_unique_code_id;
|
||||
static machine_uint_t unique_codes_alloc = 0;
|
||||
static mp_code_t *unique_codes = NULL;
|
||||
STATIC uint next_unique_code_id;
|
||||
STATIC machine_uint_t unique_codes_alloc = 0;
|
||||
STATIC mp_code_t *unique_codes = NULL;
|
||||
|
||||
#ifdef WRITE_CODE
|
||||
FILE *fp_write_code = NULL;
|
||||
@@ -85,7 +85,7 @@ typedef struct _mp_builtin_elem_t {
|
||||
mp_obj_t fun;
|
||||
} mp_builtin_elem_t;
|
||||
|
||||
static const mp_builtin_elem_t builtin_table[] = {
|
||||
STATIC const mp_builtin_elem_t builtin_table[] = {
|
||||
// built-in core functions
|
||||
{ MP_QSTR___build_class__, (mp_obj_t)&mp_builtin___build_class___obj },
|
||||
{ MP_QSTR___import__, (mp_obj_t)&mp_builtin___import___obj },
|
||||
@@ -148,7 +148,7 @@ static const mp_builtin_elem_t builtin_table[] = {
|
||||
};
|
||||
|
||||
// a good optimising compiler will inline this if necessary
|
||||
static void mp_map_add_qstr(mp_map_t *map, qstr qstr, mp_obj_t value) {
|
||||
STATIC void mp_map_add_qstr(mp_map_t *map, qstr qstr, mp_obj_t value) {
|
||||
mp_map_lookup(map, MP_OBJ_NEW_QSTR(qstr), MP_MAP_LOOKUP_ADD_IF_NOT_FOUND)->value = value;
|
||||
}
|
||||
|
||||
@@ -225,7 +225,7 @@ uint rt_get_unique_code_id(void) {
|
||||
return next_unique_code_id++;
|
||||
}
|
||||
|
||||
static void alloc_unique_codes(void) {
|
||||
STATIC void alloc_unique_codes(void) {
|
||||
if (next_unique_code_id > unique_codes_alloc) {
|
||||
DEBUG_printf("allocate more unique codes: " UINT_FMT " -> %u\n", unique_codes_alloc, next_unique_code_id);
|
||||
// increase size of unique_codes table
|
||||
@@ -864,7 +864,7 @@ mp_obj_t rt_load_attr(mp_obj_t base, qstr attr) {
|
||||
// no attribute found, returns: dest[0] == MP_OBJ_NULL, dest[1] == MP_OBJ_NULL
|
||||
// normal attribute found, returns: dest[0] == <attribute>, dest[1] == MP_OBJ_NULL
|
||||
// method attribute found, returns: dest[0] == <method>, dest[1] == <self>
|
||||
static void rt_load_method_maybe(mp_obj_t base, qstr attr, mp_obj_t *dest) {
|
||||
STATIC void rt_load_method_maybe(mp_obj_t base, qstr attr, mp_obj_t *dest) {
|
||||
// clear output to indicate no attribute/method found yet
|
||||
dest[0] = MP_OBJ_NULL;
|
||||
dest[1] = MP_OBJ_NULL;
|
||||
|
||||
+5
-5
@@ -10,9 +10,9 @@
|
||||
// This file defines generic Python stream read/write methods which
|
||||
// dispatch to the underlying stream interface of an object.
|
||||
|
||||
static mp_obj_t stream_readall(mp_obj_t self_in);
|
||||
STATIC mp_obj_t stream_readall(mp_obj_t self_in);
|
||||
|
||||
static mp_obj_t stream_read(uint n_args, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t stream_read(uint n_args, const mp_obj_t *args) {
|
||||
struct _mp_obj_base_t *o = (struct _mp_obj_base_t *)args[0];
|
||||
if (o->type->stream_p.read == NULL) {
|
||||
// CPython: io.UnsupportedOperation, OSError subclass
|
||||
@@ -35,7 +35,7 @@ static mp_obj_t stream_read(uint n_args, const mp_obj_t *args) {
|
||||
}
|
||||
}
|
||||
|
||||
static mp_obj_t stream_write(mp_obj_t self_in, mp_obj_t arg) {
|
||||
STATIC mp_obj_t stream_write(mp_obj_t self_in, mp_obj_t arg) {
|
||||
struct _mp_obj_base_t *o = (struct _mp_obj_base_t *)self_in;
|
||||
if (o->type->stream_p.write == NULL) {
|
||||
// CPython: io.UnsupportedOperation, OSError subclass
|
||||
@@ -58,7 +58,7 @@ static mp_obj_t stream_write(mp_obj_t self_in, mp_obj_t arg) {
|
||||
|
||||
// TODO: should be in mpconfig.h
|
||||
#define READ_SIZE 256
|
||||
static mp_obj_t stream_readall(mp_obj_t self_in) {
|
||||
STATIC mp_obj_t stream_readall(mp_obj_t self_in) {
|
||||
struct _mp_obj_base_t *o = (struct _mp_obj_base_t *)self_in;
|
||||
if (o->type->stream_p.read == NULL) {
|
||||
// CPython: io.UnsupportedOperation, OSError subclass
|
||||
@@ -99,7 +99,7 @@ static mp_obj_t stream_readall(mp_obj_t self_in) {
|
||||
}
|
||||
|
||||
// Unbuffered, inefficient implementation of readline() for raw I/O files.
|
||||
static mp_obj_t stream_unbuffered_readline(uint n_args, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t stream_unbuffered_readline(uint n_args, const mp_obj_t *args) {
|
||||
struct _mp_obj_base_t *o = (struct _mp_obj_base_t *)args[0];
|
||||
if (o->type->stream_p.read == NULL) {
|
||||
// CPython: io.UnsupportedOperation, OSError subclass
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user