information matching did not exactly match the underlying stream's scoping
information.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44470
91177308-0d34-0410-b5e6-
96231b3b80d8
llvm::SmallVector<Location,8> BlockStack;
unsigned AbbrevNo;
unsigned RecordCode;
llvm::SmallVector<Location,8> BlockStack;
unsigned AbbrevNo;
unsigned RecordCode;
//===----------------------------------------------------------===//
// Public Interface.
//===----------------------------------------------------------===//
// Public Interface.
bool FinishedBlock(Location BlockLoc);
bool JumpTo(const Location& BlockLoc);
bool FinishedBlock(Location BlockLoc);
bool JumpTo(const Location& BlockLoc);
- void Rewind() { JumpTo(StreamStart); }
bool AtEnd();
bool inRecord();
bool AtEnd();
bool inRecord();
Deserializer::Deserializer(BitstreamReader& stream)
: Stream(stream), RecIdx(0), FreeList(NULL), AbbrevNo(0), RecordCode(0) {
Deserializer::Deserializer(BitstreamReader& stream)
: Stream(stream), RecIdx(0), FreeList(NULL), AbbrevNo(0), RecordCode(0) {
-
- AdvanceStream();
- if (!AtEnd()) StreamStart = BlockStack.back();
+
+ StreamStart = Stream.GetCurrentBitNo();
}
Deserializer::~Deserializer() {
}
Deserializer::~Deserializer() {
-// assert (AbbrevNo == bitc::ENTER_SUBBLOCK);
assert (!BlockStack.empty() || AtEnd());
assert (!BlockStack.empty() || AtEnd());
- uint64_t LastBPos = StreamStart.BitNo;
+ uint64_t LastBPos = StreamStart;
while (!BlockStack.empty()) {
while (!BlockStack.empty()) {
// destroy any accumulated context within the block scope. We then
// jump to the position of the block and enter it.
Stream.JumpToBit(LastBPos);
// destroy any accumulated context within the block scope. We then
// jump to the position of the block and enter it.
Stream.JumpToBit(LastBPos);
+
+ if (BlockStack.size() == Stream.BlockScope.size())
+ Stream.PopBlockScope();
+
- Stream.PopBlockScope();
AbbrevNo = 0;
AdvanceStream();
AbbrevNo = 0;
AdvanceStream();
}
// This block does not contain the block we are looking for. Pop it.
}
// This block does not contain the block we are looking for. Pop it.
+ if (BlockStack.size() == Stream.BlockScope.size())
+ Stream.PopBlockScope();
+
- Stream.PopBlockScope();
}
// Check if we have popped our way to the outermost scope. If so,
// we need to adjust our position.
if (BlockStack.empty()) {
}
// Check if we have popped our way to the outermost scope. If so,
// we need to adjust our position.
if (BlockStack.empty()) {
- Stream.JumpToBit(Loc.BitNo < LastBPos ? StreamStart.BitNo : LastBPos);
+ assert (Stream.BlockScope.empty());
+
+ Stream.JumpToBit(Loc.BitNo < LastBPos ? StreamStart : LastBPos);
AbbrevNo = 0;
AdvanceStream();
}
AbbrevNo = 0;
AdvanceStream();
}
+void Deserializer::Rewind() {
+ while (!Stream.BlockScope.empty())
+ Stream.PopBlockScope();
+
+ while (!BlockStack.empty())
+ BlockStack.pop_back();
+
+ Stream.JumpToBit(StreamStart);
+ AbbrevNo = 0;
+}
+
+
unsigned Deserializer::getCurrentBlockID() {
if (!inRecord())
AdvanceStream();
unsigned Deserializer::getCurrentBlockID() {
if (!inRecord())
AdvanceStream();