Skip to content

Commit 0732c45

Browse files
committed
py/showbc: Use line-number decoding helper.
Signed-off-by: Anson Mansfield <amansfield@mantaro.com>
1 parent 00fe312 commit 0732c45

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

py/showbc.c

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -144,17 +144,9 @@ void mp_bytecode_print(const mp_print_t *print, const mp_raw_code_t *rc, size_t
144144
mp_uint_t source_line = 1;
145145
mp_printf(print, " bc=" INT_FMT " line=" UINT_FMT "\n", bc, source_line);
146146
for (const byte *ci = code_info; ci < line_info_top;) {
147-
if ((ci[0] & 0x80) == 0) {
148-
// 0b0LLBBBBB encoding
149-
bc += ci[0] & 0x1f;
150-
source_line += ci[0] >> 5;
151-
ci += 1;
152-
} else {
153-
// 0b1LLLBBBB 0bLLLLLLLL encoding (l's LSB in second byte)
154-
bc += ci[0] & 0xf;
155-
source_line += ((ci[0] << 4) & 0x700) | ci[1];
156-
ci += 2;
157-
}
147+
mp_code_lineinfo_t decoded = mp_bytecode_decode_lineinfo(&ci);
148+
bc += decoded.bc_increment;
149+
source_line += decoded.line_increment;
158150
mp_printf(print, " bc=" INT_FMT " line=" UINT_FMT "\n", bc, source_line);
159151
}
160152
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy