@@ -1275,77 +1275,6 @@ _PyLineTable_NextAddressRange(PyCodeAddressRange *range)
12751275 return 1 ;
12761276}
12771277
1278- static int
1279- emit_pair (PyObject * * bytes , int * offset , int a , int b )
1280- {
1281- Py_ssize_t len = PyBytes_GET_SIZE (* bytes );
1282- if (* offset + 2 >= len ) {
1283- if (_PyBytes_Resize (bytes , len * 2 ) < 0 )
1284- return 0 ;
1285- }
1286- unsigned char * lnotab = (unsigned char * ) PyBytes_AS_STRING (* bytes );
1287- lnotab += * offset ;
1288- * lnotab ++ = a ;
1289- * lnotab ++ = b ;
1290- * offset += 2 ;
1291- return 1 ;
1292- }
1293-
1294- static int
1295- emit_delta (PyObject * * bytes , int bdelta , int ldelta , int * offset )
1296- {
1297- while (bdelta > 255 ) {
1298- if (!emit_pair (bytes , offset , 255 , 0 )) {
1299- return 0 ;
1300- }
1301- bdelta -= 255 ;
1302- }
1303- while (ldelta > 127 ) {
1304- if (!emit_pair (bytes , offset , bdelta , 127 )) {
1305- return 0 ;
1306- }
1307- bdelta = 0 ;
1308- ldelta -= 127 ;
1309- }
1310- while (ldelta < -128 ) {
1311- if (!emit_pair (bytes , offset , bdelta , -128 )) {
1312- return 0 ;
1313- }
1314- bdelta = 0 ;
1315- ldelta += 128 ;
1316- }
1317- return emit_pair (bytes , offset , bdelta , ldelta );
1318- }
1319-
1320- static PyObject *
1321- decode_linetable (PyCodeObject * code )
1322- {
1323- PyCodeAddressRange bounds ;
1324- PyObject * bytes ;
1325- int table_offset = 0 ;
1326- int code_offset = 0 ;
1327- int line = code -> co_firstlineno ;
1328- bytes = PyBytes_FromStringAndSize (NULL , 64 );
1329- if (bytes == NULL ) {
1330- return NULL ;
1331- }
1332- _PyCode_InitAddressRange (code , & bounds );
1333- while (_PyLineTable_NextAddressRange (& bounds )) {
1334- if (bounds .opaque .computed_line != line ) {
1335- int bdelta = bounds .ar_start - code_offset ;
1336- int ldelta = bounds .opaque .computed_line - line ;
1337- if (!emit_delta (& bytes , bdelta , ldelta , & table_offset )) {
1338- Py_DECREF (bytes );
1339- return NULL ;
1340- }
1341- code_offset = bounds .ar_start ;
1342- line = bounds .opaque .computed_line ;
1343- }
1344- }
1345- _PyBytes_Resize (& bytes , table_offset );
1346- return bytes ;
1347- }
1348-
13491278
13501279typedef struct {
13511280 PyObject_HEAD
0 commit comments