mirror of
https://github.com/RPCSX/llvm.git
synced 2024-11-28 22:20:37 +00:00
Add Utility to Scope Names
Add a couple of utility functions to take a variable name and qualify it with the namespace of the enclosing class and/or multiclass. This is inpreparation for making template arg names first-class Inits. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142498 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
ee6dca1725
commit
30c2225b3c
@ -1674,6 +1674,16 @@ struct LessRecordFieldName {
|
||||
|
||||
raw_ostream &operator<<(raw_ostream &OS, const RecordKeeper &RK);
|
||||
|
||||
/// QualifyName - Return an Init with a qualifier prefix referring
|
||||
/// to CurRec's name.
|
||||
Init *QualifyName(Record &CurRec, MultiClass *CurMultiClass,
|
||||
Init *Name, const std::string &Scoper);
|
||||
|
||||
/// QualifyName - Return an Init with a qualifier prefix referring
|
||||
/// to CurRec's name.
|
||||
Init *QualifyName(Record &CurRec, MultiClass *CurMultiClass,
|
||||
const std::string &Name, const std::string &Scoper);
|
||||
|
||||
} // End llvm namespace
|
||||
|
||||
#endif
|
||||
|
@ -2041,3 +2041,39 @@ RecordKeeper::getAllDerivedDefinitions(const std::string &ClassName) const {
|
||||
return Defs;
|
||||
}
|
||||
|
||||
/// QualifyName - Return an Init with a qualifier prefix referring
|
||||
/// to CurRec's name.
|
||||
Init *llvm::QualifyName(Record &CurRec, MultiClass *CurMultiClass,
|
||||
Init *Name, const std::string &Scoper) {
|
||||
RecTy *Type = dynamic_cast<TypedInit *>(Name)->getType();
|
||||
|
||||
BinOpInit *NewName =
|
||||
BinOpInit::get(BinOpInit::STRCONCAT,
|
||||
BinOpInit::get(BinOpInit::STRCONCAT,
|
||||
CurRec.getNameInit(),
|
||||
StringInit::get(Scoper),
|
||||
Type)->Fold(&CurRec, CurMultiClass),
|
||||
Name,
|
||||
Type);
|
||||
|
||||
if (CurMultiClass && Scoper != "::") {
|
||||
NewName =
|
||||
BinOpInit::get(BinOpInit::STRCONCAT,
|
||||
BinOpInit::get(BinOpInit::STRCONCAT,
|
||||
CurMultiClass->Rec.getNameInit(),
|
||||
StringInit::get("::"),
|
||||
Type)->Fold(&CurRec, CurMultiClass),
|
||||
NewName->Fold(&CurRec, CurMultiClass),
|
||||
Type);
|
||||
}
|
||||
|
||||
return NewName->Fold(&CurRec, CurMultiClass);
|
||||
}
|
||||
|
||||
/// QualifyName - Return an Init with a qualifier prefix referring
|
||||
/// to CurRec's name.
|
||||
Init *llvm::QualifyName(Record &CurRec, MultiClass *CurMultiClass,
|
||||
const std::string &Name,
|
||||
const std::string &Scoper) {
|
||||
return QualifyName(CurRec, CurMultiClass, StringInit::get(Name), Scoper);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user