Add and use a new method

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7682 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2003-08-07 19:41:59 +00:00
parent 2b8b2b4aee
commit a40e5ad69f
4 changed files with 16 additions and 4 deletions

View File

@ -703,6 +703,13 @@ public:
return false;
}
bool isSubClassOf(const std::string &Name) const {
for (unsigned i = 0, e = SuperClasses.size(); i != e; ++i)
if (SuperClasses[i]->getName() == Name)
return true;
return false;
}
void addSuperClass(Record *R) {
assert(!isSubClassOf(R) && "Already subclassing record!");
SuperClasses.push_back(R);

View File

@ -73,7 +73,6 @@ void RegisterInfoEmitter::run(std::ostream &OS) {
Records.getAllDerivedDefinitions("RegisterClass");
std::vector<Record*> Registers = Records.getAllDerivedDefinitions("Register");
Record *RegisterClass = Records.getClass("Register");
std::set<Record*> RegistersFound;
std::vector<std::string> RegClassNames;
@ -99,7 +98,7 @@ void RegisterInfoEmitter::run(std::ostream &OS) {
DefInit *RegDef = dynamic_cast<DefInit*>(RegList->getElement(i));
if (!RegDef) throw "Register class member is not a record!";
Record *Reg = RegDef->getDef();
if (!Reg->isSubClassOf(RegisterClass))
if (!Reg->isSubClassOf("Register"))
throw "Register Class member '" + Reg->getName() +
" does not derive from the Register class!";
if (RegistersFound.count(Reg))

View File

@ -703,6 +703,13 @@ public:
return false;
}
bool isSubClassOf(const std::string &Name) const {
for (unsigned i = 0, e = SuperClasses.size(); i != e; ++i)
if (SuperClasses[i]->getName() == Name)
return true;
return false;
}
void addSuperClass(Record *R) {
assert(!isSubClassOf(R) && "Already subclassing record!");
SuperClasses.push_back(R);

View File

@ -73,7 +73,6 @@ void RegisterInfoEmitter::run(std::ostream &OS) {
Records.getAllDerivedDefinitions("RegisterClass");
std::vector<Record*> Registers = Records.getAllDerivedDefinitions("Register");
Record *RegisterClass = Records.getClass("Register");
std::set<Record*> RegistersFound;
std::vector<std::string> RegClassNames;
@ -99,7 +98,7 @@ void RegisterInfoEmitter::run(std::ostream &OS) {
DefInit *RegDef = dynamic_cast<DefInit*>(RegList->getElement(i));
if (!RegDef) throw "Register class member is not a record!";
Record *Reg = RegDef->getDef();
if (!Reg->isSubClassOf(RegisterClass))
if (!Reg->isSubClassOf("Register"))
throw "Register Class member '" + Reg->getName() +
" does not derive from the Register class!";
if (RegistersFound.count(Reg))