return LI;
}
+Init *ListRecTy::convertValue(TypedInit *TI) {
+ // Ensure that TI is compatible with our class.
+ if (ListRecTy *LRT = dynamic_cast<ListRecTy*>(TI->getType()))
+ if (LRT->getElementClass() == getElementClass())
+ return TI;
+ return 0;
+}
+
void RecordRecTy::print(std::ostream &OS) const {
OS << Rec->getName();
}
return DI;
}
-Init *RecordRecTy::convertValue(TypedInit *VI) {
- // Ensure that VI is compatible with Rec.
- if (RecordRecTy *RRT = dynamic_cast<RecordRecTy*>(VI->getType()))
+Init *RecordRecTy::convertValue(TypedInit *TI) {
+ // Ensure that TI is compatible with Rec.
+ if (RecordRecTy *RRT = dynamic_cast<RecordRecTy*>(TI->getType()))
if (RRT->getRecord()->isSubClassOf(getRecord()) ||
RRT->getRecord() == getRecord())
- return VI;
+ return TI;
return 0;
}
struct StringRecTy : public RecTy {
Init *convertValue(UnsetInit *UI) { return (Init*)UI; }
Init *convertValue(StringInit *SI) { return (Init*)SI; }
- Init *convertValue(TypedInit *VI);
+ Init *convertValue(TypedInit *TI);
void print(std::ostream &OS) const { OS << "string"; }
};
Record *Class;
public:
ListRecTy(Record *C) : Class(C) {}
+
+ /// getElementClass - Return the class that the list contains.
+ ///
+ Record *getElementClass() const { return Class; }
+
Init *convertValue(UnsetInit *UI) { return (Init*)UI; }
Init *convertValue(ListInit *LI);
+ Init *convertValue(TypedInit *TI);
void print(std::ostream &OS) const;
};
return LI;
}
+Init *ListRecTy::convertValue(TypedInit *TI) {
+ // Ensure that TI is compatible with our class.
+ if (ListRecTy *LRT = dynamic_cast<ListRecTy*>(TI->getType()))
+ if (LRT->getElementClass() == getElementClass())
+ return TI;
+ return 0;
+}
+
void RecordRecTy::print(std::ostream &OS) const {
OS << Rec->getName();
}
return DI;
}
-Init *RecordRecTy::convertValue(TypedInit *VI) {
- // Ensure that VI is compatible with Rec.
- if (RecordRecTy *RRT = dynamic_cast<RecordRecTy*>(VI->getType()))
+Init *RecordRecTy::convertValue(TypedInit *TI) {
+ // Ensure that TI is compatible with Rec.
+ if (RecordRecTy *RRT = dynamic_cast<RecordRecTy*>(TI->getType()))
if (RRT->getRecord()->isSubClassOf(getRecord()) ||
RRT->getRecord() == getRecord())
- return VI;
+ return TI;
return 0;
}
struct StringRecTy : public RecTy {
Init *convertValue(UnsetInit *UI) { return (Init*)UI; }
Init *convertValue(StringInit *SI) { return (Init*)SI; }
- Init *convertValue(TypedInit *VI);
+ Init *convertValue(TypedInit *TI);
void print(std::ostream &OS) const { OS << "string"; }
};
Record *Class;
public:
ListRecTy(Record *C) : Class(C) {}
+
+ /// getElementClass - Return the class that the list contains.
+ ///
+ Record *getElementClass() const { return Class; }
+
Init *convertValue(UnsetInit *UI) { return (Init*)UI; }
Init *convertValue(ListInit *LI);
+ Init *convertValue(TypedInit *TI);
void print(std::ostream &OS) const;
};