1 //==- Serialize.h - Generic Object Serialization to 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 serialization to
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_BITCODE_SERIALIZE_OUTPUT
16 #define LLVM_BITCODE_SERIALIZE_OUTPUT
18 #include "llvm/Bitcode/Serialization.h"
19 #include "llvm/Bitcode/BitstreamWriter.h"
20 #include "llvm/ADT/SmallVector.h"
25 BitstreamWriter& Stream;
26 SmallVector<uint64_t,10> Record;
29 Serializer(BitstreamWriter& stream, unsigned BlockID = 0);
33 inline void Emit(const T& X) { SerializeTrait<T>::Emit(*this,X); }
35 void EmitInt(unsigned X);
36 void EmitBool(bool X) { EmitInt(X); }
37 void EmitCStr(const char* beg, const char* end);
38 void EmitCStr(const char* cstr);
40 void Flush() { if (inRecord()) EmitRecord(); }
44 inline bool inRecord() { return Record.size() > 0; }
47 } // end namespace llvm