1 //=- Deserialize.h - Generic Object Deserialization from Bitcode --*- C++ -*-=//
3 // The LLVM Compiler Infrastructure
5 // This file was developed by Ted Kremenek and is distributed under the
6 // University of Illinois Open Source License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines the interface for generic object deserialization from
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_BITCODE_SERIALIZE_INPUT
16 #define LLVM_BITCODE_SERIALIZE_INPUT
18 #include "llvm/Bitcode/BitstreamReader.h"
19 #include "llvm/Bitcode/Serialization.h"
25 BitstreamReader& Stream;
26 SmallVector<uint64_t,10> Record;
29 Deserializer(BitstreamReader& stream);
33 inline T& Read(T& X) {
34 SerializeTrait<T>::Read(*this,X);
39 inline T* Materialize() {
40 return SerializeTrait<T>::Materialize(*this);
44 bool ReadBool() { return ReadInt() ? true : false; }
46 // FIXME: Substitute a better implementation which calculates the minimum
47 // number of bits needed to serialize the enum.
48 template <typename EnumT>
49 EnumT ReadEnum(unsigned MinVal, unsigned MaxVal) {
50 return static_cast<EnumT>(ReadInt(32));
53 char* ReadCStr(char* cstr = NULL, unsigned MaxLen=0, bool isNullTerm=true);
54 void ReadCStr(std::vector<char>& buff, bool isNullTerm=false);
59 inline bool inRecord() {
60 if (Record.size() > 0) {
61 if (RecIdx >= Record.size()) {
72 } // end namespace llvm