Allow passing lists through variables
authorChris Lattner <sabre@nondot.org>
Wed, 30 Jul 2003 04:16:52 +0000 (04:16 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 30 Jul 2003 04:16:52 +0000 (04:16 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7407 91177308-0d34-0410-b5e6-96231b3b80d8

support/tools/TableGen/Record.cpp
support/tools/TableGen/Record.h
utils/TableGen/Record.cpp
utils/TableGen/Record.h

index 72c5a230e5bebb55c6c89745fd385eac713fea81..a54f8e238b13010ae12175e5ca8f57ff0e3245be 100644 (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;
 }
 
index 356d131ae9ee90ccf3e55f58bbd8b12d11d5b78b..d94bb34504fcb99692a6a69b608f692131eac30a 100644 (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;
 };
index 72c5a230e5bebb55c6c89745fd385eac713fea81..a54f8e238b13010ae12175e5ca8f57ff0e3245be 100644 (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;
 }
 
index 356d131ae9ee90ccf3e55f58bbd8b12d11d5b78b..d94bb34504fcb99692a6a69b608f692131eac30a 100644 (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;
 };