(code)
| 1311 | return uval >> 1 |
| 1312 | |
| 1313 | def parse_location_table(code): |
| 1314 | line = code.co_firstlineno |
| 1315 | it = iter(code.co_linetable) |
| 1316 | while True: |
| 1317 | try: |
| 1318 | first_byte = read(it) |
| 1319 | except StopIteration: |
| 1320 | return |
| 1321 | code = (first_byte >> 3) & 15 |
| 1322 | length = (first_byte & 7) + 1 |
| 1323 | if code == 15: |
| 1324 | yield (code, length, None, None, None, None) |
| 1325 | elif code == 14: |
| 1326 | line_delta = read_signed_varint(it) |
| 1327 | line += line_delta |
| 1328 | end_line = line + read_varint(it) |
| 1329 | col = read_varint(it) |
| 1330 | if col == 0: |
| 1331 | col = None |
| 1332 | else: |
| 1333 | col -= 1 |
| 1334 | end_col = read_varint(it) |
| 1335 | if end_col == 0: |
| 1336 | end_col = None |
| 1337 | else: |
| 1338 | end_col -= 1 |
| 1339 | yield (code, length, line, end_line, col, end_col) |
| 1340 | elif code == 13: # No column |
| 1341 | line_delta = read_signed_varint(it) |
| 1342 | line += line_delta |
| 1343 | yield (code, length, line, line, None, None) |
| 1344 | elif code in (10, 11, 12): # new line |
| 1345 | line_delta = code - 10 |
| 1346 | line += line_delta |
| 1347 | column = read(it) |
| 1348 | end_column = read(it) |
| 1349 | yield (code, length, line, line, column, end_column) |
| 1350 | else: |
| 1351 | assert (0 <= code < 10) |
| 1352 | second_byte = read(it) |
| 1353 | column = code << 3 | (second_byte >> 4) |
| 1354 | yield (code, length, line, line, column, column + (second_byte & 15)) |
| 1355 | |
| 1356 | def positions_from_location_table(code): |
| 1357 | for _, length, line, end_line, col, end_col in parse_location_table(code): |
no test coverage detected
searching dependent graphs…