(self)
Preparse to build line number dictionary.
Preparse to build line number dictionary.
Preparse to build line number dictionary .
def rebuild_line_dict(self):
        """Preparse to build line number dictionary."""
        self.line_numbers, offsets = {}, []
        self.bytecode.seek(0)
        scanline, scanpos, last = 0, 0, 0
        while True:
            # pass \x00
            self.bytecode.read(1)
            scanline = self.lister.detokenise_line_number(self.bytecode)
            if scanline == -1:
                scanline = 65536
                # if detokenise_line_number returns -1, it leaves the stream pointer here:
                # 00 _00_ 00 1A
                break
            self.line_numbers[scanline] = scanpos
            last = scanpos
            self.bytecode.skip_to(tk.END_LINE)
            scanpos = self.bytecode.tell()
            offsets.append(scanpos)
        self.line_numbers[65536] = scanpos
        # rebuild offsets
        if self._rebuild_offsets:
            self.bytecode.seek(0)
            last = 0
            for pos in offsets:
                self.bytecode.read(1)
                self.bytecode.write(struct.pack('<H', self.code_start + 1 + pos))
                self.bytecode.read(pos - last - 3)
                last = pos
            # ensure program is properly sealed - last offset must be 00 00.
            # keep, but ignore, anything after.
            self.bytecode.write(b'\0\0\0')
def rebuild_line_dict ( self ) : self . line_numbers , offsets = { } , [ ] self . bytecode . seek ( 0 ) scanline , scanpos , last = 0 , 0 , 0 while True : # pass \x00 self . bytecode . read ( 1 ) scanline = self . lister . detokenise_line_number ( self . bytecode ) if scanline == - 1 : scanline = 65536 # if detokenise_line_number returns -1, it leaves the stream pointer here: # 00 _00_ 00 1A break self . line_numbers [ scanline ] = scanpos last = scanpos self . bytecode . skip_to ( tk . END_LINE ) scanpos = self . bytecode . tell ( ) offsets . append ( scanpos ) self . line_numbers [ 65536 ] = scanpos # rebuild offsets if self . _rebuild_offsets : self . bytecode . seek ( 0 ) last = 0 for pos in offsets : self . bytecode . read ( 1 ) self . bytecode . write ( struct . pack ( '<H' , self . code_start + 1 + pos ) ) self . bytecode . read ( pos - last - 3 ) last = pos # ensure program is properly sealed - last offset must be 00 00. # keep, but ignore, anything after. self . bytecode . write ( b'\0\0\0' )