charmxi: abolish use of TList in SDAG processing
authorPhil Miller <mille121@illinois.edu>
Wed, 3 Oct 2012 22:44:19 +0000 (17:44 -0500)
committerPhil Miller <mille121@illinois.edu>
Wed, 3 Oct 2012 22:44:19 +0000 (17:44 -0500)
src/xlat-i/sdag/CEntry.C
src/xlat-i/sdag/CEntry.h
src/xlat-i/sdag/CParsedFile.C
src/xlat-i/sdag/CParsedFile.h
src/xlat-i/sdag/CSdagConstruct.C
src/xlat-i/xi-symbol.h

index 1e913754b350a9f1819ade9fa9d1ccb442a43c4d..6136aa6bf56536f91eed5d9ec4515698a135f03d 100644 (file)
@@ -2,13 +2,14 @@
 #include "xi-symbol.h"
 #include "CStateVar.h"
 
+using std::list;
+
 namespace xi {
 
 void CEntry::generateDeps(XStr& op)
 {
-  SdagConstruct *cn;
-  for(cn=whenList.begin(); !whenList.end(); cn=whenList.next()) {
-    op << "    __cDep->addDepends("<<cn->nodeNum<<","<<entryNum<<");\n";
+  for(list<SdagConstruct*>::iterator cn = whenList.begin(); cn != whenList.end(); ++cn) {
+    op << "    __cDep->addDepends(" << (*cn)->nodeNum << "," << entryNum << ");\n";
   }
 }
 
@@ -261,19 +262,19 @@ void CEntry::generateCode(XStr& decls, XStr& defs)
   SdagConstruct::generateEndExec(defs);
 #endif
 
-  if(whenList.length() == 1) {
+  if(whenList.size() == 1) {
     defs << "    {\n";
-    generateWhenCode(defs, whenList.begin());
+    generateWhenCode(defs, *whenList.begin());
     defs << "    }\n";
   }
   else {   
     defs << "    switch(tr->whenID) {\n";
-    for(SdagConstruct *cn=whenList.begin(); !whenList.end(); cn=whenList.next())
+    for(list<SdagConstruct*>::iterator cn = whenList.begin(); cn != whenList.end(); ++cn)
     {
-      defs << "      case " << cn->nodeNum << ":\n";
+      defs << "      case " << (*cn)->nodeNum << ":\n";
       defs << "      {\n";
       // This emits a `return;', so no `break' is needed
-      generateWhenCode(defs, cn);
+      generateWhenCode(defs, *cn);
       defs << "      }\n";
     }
     defs << "    }\n";
index ff171668c29db42db36c86615fc309813e559173..54fb775ae2f755deefa2c19c53a20519129ee796 100644 (file)
@@ -5,6 +5,8 @@
 #include "sdag-globals.h"
 #include "CList.h"
 
+#include <list>
+
 namespace xi {
 
 class Entry;
@@ -23,7 +25,7 @@ class CEntry{
     int refNumNeeded;
     TList<CStateVar*> *myParameters;
     //TList<CParseNode*> whenList;
-    TList<SdagConstruct*> whenList;
+    std::list<SdagConstruct*> whenList;
     CEntry(XStr *e, ParamList *p, TList<CStateVar*>& list, int pm) : entry(e), paramlist(p), needsParamMarshalling(pm) {
        myParameters = new TList<CStateVar*>();
        CStateVar *sv;
index 20431c162581107e0962ccd687afea3fcb51d570..37ac9827e39e3780b2f8462abe814d0d0ec20d88 100644 (file)
@@ -75,9 +75,8 @@ void CParsedFile::doProcess(XStr& classname, XStr& decls, XStr& defs) {
 
 void CParsedFile::mapCEntry(void)
 {
-  CEntry *en;
-  for(en=entryList.begin(); !entryList.end(); en=entryList.next()) {
-    container->lookforCEntry(en);
+  for(list<CEntry*>::iterator en=entryList.begin(); en != entryList.end(); ++en) {
+    container->lookforCEntry(*en);
   }
 }
 
@@ -105,12 +104,11 @@ void CParsedFile::generateCode(XStr& decls, XStr& defs)
 
 void CParsedFile::generateEntries(XStr& decls, XStr& defs)
 {
-  CEntry *en;
   decls << "public:\n";
   for(list<SdagConstruct *>::iterator sc=connectEntryList.begin(); sc != connectEntryList.end(); ++sc)
     (*sc)->generateConnectEntries(decls);
-  for(en=entryList.begin(); !entryList.end(); en=entryList.next()) {
-    en->generateCode(decls, defs);
+  for(list<CEntry*>::iterator en = entryList.begin(); en != entryList.end(); ++en) {
+    (*en)->generateCode(decls, defs);
   }
 }
 
@@ -123,8 +121,8 @@ void CParsedFile::generateInitFunction(XStr& decls, XStr& defs)
   generateSignature(decls, defs, container, false, "void", &name, false, NULL);
   defs << "    __cDep = new CDep(" << numEntries << "," << numWhens << ");\n";
   CEntry *en;
-  for(en=entryList.begin(); !entryList.end(); en=entryList.next()) {
-    en->generateDeps(defs);
+  for(list<CEntry*>::iterator en=entryList.begin(); en != entryList.end(); ++en) {
+    (*en)->generateDeps(defs);
   }
   endMethod(defs);
 
index ba6f5201f594aa9b49686e50b7fb1de51f06cb57..9d6ac8f710cf810977206d8d545e0c9393879583 100644 (file)
@@ -26,7 +26,7 @@ class CParsedFile {
     void generateRegisterEp(XStr& decls, XStr& defs);
     void generateDependencyMergePoints(XStr& output);
     std::list<Entry*> nodeList;
-    TList<CEntry*> entryList;
+    std::list<CEntry*> entryList;
     std::list<SdagConstruct *> connectEntryList;
     Chare *container;
 
index 1ceef78cde86cc983bcd775070ac1d88e1e27a2d..aec760b75dee4ad9154faed479fbeac68fc375bc 100644 (file)
@@ -5,6 +5,8 @@
 #include "CParsedFile.h"
 #include "EToken.h"
 #include "CStateVar.h"
+#include <list>
+using std::list;
 
 namespace xi {
 
@@ -184,7 +186,7 @@ void SdagConstruct::labelNodes(void)
   }
 }
 
-void EntryList::generateEntryList(TList<CEntry*>& CEntrylist, SdagConstruct *thisWhen)
+void EntryList::generateEntryList(list<CEntry*>& CEntrylist, SdagConstruct *thisWhen)
 {
    EntryList *el;
    el = this;
@@ -195,21 +197,21 @@ void EntryList::generateEntryList(TList<CEntry*>& CEntrylist, SdagConstruct *thi
    }
 }
 
-void Entry::generateEntryList(TList<CEntry*>& CEntrylist, SdagConstruct *thisWhen)
+void Entry::generateEntryList(list<CEntry*>& CEntrylist, SdagConstruct *thisWhen)
 {
    // case SENTRY:
-   CEntry *entry;
    bool found = false;
    
-   for(entry=CEntrylist.begin(); !CEntrylist.end(); entry=CEntrylist.next()) {
-     if(*(entry->entry) == (const char *)name) 
+   for(list<CEntry *>::iterator entry=CEntrylist.begin(); 
+       entry != CEntrylist.end(); ++entry) {
+     if(*((*entry)->entry) == (const char *)name) 
      {
         ParamList *epl;
-       epl = entry->paramlist;
+       epl = (*entry)->paramlist;
         ParamList *pl;
         pl = param;
         found = false;
-       if ((entry->paramlist->isVoid() == 1) && (pl->isVoid() == 1)) {
+       if (((*entry)->paramlist->isVoid() == 1) && (pl->isVoid() == 1)) {
           found = true;
        }
        while ((pl != NULL) && (epl != NULL))
@@ -232,34 +234,33 @@ void Entry::generateEntryList(TList<CEntry*>& CEntrylist, SdagConstruct *thisWhe
           found = false;
        if (found) {
           // check to see if thisWhen is already in entry's whenList
-          int whenFound = 0;
-          TList<SdagConstruct*> *tmpList = &(entry->whenList);
-          SdagConstruct *tmpNode;
-          for(tmpNode = tmpList->begin(); !tmpList->end(); tmpNode = tmpList->next()) {
-            if(tmpNode->nodeNum == thisWhen->nodeNum)
-               whenFound = 1;
+          bool whenFound = false;
+          for(list<SdagConstruct*>::iterator it = (*entry)->whenList.begin();
+              it != (*entry)->whenList.end(); ++it) {
+            if ((*it)->nodeNum == thisWhen->nodeNum)
+              whenFound = true;
           }
           if(!whenFound)
-            entry->whenList.append(thisWhen);
-          entryPtr = entry;
+            (*entry)->whenList.push_back(thisWhen);
+          entryPtr = *entry;
           if(intExpr != 0)
-            entry->refNumNeeded = 1; 
+            (*entry)->refNumNeeded = 1; 
         } 
      }
    }
    if(!found) {
      CEntry *newEntry;
      newEntry = new CEntry(new XStr(name), param, estateVars, paramIsMarshalled() );
-     CEntrylist.append(newEntry);
+     CEntrylist.push_back(newEntry);
      entryPtr = newEntry;
-     newEntry->whenList.append(thisWhen);
+     newEntry->whenList.push_back(thisWhen);
      if(intExpr != 0)
        newEntry->refNumNeeded = 1; 
    }
       //break;
 }
 
-void SdagConstruct::generateEntryList(TList<CEntry*>& CEntrylist, SdagConstruct *thisWhen)
+void SdagConstruct::generateEntryList(std::list<CEntry*>& CEntrylist, SdagConstruct *thisWhen)
 {
   SdagConstruct *cn;
   switch(type) {
index 50d0c383af3c13f22c6222482d1e7edfa4acfa4d..a871d43bd1f79cd772fe3506a7210324c93991e9 100644 (file)
@@ -1047,7 +1047,7 @@ class Entry : public Member {
     XStr genRegEp(bool isForRedn = false);
     void preprocess();
     char *getEntryName() { return name; }
-    void generateEntryList(TList<CEntry*>&, SdagConstruct *);
+    void generateEntryList(std::list<CEntry*>&, SdagConstruct *);
     void collectSdagCode(CParsedFile *pf, int& sdagPresent);
     void propagateState(int);
     void lookforCEntry(CEntry *centry);
@@ -1060,7 +1060,7 @@ class EntryList {
     EntryList *next;
     EntryList(Entry *e,EntryList *elist=NULL):
        entry(e), next(elist) {}
-    void generateEntryList(TList<CEntry*>&, SdagConstruct *);
+    void generateEntryList(std::list<CEntry*>&, SdagConstruct *);
 };
 
 
@@ -1311,7 +1311,7 @@ public:
   void labelNodes(void);
   void generateConnectEntryList(std::list<SdagConstruct*>&);
   void generateConnectEntries(XStr&);
-  void generateEntryList(TList<CEntry*>&, SdagConstruct *);
+  void generateEntryList(std::list<CEntry*>&, SdagConstruct *);
   void propagateState(int);
   void propagateState(TList<CStateVar*>&, TList<CStateVar*>&, TList<SdagConstruct*>&, int);
   void generateCode(XStr& decls, XStr& defs, Entry *entry);