mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
GH-88116: Use a compact format to represent end line and column offsets. (GH-91666)
* Stores all location info in linetable to conform to PEP 626. * Remove column table from code objects. * Remove end-line table from code objects. * Document new location table format
This commit is contained in:
parent
2a5f171759
commit
944fffee89
20 changed files with 859 additions and 539 deletions
|
@ -378,6 +378,7 @@ marklines(PyCodeObject *code, int len)
|
|||
PyCodeAddressRange bounds;
|
||||
_PyCode_InitAddressRange(code, &bounds);
|
||||
assert (bounds.ar_end == 0);
|
||||
int last_line = -1;
|
||||
|
||||
int *linestarts = PyMem_New(int, len);
|
||||
if (linestarts == NULL) {
|
||||
|
@ -389,7 +390,10 @@ marklines(PyCodeObject *code, int len)
|
|||
|
||||
while (_PyLineTable_NextAddressRange(&bounds)) {
|
||||
assert(bounds.ar_start / (int)sizeof(_Py_CODEUNIT) < len);
|
||||
linestarts[bounds.ar_start / sizeof(_Py_CODEUNIT)] = bounds.ar_line;
|
||||
if (bounds.ar_line != last_line && bounds.ar_line != -1) {
|
||||
linestarts[bounds.ar_start / sizeof(_Py_CODEUNIT)] = bounds.ar_line;
|
||||
last_line = bounds.ar_line;
|
||||
}
|
||||
}
|
||||
return linestarts;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue