py/showbc: Make sure to set the const_table before printing bytecode.

This commit is contained in:
Damien George
2017-01-27 12:34:09 +11:00
parent 4614403f63
commit cc4c1adf6e
3 changed files with 6 additions and 7 deletions

View File

@@ -82,7 +82,6 @@ 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;
mp_showbc_const_table = const_table;
// get bytecode parameters
mp_uint_t n_state = mp_decode_uint(&ip);
@@ -159,7 +158,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);
mp_bytecode_print2(ip, len - 0, const_table);
}
const byte *mp_bytecode_print_str(const byte *ip) {
@@ -547,8 +546,9 @@ const byte *mp_bytecode_print_str(const byte *ip) {
return ip;
}
void mp_bytecode_print2(const byte *ip, mp_uint_t len) {
void mp_bytecode_print2(const byte *ip, size_t len, const mp_uint_t *const_table) {
mp_showbc_code_start = ip;
mp_showbc_const_table = const_table;
while (ip < len + mp_showbc_code_start) {
printf("%02u ", (uint)(ip - mp_showbc_code_start));
ip = mp_bytecode_print_str(ip);