OLD | NEW |
1 //===- NaClBitstreamReader.cpp --------------------------------------------===// | 1 //===- NaClBitstreamReader.cpp --------------------------------------------===// |
2 // NaClBitstreamReader implementation | 2 // NaClBitstreamReader implementation |
3 // | 3 // |
4 // The LLVM Compiler Infrastructure | 4 // The LLVM Compiler Infrastructure |
5 // | 5 // |
6 // This file is distributed under the University of Illinois Open Source | 6 // This file is distributed under the University of Illinois Open Source |
7 // License. See LICENSE.TXT for details. | 7 // License. See LICENSE.TXT for details. |
8 // | 8 // |
9 //===----------------------------------------------------------------------===// | 9 //===----------------------------------------------------------------------===// |
10 | 10 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 // Add the abbrevs specific to this block to the CurAbbrevs list. | 64 // Add the abbrevs specific to this block to the CurAbbrevs list. |
65 if (const NaClBitstreamReader::BlockInfo *Info = | 65 if (const NaClBitstreamReader::BlockInfo *Info = |
66 BitStream->getBlockInfo(BlockID)) { | 66 BitStream->getBlockInfo(BlockID)) { |
67 for (size_t i = 0, e = Info->Abbrevs.size(); i != e; ++i) { | 67 for (size_t i = 0, e = Info->Abbrevs.size(); i != e; ++i) { |
68 CurAbbrevs.push_back(Info->Abbrevs[i]); | 68 CurAbbrevs.push_back(Info->Abbrevs[i]); |
69 CurAbbrevs.back()->addRef(); | 69 CurAbbrevs.back()->addRef(); |
70 } | 70 } |
71 } | 71 } |
72 | 72 |
73 // Get the codesize of this block. | 73 // Get the codesize of this block. |
74 CurCodeSize = ReadVBR(naclbitc::CodeLenWidth); | 74 CurCodeSize.IsFixed = true; |
| 75 CurCodeSize.NumBits = ReadVBR(naclbitc::CodeLenWidth); |
75 SkipToFourByteBoundary(); | 76 SkipToFourByteBoundary(); |
76 unsigned NumWords = Read(naclbitc::BlockSizeWidth); | 77 unsigned NumWords = Read(naclbitc::BlockSizeWidth); |
77 if (NumWordsP) *NumWordsP = NumWords; | 78 if (NumWordsP) *NumWordsP = NumWords; |
78 | 79 |
79 // Validate that this block is sane. | 80 // Validate that this block is sane. |
80 if (CurCodeSize == 0 || AtEndOfStream()) | 81 if (CurCodeSize.NumBits == 0 || AtEndOfStream()) |
81 return true; | 82 return true; |
82 | 83 |
83 return false; | 84 return false; |
84 } | 85 } |
85 | 86 |
86 void NaClBitstreamCursor::readAbbreviatedLiteral( | 87 void NaClBitstreamCursor::readAbbreviatedLiteral( |
87 const NaClBitCodeAbbrevOp &Op, | 88 const NaClBitCodeAbbrevOp &Op, |
88 SmallVectorImpl<uint64_t> &Vals) { | 89 SmallVectorImpl<uint64_t> &Vals) { |
89 assert(Op.isLiteral() && "Not a literal"); | 90 assert(Op.isLiteral() && "Not a literal"); |
90 // If the abbrev specifies the literal value to use, use it. | 91 // If the abbrev specifies the literal value to use, use it. |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 std::string Name; | 365 std::string Name; |
365 for (unsigned i = 1, e = Record.size(); i != e; ++i) | 366 for (unsigned i = 1, e = Record.size(); i != e; ++i) |
366 Name += (char)Record[i]; | 367 Name += (char)Record[i]; |
367 CurBlockInfo->RecordNames.push_back(std::make_pair((unsigned)Record[0], | 368 CurBlockInfo->RecordNames.push_back(std::make_pair((unsigned)Record[0], |
368 Name)); | 369 Name)); |
369 break; | 370 break; |
370 } | 371 } |
371 } | 372 } |
372 } | 373 } |
373 } | 374 } |
OLD | NEW |