[python] upgrade to micropython 1.12

This commit is contained in:
Émilie Feral
2020-04-06 14:57:17 +02:00
committed by LeaNumworks
parent 010fb1894f
commit 7df8c2935a
83 changed files with 3516 additions and 1284 deletions

View File

@@ -83,17 +83,10 @@ const mp_uint_t *mp_showbc_const_table;
void mp_bytecode_print(const void *descr, const byte *ip, mp_uint_t len, const mp_uint_t *const_table) {
mp_showbc_code_start = ip;
// get bytecode parameters
mp_uint_t n_state = mp_decode_uint(&ip);
mp_uint_t n_exc_stack = mp_decode_uint(&ip);
/*mp_uint_t scope_flags =*/ ip++;
mp_uint_t n_pos_args = *ip++;
mp_uint_t n_kwonly_args = *ip++;
/*mp_uint_t n_def_pos_args =*/ ip++;
// Decode prelude
MP_BC_PRELUDE_SIG_DECODE(ip);
MP_BC_PRELUDE_SIZE_DECODE(ip);
const byte *code_info = ip;
mp_uint_t code_info_size = mp_decode_uint(&code_info);
ip += code_info_size;
#if MICROPY_PERSISTENT_CODE
qstr block_name = code_info[0] | (code_info[1] << 8);
@@ -107,7 +100,9 @@ void mp_bytecode_print(const void *descr, const byte *ip, mp_uint_t len, const m
qstr_str(source_file), qstr_str(block_name), descr, mp_showbc_code_start, len);
// raw bytecode dump
printf("Raw bytecode (code_info_size=" UINT_FMT ", bytecode_size=" UINT_FMT "):\n", code_info_size, len - code_info_size);
size_t prelude_size = ip - mp_showbc_code_start + n_info + n_cell;
printf("Raw bytecode (code_info_size=" UINT_FMT ", bytecode_size=" UINT_FMT "):\n",
prelude_size, len - prelude_size);
for (mp_uint_t i = 0; i < len; i++) {
if (i > 0 && i % 16 == 0) {
printf("\n");
@@ -123,24 +118,21 @@ void mp_bytecode_print(const void *descr, const byte *ip, mp_uint_t len, const m
}
printf("\n");
printf("(N_STATE " UINT_FMT ")\n", n_state);
printf("(N_EXC_STACK " UINT_FMT ")\n", n_exc_stack);
printf("(N_STATE %u)\n", (unsigned)n_state);
printf("(N_EXC_STACK %u)\n", (unsigned)n_exc_stack);
// for printing line number info
const byte *bytecode_start = ip;
// skip over code_info
ip += n_info;
// bytecode prelude: initialise closed over variables
{
uint local_num;
while ((local_num = *ip++) != 255) {
printf("(INIT_CELL %u)\n", local_num);
}
len -= ip - mp_showbc_code_start;
for (size_t i = 0; i < n_cell; ++i) {
uint local_num = *ip++;
printf("(INIT_CELL %u)\n", local_num);
}
// print out line number info
{
mp_int_t bc = bytecode_start - ip;
mp_int_t bc = 0;
mp_uint_t source_line = 1;
printf(" bc=" INT_FMT " line=" UINT_FMT "\n", bc, source_line);
for (const byte* ci = code_info; *ci;) {
@@ -158,7 +150,7 @@ void mp_bytecode_print(const void *descr, const byte *ip, mp_uint_t len, const m
printf(" bc=" INT_FMT " line=" UINT_FMT "\n", bc, source_line);
}
}
mp_bytecode_print2(ip, len - 0, const_table);
mp_bytecode_print2(ip, len - prelude_size, const_table);
}
const byte *mp_bytecode_print_str(const byte *ip) {
@@ -500,9 +492,16 @@ const byte *mp_bytecode_print_str(const byte *ip) {
printf("RETURN_VALUE");
break;
case MP_BC_RAISE_VARARGS:
unum = *ip++;
printf("RAISE_VARARGS " UINT_FMT, unum);
case MP_BC_RAISE_LAST:
printf("RAISE_LAST");
break;
case MP_BC_RAISE_OBJ:
printf("RAISE_OBJ");
break;
case MP_BC_RAISE_FROM:
printf("RAISE_FROM");
break;
case MP_BC_YIELD_VALUE:
@@ -540,7 +539,7 @@ const byte *mp_bytecode_print_str(const byte *ip) {
mp_uint_t op = ip[-1] - MP_BC_BINARY_OP_MULTI;
printf("BINARY_OP " UINT_FMT " %s", op, qstr_str(mp_binary_op_method_name[op]));
} else {
printf("code %p, byte code 0x%02x not implemented\n", ip, ip[-1]);
printf("code %p, byte code 0x%02x not implemented\n", ip - 1, ip[-1]);
assert(0);
return ip;
}