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 int ncount = 0;
00039 int freqs[100];
00040 static void print_all (void);
00041
00042 #include "c_breeze.h"
00043
00044
00045
00046 int Node::_count = 0;
00047 int Node::_uid_count = 0;
00048 int Node::_t_count[50];
00049
00050 char * TypNames[] = {
00051
00052 "Const", "Id", "Binary", "Unary", "Cast", "Comma", "Ternary",
00053 "Call", "Initializer",
00054
00055
00056 "Label", "Switch", "Case", "If", "While", "Do",
00057 "For", "Goto", "Continue", "Break", "Return", "Block",
00058
00059
00060 "Prim", "Tdef", "Ptr", "Array", "Func", "Struct", "Union", "Enum", "sueSpec",
00061
00062
00063
00064 "Decl",
00065
00066
00067 "Attrib",
00068
00069
00070 "Proc",
00071
00072
00073 "Text",
00074
00075
00076 "Expr",
00077
00078
00079 "Undeclared",
00080
00081
00082
00083 "Unit"
00084 };
00085
00086
00087
00088
00089
00090 Node::Node(NodeType the_typ, const Coord coord, bool parenthesized)
00091 : _typ(the_typ),
00092 _coord(coord),
00093 _parenthesized(parenthesized),
00094 _annotations(),
00095 _gen(0),
00096 _kill(0)
00097 {
00098
00099
00100
00101
00102
00103
00104
00105
00106 Node::nodes.push_back (this);
00107 ++_count;
00108 ++_t_count[the_typ];
00109
00110
00111 }
00112
00113
00114
00115 node_list Node::nodes;
00116 map <Node *, bool> Node::deleted_nodes;
00117
00118 static void print_all (void) {
00119 int i;
00120
00121 printf ("node freqs:\n");
00122 for (i=0; i<100; i++) if (freqs[i]) printf ("%d: %d\n", i, freqs[i]);
00123 }
00124 Node::Node(const Node & other)
00125 : _typ(other._typ),
00126 _coord(other._coord),
00127 _parenthesized(other._parenthesized),
00128 _annotations(),
00129 _gen(0),
00130 _kill(0)
00131 {
00132
00133
00134
00135
00136
00137
00138
00139 Node::nodes.push_back (this);
00140
00141
00142
00143
00144 }
00145
00146
00147
00148
00149
00150
00151
00152 typeNode * Node::base_type(bool TdefIndir) const
00153 {
00154 return (typeNode *) 0;
00155 }
00156
00157 typeNode * Node::datatype() const
00158 {
00159 return base_type(true);
00160 }
00161
00162 typeNode * Node::datatype_superior() const
00163 {
00164 return base_type(false);
00165 }
00166
00167
00168
00169
00170
00171
00172 Node::~Node()
00173 {
00174 deleted_nodes[this] = true;
00175
00176
00177
00178 }
00179
00180
00181
00182
00183
00184 void Node::report()
00185 {
00186 cout << "Nodes: " << _count << endl;
00187 for (int i = 0; i <= Undeclared; ++i) {
00188 if (_t_count[i] != 0) {
00189
00190 cout << " ";
00191 switch (i) {
00192 case Const:
00193 cout << "Const";
00194 break;
00195 case Id:
00196 cout << "Id";
00197 break;
00198 case Binary:
00199 cout << "Binary";
00200 break;
00201 case Unary:
00202 cout << "Unary";
00203 break;
00204 case Cast:
00205 cout << "Cast";
00206 break;
00207 case Comma:
00208 cout << "Comma";
00209 break;
00210 case Ternary:
00211 cout << "Ternary";
00212 break;
00213 case Call:
00214 cout << "Call";
00215 break;
00216 case Initializer:
00217 cout << "Initializer";
00218 break;
00219 case Label:
00220 cout << "Label";
00221 break;
00222 case Switch:
00223 cout << "Switch";
00224 break;
00225 case Case:
00226 cout << "Case";
00227 break;
00228 case If:
00229 cout << "If";
00230 break;
00231 case While:
00232 cout << "While";
00233 break;
00234 case Do:
00235 cout << "Do";
00236 break;
00237 case For:
00238 cout << "For";
00239 break;
00240 case Goto:
00241 cout << "Goto";
00242 break;
00243 case Continue:
00244 cout << "Continue";
00245 break;
00246 case Break:
00247 cout << "Break";
00248 break;
00249 case Return:
00250 cout << "Return";
00251 break;
00252 case Block:
00253 cout << "Block";
00254 break;
00255 case Prim:
00256 cout << "Prim";
00257 break;
00258 case Tdef:
00259 cout << "Tdef";
00260 break;
00261 case Ptr:
00262 cout << "Ptr";
00263 break;
00264 case Array:
00265 cout << "Array";
00266 break;
00267 case Func:
00268 cout << "Func";
00269 break;
00270 case Struct:
00271 cout << "Struct";
00272 break;
00273 case Union:
00274 cout << "Union";
00275 break;
00276 case Enum:
00277 cout << "Enum";
00278 break;
00279 case sueSpec:
00280 cout << "sueSpec";
00281 break;
00282 case Decl:
00283 cout << "Decl";
00284 break;
00285 case Attrib:
00286 cout << "Attrib";
00287 break;
00288 case Proc:
00289 cout << "Proc";
00290 break;
00291 case Text:
00292 cout << "Text";
00293 break;
00294 case Expr:
00295 cout << "Expr";
00296 break;
00297 case Undeclared:
00298 cout << "Undeclared";
00299 break;
00300 default:
00301 cout << "ERROR";
00302 break;
00303 }
00304
00305 cout << " : " << _t_count[i] << endl;
00306 }
00307 }
00308 }