mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-17 21:29:20 +00:00
add JumpToBit, an explicit init method, and a default ctor.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36613 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
9dd446c561
commit
90a5c7dbc1
@ -51,8 +51,20 @@ class BitstreamReader {
|
|||||||
/// FirstChar - This remembers the first byte of the stream.
|
/// FirstChar - This remembers the first byte of the stream.
|
||||||
const unsigned char *FirstChar;
|
const unsigned char *FirstChar;
|
||||||
public:
|
public:
|
||||||
BitstreamReader(const unsigned char *Start, const unsigned char *End)
|
BitstreamReader() {
|
||||||
: NextChar(Start), LastChar(End), FirstChar(Start) {
|
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");
|
assert(((End-Start) & 3) == 0 &&"Bitcode stream not a multiple of 4 bytes");
|
||||||
CurWord = 0;
|
CurWord = 0;
|
||||||
BitsInCurWord = 0;
|
BitsInCurWord = 0;
|
||||||
@ -79,6 +91,20 @@ public:
|
|||||||
return (NextChar-FirstChar)*8 + (32-BitsInCurWord);
|
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 #.
|
/// GetAbbrevIDWidth - Return the number of bits used to encode an abbrev #.
|
||||||
unsigned GetAbbrevIDWidth() const { return CurCodeSize; }
|
unsigned GetAbbrevIDWidth() const { return CurCodeSize; }
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user