Support passing a data pointer to annotation factory methods

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@376 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2001-08-27 05:19:10 +00:00
parent be88fd03e6
commit da8f004cdb
2 changed files with 12 additions and 10 deletions

View File

@ -14,8 +14,8 @@ static unsigned IDCounter = 0; // Unique ID counter
static IDMapType &getIDMap() { static IDMapType TheMap; return TheMap; }
// On demand annotation creation support...
typedef Annotation *(*AnnFactory)(AnnotationID, Annotable *);
typedef map<unsigned, AnnFactory> FactMapType;
typedef Annotation *(*AnnFactory)(AnnotationID, Annotable *, void *);
typedef map<unsigned, pair<AnnFactory,void*> > FactMapType;
static FactMapType &getFactMap() { static FactMapType FactMap; return FactMap; }
@ -45,9 +45,10 @@ const string &AnnotationManager::getName(AnnotationID ID) { // ID -> Name
// Annotable::findOrCreateAnnotation method.
//
void AnnotationManager::registerAnnotationFactory(AnnotationID ID,
AnnFactory F) {
AnnFactory F,
void *ExtraData) {
if (F)
getFactMap()[ID.ID] = F;
getFactMap()[ID.ID] = make_pair(F, ExtraData);
else
getFactMap().erase(ID.ID);
}
@ -59,5 +60,5 @@ Annotation *AnnotationManager::createAnnotation(AnnotationID ID,
Annotable *Obj) {
FactMapType::iterator I = getFactMap().find(ID.ID);
if (I == getFactMap().end()) return 0;
return I->second(ID, Obj);
return I->second.first(ID, Obj, I->second.second);
}

View File

@ -14,8 +14,8 @@ static unsigned IDCounter = 0; // Unique ID counter
static IDMapType &getIDMap() { static IDMapType TheMap; return TheMap; }
// On demand annotation creation support...
typedef Annotation *(*AnnFactory)(AnnotationID, Annotable *);
typedef map<unsigned, AnnFactory> FactMapType;
typedef Annotation *(*AnnFactory)(AnnotationID, Annotable *, void *);
typedef map<unsigned, pair<AnnFactory,void*> > FactMapType;
static FactMapType &getFactMap() { static FactMapType FactMap; return FactMap; }
@ -45,9 +45,10 @@ const string &AnnotationManager::getName(AnnotationID ID) { // ID -> Name
// Annotable::findOrCreateAnnotation method.
//
void AnnotationManager::registerAnnotationFactory(AnnotationID ID,
AnnFactory F) {
AnnFactory F,
void *ExtraData) {
if (F)
getFactMap()[ID.ID] = F;
getFactMap()[ID.ID] = make_pair(F, ExtraData);
else
getFactMap().erase(ID.ID);
}
@ -59,5 +60,5 @@ Annotation *AnnotationManager::createAnnotation(AnnotationID ID,
Annotable *Obj) {
FactMapType::iterator I = getFactMap().find(ID.ID);
if (I == getFactMap().end()) return 0;
return I->second(ID, Obj);
return I->second.first(ID, Obj, I->second.second);
}