00001 /*------------------------------------------------------------------- 00002 * Name: legoModu.H 00003 * 00004 * Designer: Willie Glover 00005 * 00006 * Created: 5/28/96 00007 * 00008 * Description: This file contains the LEGO header file which 00009 * defines the module region derived class. 00010 * 00011 * legoModule is derived from region class. The 00012 * container holds legoProcs. In addition to the 00013 * module name, this class also has pointers to 00014 * the data segments associated with this module. 00015 * 00016 * Location: /ncsu/tinker/LEGO/src/derived/legoModu.H 00017 -------------------------------------------------------------------- 00018 * 8/12/96 WTG: Initial file creation. 00019 * 4/8/97 WAH: Fixed default constructor to allocate 5 bytes, not 4. 00020 * 6/11/97 WAH: Added GetOpCount method. 00021 * 12/11/97 WAH: Added comments field and associated methods. 00022 * 1/9/98 WAH: Fixed constructors and SetModuleName to handle NULL name. 00023 --------------------------------------------------------------------*/ 00024 00025 #ifndef LEGOMODU_H 00026 #define LEGOMODU_H 00027 00028 #include <stl.h> 00029 #include "region.H" 00030 00031 //--------------------------------------------------------------------------- 00032 00033 #include "lSymTab.H" 00034 #include "opEdges.H" 00035 #include "attr.H" 00036 #include "legoJump.H" 00037 class memvrs; 00038 00039 class legoModule: 00040 public legoRegion 00041 { 00042 00043 char *moduleName; 00044 vector <char *> *comments; 00045 00046 symbolTable* dataPtr; 00047 symbolTable* data1Ptr; 00048 symbolTable* bssPtr; 00049 symbolTable* textPtr; 00050 //HZ: 12/17/01 added the segments of SDATA (short data), SBSS (short 00051 // uninitialized data), COMMENT (COMMENT segment) for IA-64 00052 symbolTable* sdataPtr; 00053 symbolTable* sbssPtr; 00054 symbolTable* commentPtr; 00055 00056 opEdges* edgeDictionary; 00057 attrs* attrDictionary; 00058 jumpTable* jumpDictionary; 00059 memvrs* memDictionary; 00060 00061 public: 00062 00063 legoModule () : legoRegion(RT_MODULE,1) 00064 { 00065 // fprintf(stderr,"Creating LEGOMODULE %p\n",this); 00066 moduleName = new char[5]; 00067 (void)strcpy(moduleName,"none"); 00068 comments = new vector<char *>; 00069 //dataPtr = data1Ptr = bssPtr = textPtr = NULL; 00070 //HZ: 00071 commentPtr = sbssPtr = sdataPtr = dataPtr = data1Ptr = bssPtr = textPtr = NULL; 00072 edgeDictionary = NULL; 00073 attrDictionary = NULL; 00074 jumpDictionary = NULL; 00075 memDictionary = NULL; 00076 } 00077 00078 legoModule (char* name, unsigned rId = 1) 00079 : legoRegion(RT_MODULE,rId) 00080 { 00081 // fprintf(stderr,"Creating LEGOMODULE %p\n",this); 00082 if (name != NULL) 00083 { 00084 moduleName = new char[strlen(name)+1]; 00085 (void)strcpy(moduleName,name); 00086 } // end if 00087 else moduleName = NULL; 00088 comments = new vector<char *>; 00089 //dataPtr = data1Ptr = bssPtr = textPtr = NULL; 00090 //HZ: 00091 commentPtr = sbssPtr = sdataPtr = dataPtr = data1Ptr = bssPtr = textPtr = NULL; 00092 00093 edgeDictionary = NULL; 00094 attrDictionary = NULL; 00095 jumpDictionary = NULL; 00096 memDictionary = NULL; 00097 } 00098 00099 legoModule (const legoModule &orig) : legoRegion ((legoRegion) orig) 00100 { 00101 vector<char *>::iterator comi; 00102 // fprintf(stderr,"Creating LEGOMODULE %p\n",this); 00103 if (orig.moduleName != NULL) 00104 { 00105 moduleName = new char[strlen(orig.moduleName)+1]; 00106 (void)strcpy(moduleName,orig.moduleName); 00107 } // end if 00108 else 00109 moduleName = NULL; 00110 comments = new vector<char *>; 00111 for (comi = orig.comments->begin(); comi != orig.comments->end(); 00112 comi++) 00113 { 00114 char *temp = new char [strlen (*comi) + 1]; 00115 strcpy (temp, *comi); 00116 comments->push_back (temp); 00117 } // end for 00118 //HZ: 00119 if (orig.sdataPtr != NULL) 00120 sdataPtr = new symbolTable (*(orig.sdataPtr)); 00121 else 00122 sdataPtr = NULL; 00123 if (orig.sbssPtr != NULL) 00124 sbssPtr = new symbolTable (*(orig.sbssPtr)); 00125 else 00126 sbssPtr = NULL; 00127 if (orig.commentPtr != NULL) 00128 commentPtr = new symbolTable (*(orig.commentPtr)); 00129 else 00130 commentPtr = NULL; 00131 00132 if (orig.dataPtr != NULL) 00133 dataPtr = new symbolTable (*(orig.dataPtr)); 00134 else 00135 dataPtr = NULL; 00136 if (orig.data1Ptr != NULL) 00137 data1Ptr = new symbolTable (*(orig.data1Ptr)); 00138 else 00139 data1Ptr = NULL; 00140 if (orig.bssPtr != NULL) 00141 bssPtr = new symbolTable (*(orig.bssPtr)); 00142 else 00143 bssPtr = NULL; 00144 if (orig.textPtr != NULL) 00145 textPtr = new symbolTable (*(orig.textPtr)); 00146 else 00147 textPtr = NULL; 00148 if (orig.edgeDictionary != NULL) 00149 edgeDictionary = new opEdges (*(orig.edgeDictionary)); 00150 else 00151 edgeDictionary = NULL; 00152 if (orig.attrDictionary != NULL) 00153 attrDictionary = new attrs (*(orig.attrDictionary)); 00154 else 00155 attrDictionary = NULL; 00156 if (orig.jumpDictionary != NULL) 00157 jumpDictionary = new jumpTable (*(orig.jumpDictionary)); 00158 else 00159 jumpDictionary = NULL; 00160 memDictionary = NULL; 00161 // if (orig.memDictionary != NULL) 00162 // memDictionary = new (*(orig.memDictionary)); 00163 } 00164 00165 00166 ~legoModule () 00167 { 00168 vector<char *>::iterator comi; 00169 delete[] moduleName; 00170 for (comi = comments->begin(); comi != comments->end(); comi++) 00171 delete[] *comi; 00172 delete comments; 00173 delete dataPtr; 00174 delete data1Ptr; 00175 delete bssPtr; 00176 delete textPtr; 00177 00178 delete sdataPtr; 00179 delete sbssPtr; 00180 delete commentPtr; 00181 00182 delete edgeDictionary; 00183 delete attrDictionary; 00184 delete jumpDictionary; 00185 // delete memDictionary; 00186 RegionKiller(); 00187 // fprintf(stderr,"Deleting LEGOMODULE %p\n",this); 00188 } 00189 int GetOpCount (void) 00190 { 00191 int opct = 0; 00192 00193 for (int i = 0; i < GetCount(); i++) 00194 opct += ((legoRegion *) GetItem(i))->GetOpCount(); 00195 return opct; 00196 } 00197 00198 /*------------------------------------------------------------------- 00199 Update the name of the module. 00200 --------------------------------------------------------------------*/ 00201 void SetModuleName(char *mName) 00202 { 00203 delete[] moduleName; 00204 if (mName != NULL) 00205 { 00206 moduleName = new char[strlen(mName)+1]; 00207 (void)strcpy(moduleName,mName); 00208 } // end if 00209 else moduleName = NULL; 00210 } 00211 00212 /*------------------------------------------------------------------- 00213 Update the comments. 00214 --------------------------------------------------------------------*/ 00215 void SetComments (vector<char *> *c) 00216 { 00217 vector<char *>::iterator comi; 00218 00219 for (comi = comments->begin(); comi != comments->end(); comi++) 00220 delete[] *comi; 00221 delete comments; 00222 comments = c; 00223 } 00224 00225 /*------------------------------------------------------------------- 00226 Update the "data" data segment pointer. 00227 --------------------------------------------------------------------*/ 00228 void SetDataPtr(symbolTable* newDataPtr) { dataPtr = newDataPtr; } 00229 00230 //HZ: 00231 void SetSDataPtr(symbolTable* newSDataPtr) { sdataPtr = newSDataPtr; } 00232 00233 /*------------------------------------------------------------------- 00234 Update the "data1" data segment pointer. 00235 --------------------------------------------------------------------*/ 00236 void SetData1Ptr(symbolTable* newData1Ptr) { 00237 data1Ptr = newData1Ptr; } 00238 00239 /*------------------------------------------------------------------- 00240 Update the "bss" data segment pointer. 00241 --------------------------------------------------------------------*/ 00242 void SetBssPtr(symbolTable* newBssPtr) { bssPtr = newBssPtr; } 00243 00244 //HZ: 00245 void SetSBssPtr(symbolTable* newSBssPtr) { sbssPtr = newSBssPtr; } 00246 void SetCommentPtr(symbolTable* newCommentPtr) { commentPtr = newCommentPtr; } 00247 00248 void SetTextPtr(symbolTable* newTextPtr) { textPtr = newTextPtr; } 00249 00250 /*------------------------------------------------------------------- 00251 Update the edge dictionary pointer. 00252 --------------------------------------------------------------------*/ 00253 void SetEdgeDictionary(opEdges *newEdgeDictionary) 00254 { edgeDictionary = newEdgeDictionary; } 00255 00256 /*------------------------------------------------------------------- 00257 Update the attribute dictionary pointer. 00258 --------------------------------------------------------------------*/ 00259 void SetAttrDictionary(attrs *newAttrDictionary) 00260 { attrDictionary = newAttrDictionary; } 00261 00262 /*------------------------------------------------------------------- 00263 Update the jump dictionary pointer. 00264 --------------------------------------------------------------------*/ 00265 void SetJumpDictionary(jumpTable *newJumpDictionary) 00266 { jumpDictionary = newJumpDictionary; } 00267 00268 /*------------------------------------------------------------------- 00269 Update the memvrs dictionary pointer. 00270 --------------------------------------------------------------------*/ 00271 void SetMemDictionary(memvrs *newMemDictionary) 00272 { memDictionary = newMemDictionary; } 00273 00274 /*------------------------------------------------------------------- 00275 Get the module name. 00276 --------------------------------------------------------------------*/ 00277 char *GetModuleName(void) { return moduleName; } 00278 00279 /*------------------------------------------------------------------- 00280 Get the comments. 00281 --------------------------------------------------------------------*/ 00282 vector<char *> *GetComments(void) { return comments; } 00283 00284 /*------------------------------------------------------------------- 00285 Get the "data" data segment pointer. 00286 --------------------------------------------------------------------*/ 00287 symbolTable* GetDataPtr(void) { return dataPtr; } 00288 00289 //HZ: 00290 symbolTable* GetSDataPtr(void) { return sdataPtr; } 00291 00292 /*------------------------------------------------------------------- 00293 Get the "data1" data segment pointer 00294 --------------------------------------------------------------------*/ 00295 symbolTable* GetData1Ptr(void) { return data1Ptr; } 00296 00297 /*------------------------------------------------------------------- 00298 Get the "bss" data segment pointer. 00299 --------------------------------------------------------------------*/ 00300 symbolTable* GetBssPtr(void) { return bssPtr; } 00301 //HZ: 00302 symbolTable* GetSBssPtr(void) { return sbssPtr; } 00303 symbolTable* GetCommentPtr(void) { return commentPtr; } 00304 00305 symbolTable* GetTextPtr(void) { return textPtr; } 00306 00307 /*------------------------------------------------------------------- 00308 Get the edge dictionary pointer. 00309 --------------------------------------------------------------------*/ 00310 opEdges *GetEdgeDictionary(void) { return edgeDictionary; } 00311 00312 /*------------------------------------------------------------------- 00313 Get the attribute dictionary pointer. 00314 --------------------------------------------------------------------*/ 00315 attrs *GetAttrDictionary(void) { return attrDictionary; } 00316 00317 /*------------------------------------------------------------------- 00318 Get the jump dictionary pointer. 00319 --------------------------------------------------------------------*/ 00320 jumpTable *GetJumpDictionary(void) { return jumpDictionary; } 00321 00322 /*------------------------------------------------------------------- 00323 Get the memvrs dictionary pointer. 00324 --------------------------------------------------------------------*/ 00325 memvrs *GetMemDictionary(void) { return memDictionary; } 00326 }; 00327 00328 #endif // LEGOMODU_H 00329
1.3.2