-//===----------------------------------------------------------------------===//
-/// DISerializer - This class is responsible for casting DebugInfoDesc objects
-/// into GlobalVariables.
-class DISerializer {
-private:
- Module *M; // Definition space module.
- PointerType *StrPtrTy; // A "i8*" type. Created lazily.
- PointerType *EmptyStructPtrTy; // A "{ }*" type. Created lazily.
- std::map<unsigned, StructType *> TagTypes;
- // Types per Tag. Created lazily.
- std::map<DebugInfoDesc *, GlobalVariable *> DescGlobals;
- // Previously defined descriptors.
- std::map<const std::string, Constant *> StringCache;
- // Previously defined strings.
-
-public:
- DISerializer()
- : M(NULL)
- , StrPtrTy(NULL)
- , EmptyStructPtrTy(NULL)
- , TagTypes()
- , DescGlobals()
- , StringCache()
- {}
- ~DISerializer() {}
-
- // Accessors
- Module *getModule() const { return M; };
- void setModule(Module *module) { M = module; }
-
- /// getStrPtrType - Return a "i8*" type.
- ///
- const PointerType *getStrPtrType();
-
- /// getEmptyStructPtrType - Return a "{ }*" type.
- ///
- const PointerType *getEmptyStructPtrType();
-
- /// getTagType - Return the type describing the specified descriptor (via
- /// tag.)
- const StructType *getTagType(DebugInfoDesc *DD);
-
- /// getString - Construct the string as constant string global.
- ///
- Constant *getString(const std::string &String);
-
- /// Serialize - Recursively cast the specified descriptor into a
- /// GlobalVariable so that it can be serialized to a .bc or .ll file.
- GlobalVariable *Serialize(DebugInfoDesc *DD);
-
- /// addDescriptor - Directly connect DD with existing GV.
- void addDescriptor(DebugInfoDesc *DD, GlobalVariable *GV);