diff options
| author | Anson Mansfield <amansfield@mantaro.com> | 2025-06-26 12:41:44 -0400 |
|---|---|---|
| committer | Anson Mansfield <amansfield@mantaro.com> | 2025-07-08 11:03:22 -0400 |
| commit | 0732c45683fe7fabe61e4ef4eb95011817966372 (patch) | |
| tree | b062ad9736dde1e8b0233e45b360ecfc9f4cdd98 | |
| parent | 00fe312f83a9fd5816f8034c7f7ee591325d15d9 (diff) | |
py/showbc: Use line-number decoding helper.
Signed-off-by: Anson Mansfield <amansfield@mantaro.com>
| -rw-r--r-- | py/showbc.c | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/py/showbc.c b/py/showbc.c index 6913d18c1..792fccd01 100644 --- a/py/showbc.c +++ b/py/showbc.c @@ -144,17 +144,9 @@ void mp_bytecode_print(const mp_print_t *print, const mp_raw_code_t *rc, size_t mp_uint_t source_line = 1; mp_printf(print, " bc=" INT_FMT " line=" UINT_FMT "\n", bc, source_line); for (const byte *ci = code_info; ci < line_info_top;) { - if ((ci[0] & 0x80) == 0) { - // 0b0LLBBBBB encoding - bc += ci[0] & 0x1f; - source_line += ci[0] >> 5; - ci += 1; - } else { - // 0b1LLLBBBB 0bLLLLLLLL encoding (l's LSB in second byte) - bc += ci[0] & 0xf; - source_line += ((ci[0] << 4) & 0x700) | ci[1]; - ci += 2; - } + mp_code_lineinfo_t decoded = mp_bytecode_decode_lineinfo(&ci); + bc += decoded.bc_increment; + source_line += decoded.line_increment; mp_printf(print, " bc=" INT_FMT " line=" UINT_FMT "\n", bc, source_line); } } |
