mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-27 16:17:17 +00:00
Added typedef "SerializedPtrID" to represent the pointer handle written to disk
instead of just using "unsigned". This gives us more flexibility in changing the definition of the handle later, and is more self-documenting. Added tracking of block stack in the Deserializer. Now clients can query if they are still within a block using the methods GetCurrentBlockLocation() and FinishedBlock(). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43903 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -14,6 +14,10 @@
|
||||
#include "llvm/Bitcode/Serialize.h"
|
||||
#include "string.h"
|
||||
|
||||
#ifdef DEBUG_BACKPATCH
|
||||
#include "llvm/Support/Streams.h"
|
||||
#endif
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
Serializer::Serializer(BitstreamWriter& stream)
|
||||
@@ -67,15 +71,13 @@ void Serializer::EmitCStr(const char* s, const char* end) {
|
||||
Record.push_back(*s);
|
||||
++s;
|
||||
}
|
||||
|
||||
EmitRecord();
|
||||
}
|
||||
|
||||
void Serializer::EmitCStr(const char* s) {
|
||||
EmitCStr(s,s+strlen(s));
|
||||
}
|
||||
|
||||
unsigned Serializer::getPtrId(const void* ptr) {
|
||||
SerializedPtrID Serializer::getPtrId(const void* ptr) {
|
||||
if (!ptr)
|
||||
return 0;
|
||||
|
||||
@@ -83,12 +85,20 @@ unsigned Serializer::getPtrId(const void* ptr) {
|
||||
|
||||
if (I == PtrMap.end()) {
|
||||
unsigned id = PtrMap.size()+1;
|
||||
#ifdef DEBUG_BACKPATCH
|
||||
llvm::cerr << "Registered PTR: " << ptr << " => " << id << "\n";
|
||||
#endif
|
||||
PtrMap[ptr] = id;
|
||||
return id;
|
||||
}
|
||||
else return I->second;
|
||||
}
|
||||
|
||||
bool Serializer::isRegistered(const void* ptr) const {
|
||||
MapTy::const_iterator I = PtrMap.find(ptr);
|
||||
return I != PtrMap.end();
|
||||
}
|
||||
|
||||
|
||||
#define INT_EMIT(TYPE)\
|
||||
void SerializeTrait<TYPE>::Emit(Serializer&S, TYPE X) { S.EmitInt(X); }
|
||||
|
Reference in New Issue
Block a user