Allow passing lists through variables

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7407 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2003-07-30 04:16:52 +00:00
parent 9b929aa749
commit f1b36f9a71
4 changed files with 38 additions and 10 deletions

View File

@ -116,6 +116,14 @@ Init *ListRecTy::convertValue(ListInit *LI) {
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();
}
@ -127,12 +135,12 @@ Init *RecordRecTy::convertValue(DefInit *DI) {
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;
}

View File

@ -108,7 +108,7 @@ struct IntRecTy : public RecTy {
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"; }
};
@ -119,8 +119,14 @@ class ListRecTy : public RecTy {
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;
};

View File

@ -116,6 +116,14 @@ Init *ListRecTy::convertValue(ListInit *LI) {
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();
}
@ -127,12 +135,12 @@ Init *RecordRecTy::convertValue(DefInit *DI) {
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;
}

View File

@ -108,7 +108,7 @@ struct IntRecTy : public RecTy {
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"; }
};
@ -119,8 +119,14 @@ class ListRecTy : public RecTy {
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;
};