Changes in directory llvm/include/llvm/Bitcode:
BitstreamReader.h updated: 1.9 -> 1.10 --- Log message: add JumpToBit, an explicit init method, and a default ctor. --- Diffs of the changes: (+28 -2) BitstreamReader.h | 30 ++++++++++++++++++++++++++++-- 1 files changed, 28 insertions(+), 2 deletions(-) Index: llvm/include/llvm/Bitcode/BitstreamReader.h diff -u llvm/include/llvm/Bitcode/BitstreamReader.h:1.9 llvm/include/llvm/Bitcode/BitstreamReader.h:1.10 --- llvm/include/llvm/Bitcode/BitstreamReader.h:1.9 Sun Apr 29 16:49:05 2007 +++ llvm/include/llvm/Bitcode/BitstreamReader.h Mon Apr 30 23:59:06 2007 @@ -51,8 +51,20 @@ /// FirstChar - This remembers the first byte of the stream. const unsigned char *FirstChar; public: - BitstreamReader(const unsigned char *Start, const unsigned char *End) - : NextChar(Start), LastChar(End), FirstChar(Start) { + BitstreamReader() { + NextChar = FirstChar = LastChar = 0; + CurWord = 0; + BitsInCurWord = 0; + CurCodeSize = 0; + } + + BitstreamReader(const unsigned char *Start, const unsigned char *End) { + init(Start, End); + } + + void init(const unsigned char *Start, const unsigned char *End) { + NextChar = FirstChar = Start; + LastChar = End; assert(((End-Start) & 3) == 0 &&"Bitcode stream not a multiple of 4 bytes"); CurWord = 0; BitsInCurWord = 0; @@ -79,6 +91,20 @@ return (NextChar-FirstChar)*8 + (32-BitsInCurWord); } + /// JumpToBit - Reset the stream to the specified bit number. + void JumpToBit(uint64_t BitNo) { + unsigned WordNo = BitNo/32; + unsigned WordBitNo = BitNo & 31; + assert(WordNo < (unsigned)(LastChar-FirstChar) && "Invalid location"); + + // Move the cursor to the right word. + NextChar = FirstChar+WordNo; + BitsInCurWord = 0; + + // Skip over any bits that are already consumed. + if (WordBitNo) Read(WordBitNo); + } + /// GetAbbrevIDWidth - Return the number of bits used to encode an abbrev #. unsigned GetAbbrevIDWidth() const { return CurCodeSize; } _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits