// funcTab.cpp #include #include "funcTab.h" #include "pmglobs.h" void funcAttributes::seeFuncAttributes() { cout << qnum; cout.width(7); cout << pcnt; cout.width(7); for (int i = 0; i < pcnt; i++) { cout << type[i]; cout.width(3); } } void idFuncTable::createEntry(int idx) { idFuncNode* anIdFuncNode = ifn; idFuncNode* bIdFuncNode = NULL; while ( anIdFuncNode != NULL) { // copy anIdFuncNode to bIdFuncNode bIdFuncNode = anIdFuncNode; anIdFuncNode = anIdFuncNode->next; } // create new idFuncNode with its index = idx, init other values. idFuncNode* cIdFuncNode = new idFuncNode; cIdFuncNode->index = idx; cIdFuncNode->fAttributes.qnum = -1; cIdFuncNode->fAttributes.pcnt = -1; for (int i = 0; i < MAXPARAMS; i++) { cIdFuncNode->fAttributes.type[i] = -1; } cIdFuncNode->next = NULL; // insert as head if ifn is NULL otherwise add to tail. // This is enqueue process. if (bIdFuncNode == NULL) { ifn = cIdFuncNode; } else { bIdFuncNode->next = cIdFuncNode; } } void idFuncTable::saveQnum(int idx, int qnum) { idFuncNode* anIdFuncNode = ifn; bool found = false; while ( (anIdFuncNode != NULL) && !found) { if (anIdFuncNode->index == idx) { // if found, store qnum in ifn. (anIdFuncNode->fAttributes).qnum = qnum; found = true; } else { anIdFuncNode = anIdFuncNode->next; } } // end of while loop. } void idFuncTable::savePcnt(int idx, int pcnt) { idFuncNode* anIdFuncNode = ifn; bool found = false; while ( (anIdFuncNode != NULL) && !found) { if (anIdFuncNode->index == idx) { // if found, store qnum in ifn. (anIdFuncNode->fAttributes).pcnt = pcnt; found = true; } else { anIdFuncNode = anIdFuncNode->next; } } // end of while loop. } void idFuncTable::saveType(int idx, int pcnt, int type) { idFuncNode* anIdFuncNode = ifn; bool found = false; while ( (anIdFuncNode != NULL) && !found) { if (anIdFuncNode->index == idx) { // if found, store qnum in ifn. (anIdFuncNode->fAttributes).type[pcnt] = type; found = true; } else { anIdFuncNode = anIdFuncNode->next; } } // end of while loop. } void idFuncTable::retrieveFAttributes(int idx, funcAttributes& fAttributes) { // Retrieve the memory. idFuncNode* anIdFuncNode = ifn; while ( anIdFuncNode != NULL) { if (anIdFuncNode->index == idx) { // if found, store qnum in ifn. anIdFuncNode->fAttributes = fAttributes; anIdFuncNode = NULL; } else { anIdFuncNode = anIdFuncNode->next; } } // end of while loop. } void idFuncTable::seeFuncTable() { idFuncNode* anIdFuncNode = ifn; while ( anIdFuncNode != NULL) { cout << "\nFunction id index == " << anIdFuncNode->index; cout.width(7); anIdFuncNode->fAttributes.seeFuncAttributes(); anIdFuncNode = anIdFuncNode->next; } // end of while loop. cout << endl; }