00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 #ifndef NODEINFO_H
00042 #define NODEINFO_H
00043
00044 #ifdef J_BREEZE
00045 #include "j_breeze.h"
00046 #include "arrayclass.h"
00047 #else
00048 #include "c_breeze.h"
00049 #endif
00050
00051
00052
00053
00054
00055
00082 class NodeInfo {
00083 private:
00084 FILE *_file;
00085 bool _read_mode;
00086 bool _verbose;
00087
00088
00089 map<int,string> strings;
00090 map<int,Node*> index2node;
00091 map<Node*,int> node2index;
00092 int _line;
00093
00094 #ifndef J_BREEZE
00095
00096
00097 static list<arrayNode*> _canonical1;
00098
00099
00100 static map<typeNode*,arrayNode*> _canonical2;
00101 #endif
00102
00103 public:
00105
00117 NodeInfo(string filename, bool readmode, bool verbose);
00118
00120 ~NodeInfo();
00121
00122
00124
00126 inline bool read_mode(void) { return _read_mode; }
00127
00130 inline string index(int i) { return strings[i]; }
00131
00135 inline Node *indexNode(int i) { return index2node[i]; }
00136
00141 inline int nodeIndex(Node *node) {
00142 if(!node) return 0;
00143 if(node->typ()==Array)
00144 #ifdef J_BREEZE
00145 return node2index[ ArrayClass::canonical((arrayNode*)node) ];
00146 #else
00147 return node2index[ canonical((arrayNode*)node) ];
00148 #endif
00149 return node2index[node];
00150 }
00151
00153 inline int nStrings() { return strings.size(); }
00154
00155
00165
00171 inline int current_line(void) { return _line; }
00172
00174 void writeType(typeNode *t);
00175 #ifdef J_BREEZE
00176
00177 void writeClassOrInterface(referenceNode *t);
00179 void writeMethod(methodNode *m);
00181 void writeConstructor(constructorNode *c);
00183 void writeFieldvar(fieldvarNode *fv, declNode *d=0);
00185 void writeFieldinit(fieldinitNode *fi);
00186 #else
00187
00188 void writeProc(procNode *proc);
00189 #endif
00190
00191
00192
00193
00197 void writeStmt(stmtNode *s, int container=-1);
00198
00199 #ifdef J_BREEZE
00200
00203 void writeCall(mcallNode *c, int container=-1);
00204
00208 void writeNew(newNode *n, int container=-1);
00209
00210 #else
00211
00214 void writeCall(callNode *c, int container=-1);
00215 #endif
00216
00223 void writeExpr(exprNode *expr, int container=-1);
00224
00228 void writeDecl(declNode *d, int container=-1);
00229
00234 void writeString(string s);
00235
00236 #ifdef J_BREEZE
00237
00241 static string type_string(typeNode *ty);
00242 #endif
00243
00244
00245 #ifndef J_BREEZE
00246
00251 static arrayNode *canonical(arrayNode *array);
00252 #endif
00253
00254 private:
00255 class NodeLocator;
00258 friend class NodeLocator;
00259
00263
00264
00265
00266 Coord getCoord(string s, unitNode **unit);
00267
00268
00269 typeNode *getType(unitNode *unit, string s);
00270
00271 #ifdef J_BREEZE
00272
00273 typeNode *getLibType(string s);
00274 #endif
00275
00276 #ifndef J_BREEZE
00277 static string type_name(typeNode *t);
00278 static typeNode *def_type(typeNode *ty);
00279 #endif
00280
00281
00285
00286 Node *getNode(string s);
00287
00288 typeNode *readType(string s);
00289 #ifdef J_BREEZE
00290 typeNode *readClassOrInterface(string s);
00291 methodNode *readMethod(string s);
00292 constructorNode *readConstructor(string s);
00293 fieldvarNode *readFieldvar(string s);
00294 fieldinitNode *readFieldinit(string s);
00295 mcallNode *readCall(string s);
00296 newNode *readNew(string s);
00297 #else
00298 procNode *readProc(string s);
00299 typeNode *readsuef(string s);
00300 callNode *readCall(string s);
00301 #endif
00302 Node *readExprOrStmt(string s, NodeType typ);
00303 declNode *readDecl(string s);
00304
00305 bool match_args(string args, decl_list formals);
00306
00307 };
00308
00309 #endif