Chromium Code Reviews| Index: include/llvm/Bitcode/NaCl/NaClBitstreamReader.h |
| diff --git a/include/llvm/Bitcode/BitstreamReader.h b/include/llvm/Bitcode/NaCl/NaClBitstreamReader.h |
| similarity index 83% |
| copy from include/llvm/Bitcode/BitstreamReader.h |
| copy to include/llvm/Bitcode/NaCl/NaClBitstreamReader.h |
| index 2d2976cde13ca867b8a1344c25979a0569203ffa..dba7f7b3ce517107705cf7dc26dc6e9bfdda5f14 100644 |
| --- a/include/llvm/Bitcode/BitstreamReader.h |
| +++ b/include/llvm/Bitcode/NaCl/NaClBitstreamReader.h |
| @@ -1,4 +1,5 @@ |
| -//===- BitstreamReader.h - Low-level bitstream reader interface -*- C++ -*-===// |
| +//===- NaClBitstreamReader.h -----------------------------------*- C++ -*-===// |
| +// Low-level bitstream reader interface |
| // |
| // The LLVM Compiler Infrastructure |
| // |
| @@ -12,11 +13,11 @@ |
| // |
| //===----------------------------------------------------------------------===// |
| -#ifndef LLVM_BITCODE_BITSTREAMREADER_H |
| -#define LLVM_BITCODE_BITSTREAMREADER_H |
| +#ifndef LLVM_BITCODE_NACL_NACLBITSTREAMREADER_H |
| +#define LLVM_BITCODE_NACL_NACLBITSTREAMREADER_H |
| #include "llvm/ADT/OwningPtr.h" |
| -#include "llvm/Bitcode/BitCodes.h" |
| +#include "llvm/Bitcode/NaCl/NaClBitCodes.h" |
| #include "llvm/Support/Endian.h" |
| #include "llvm/Support/StreamableMemoryObject.h" |
| #include <climits> |
| @@ -27,12 +28,12 @@ namespace llvm { |
| class Deserializer; |
| -/// BitstreamReader - This class is used to read from an LLVM bitcode stream, |
| -/// maintaining information that is global to decoding the entire file. While |
| -/// a file is being read, multiple cursors can be independently advanced or |
| -/// skipped around within the file. These are represented by the |
| -/// BitstreamCursor class. |
| -class BitstreamReader { |
| +/// NaClBitstreamReader - This class is used to read from an NaCl |
|
jvoung (off chromium)
2013/04/29 21:49:34
an NaCl -> a NaCl
Karl
2013/05/01 16:23:23
Done.
|
| +/// bitcode wire format stream, maintaining information that is global |
| +/// to decoding the entire file. While a file is being read, multiple |
| +/// cursors can be independently advanced or skipped around within the |
| +/// file. These are represented by the NaClBitstreamCursor class. |
| +class NaClBitstreamReader { |
| public: |
| /// BlockInfo - This contains information emitted to BLOCKINFO_BLOCK blocks. |
| /// These describe abbreviations that all blocks of the specified ID inherit. |
| @@ -53,18 +54,18 @@ private: |
| /// uses this. |
| bool IgnoreBlockInfoNames; |
| - BitstreamReader(const BitstreamReader&) LLVM_DELETED_FUNCTION; |
| - void operator=(const BitstreamReader&) LLVM_DELETED_FUNCTION; |
| + NaClBitstreamReader(const NaClBitstreamReader&) LLVM_DELETED_FUNCTION; |
| + void operator=(const NaClBitstreamReader&) LLVM_DELETED_FUNCTION; |
| public: |
| - BitstreamReader() : IgnoreBlockInfoNames(true) { |
| + NaClBitstreamReader() : IgnoreBlockInfoNames(true) { |
| } |
| - BitstreamReader(const unsigned char *Start, const unsigned char *End) { |
| + NaClBitstreamReader(const unsigned char *Start, const unsigned char *End) { |
| IgnoreBlockInfoNames = true; |
| init(Start, End); |
| } |
| - BitstreamReader(StreamableMemoryObject *bytes) { |
| + NaClBitstreamReader(StreamableMemoryObject *bytes) { |
| BitcodeBytes.reset(bytes); |
| } |
| @@ -75,7 +76,7 @@ public: |
| StreamableMemoryObject &getBitcodeBytes() { return *BitcodeBytes; } |
| - ~BitstreamReader() { |
| + ~NaClBitstreamReader() { |
| // Free the BlockInfoRecords. |
| while (!BlockInfoRecords.empty()) { |
| BlockInfo &Info = BlockInfoRecords.back(); |
| @@ -127,15 +128,15 @@ public: |
| }; |
| -/// BitstreamEntry - When advancing through a bitstream cursor, each advance can |
| -/// discover a few different kinds of entries: |
| +/// NaClBitstreamEntry - When advancing through a bitstream cursor, |
| +/// each advance can discover a few different kinds of entries: |
| /// Error - Malformed bitcode was found. |
| /// EndBlock - We've reached the end of the current block, (or the end of the |
| /// file, which is treated like a series of EndBlock records. |
| /// SubBlock - This is the start of a new subblock of a specific ID. |
| /// Record - This is a record with a specific AbbrevID. |
| /// |
| -struct BitstreamEntry { |
| +struct NaClBitstreamEntry { |
| enum { |
| Error, |
| EndBlock, |
| @@ -145,29 +146,29 @@ struct BitstreamEntry { |
| unsigned ID; |
| - static BitstreamEntry getError() { |
| - BitstreamEntry E; E.Kind = Error; return E; |
| + static NaClBitstreamEntry getError() { |
| + NaClBitstreamEntry E; E.Kind = Error; return E; |
| } |
| - static BitstreamEntry getEndBlock() { |
| - BitstreamEntry E; E.Kind = EndBlock; return E; |
| + static NaClBitstreamEntry getEndBlock() { |
| + NaClBitstreamEntry E; E.Kind = EndBlock; return E; |
| } |
| - static BitstreamEntry getSubBlock(unsigned ID) { |
| - BitstreamEntry E; E.Kind = SubBlock; E.ID = ID; return E; |
| + static NaClBitstreamEntry getSubBlock(unsigned ID) { |
| + NaClBitstreamEntry E; E.Kind = SubBlock; E.ID = ID; return E; |
| } |
| - static BitstreamEntry getRecord(unsigned AbbrevID) { |
| - BitstreamEntry E; E.Kind = Record; E.ID = AbbrevID; return E; |
| + static NaClBitstreamEntry getRecord(unsigned AbbrevID) { |
| + NaClBitstreamEntry E; E.Kind = Record; E.ID = AbbrevID; return E; |
| } |
| }; |
| -/// BitstreamCursor - This represents a position within a bitcode file. There |
| -/// may be multiple independent cursors reading within one bitstream, each |
| -/// maintaining their own local state. |
| +/// NaClBitstreamCursor - This represents a position within a bitcode |
| +/// file. There may be multiple independent cursors reading within |
| +/// one bitstream, each maintaining their own local state. |
| /// |
| -/// Unlike iterators, BitstreamCursors are heavy-weight objects that should not |
| -/// be passed by value. |
| -class BitstreamCursor { |
| +/// Unlike iterators, NaClBitstreamCursors are heavy-weight objects |
| +/// that should not be passed by value. |
| +class NaClBitstreamCursor { |
| friend class Deserializer; |
| - BitstreamReader *BitStream; |
| + NaClBitstreamReader *BitStream; |
| size_t NextChar; |
| @@ -201,20 +202,21 @@ class BitstreamCursor { |
| public: |
| - BitstreamCursor() : BitStream(0), NextChar(0) { |
| + NaClBitstreamCursor() : BitStream(0), NextChar(0) { |
| } |
| - BitstreamCursor(const BitstreamCursor &RHS) : BitStream(0), NextChar(0) { |
| + NaClBitstreamCursor(const NaClBitstreamCursor &RHS) |
| + : BitStream(0), NextChar(0) { |
| operator=(RHS); |
| } |
| - explicit BitstreamCursor(BitstreamReader &R) : BitStream(&R) { |
| + explicit NaClBitstreamCursor(NaClBitstreamReader &R) : BitStream(&R) { |
| NextChar = 0; |
| CurWord = 0; |
| BitsInCurWord = 0; |
| CurCodeSize = 2; |
| } |
| - void init(BitstreamReader &R) { |
| + void init(NaClBitstreamReader &R) { |
| freeState(); |
| BitStream = &R; |
| @@ -224,11 +226,11 @@ public: |
| CurCodeSize = 2; |
| } |
| - ~BitstreamCursor() { |
| + ~NaClBitstreamCursor() { |
| freeState(); |
| } |
| - void operator=(const BitstreamCursor &RHS); |
| + void operator=(const NaClBitstreamCursor &RHS); |
| void freeState(); |
| @@ -260,10 +262,10 @@ public: |
| return NextChar*CHAR_BIT - BitsInCurWord; |
| } |
| - BitstreamReader *getBitStreamReader() { |
| + NaClBitstreamReader *getBitStreamReader() { |
| return BitStream; |
| } |
| - const BitstreamReader *getBitStreamReader() const { |
| + const NaClBitstreamReader *getBitStreamReader() const { |
| return BitStream; |
| } |
| @@ -281,18 +283,18 @@ public: |
| /// advance - Advance the current bitstream, returning the next entry in the |
| /// stream. |
| - BitstreamEntry advance(unsigned Flags = 0) { |
| + NaClBitstreamEntry advance(unsigned Flags = 0) { |
| while (1) { |
| unsigned Code = ReadCode(); |
| if (Code == bitc::END_BLOCK) { |
| // Pop the end of the block unless Flags tells us not to. |
| if (!(Flags & AF_DontPopBlockAtEnd) && ReadBlockEnd()) |
| - return BitstreamEntry::getError(); |
| - return BitstreamEntry::getEndBlock(); |
| + return NaClBitstreamEntry::getError(); |
| + return NaClBitstreamEntry::getEndBlock(); |
| } |
| if (Code == bitc::ENTER_SUBBLOCK) |
| - return BitstreamEntry::getSubBlock(ReadSubBlockID()); |
| + return NaClBitstreamEntry::getSubBlock(ReadSubBlockID()); |
| if (Code == bitc::DEFINE_ABBREV && |
| !(Flags & AF_DontAutoprocessAbbrevs)) { |
| @@ -302,22 +304,22 @@ public: |
| continue; |
| } |
| - return BitstreamEntry::getRecord(Code); |
| + return NaClBitstreamEntry::getRecord(Code); |
| } |
| } |
| /// advanceSkippingSubblocks - This is a convenience function for clients that |
| /// don't expect any subblocks. This just skips over them automatically. |
| - BitstreamEntry advanceSkippingSubblocks(unsigned Flags = 0) { |
| + NaClBitstreamEntry advanceSkippingSubblocks(unsigned Flags = 0) { |
| while (1) { |
| // If we found a normal entry, return it. |
| - BitstreamEntry Entry = advance(Flags); |
| - if (Entry.Kind != BitstreamEntry::SubBlock) |
| + NaClBitstreamEntry Entry = advance(Flags); |
| + if (Entry.Kind != NaClBitstreamEntry::SubBlock) |
| return Entry; |
| // If we found a sub-block, just skip over it and check the next entry. |
| if (SkipBlock()) |
| - return BitstreamEntry::getError(); |
| + return NaClBitstreamEntry::getError(); |
| } |
| } |