Split Serialization.h into separate headers: Serialize.h and

Deserialize.h Serialization.h now includes trait speciailizations for
unsigned long, etc.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43307 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Ted Kremenek
2007-10-24 19:06:40 +00:00
parent be3e348c7c
commit 6e9b496643
5 changed files with 186 additions and 127 deletions

View File

@ -0,0 +1,48 @@
//==- Serialize.h - Generic Object Serialization to Bitcode -------*- C++ -*-=//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by Ted Kremenek and is distributed under the
// University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file defines the interface for generic object serialization to
// LLVM bitcode.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_BITCODE_SERIALIZE_OUTPUT
#define LLVM_BITCODE_SERIALIZE_OUTPUT
#include "llvm/Bitcode/Serialization.h"
#include "llvm/Bitcode/BitstreamWriter.h"
#include "llvm/ADT/SmallVector.h"
namespace llvm {
class Serializer {
BitstreamWriter& Stream;
SmallVector<uint64_t,10> Record;
bool inBlock;
public:
Serializer(BitstreamWriter& stream, unsigned BlockID = 0);
~Serializer();
template <typename T>
inline void Emit(const T& X) { SerializeTrait<T>::Emit(*this,X); }
void EmitInt(unsigned X);
void EmitBool(bool X) { EmitInt(X); }
void EmitCStr(const char* beg, const char* end);
void EmitCStr(const char* cstr);
void Flush() { if (inRecord()) EmitRecord(); }
private:
void EmitRecord();
inline bool inRecord() { return Record.size() > 0; }
};
} // end namespace llvm
#endif