not needed
[prop.git] / prop-src / visual2.cc
blob6ac07fd0a6cec248acaac9cba6f2fd3c4ce9aca8
1 ///////////////////////////////////////////////////////////////////////////////
2 // This file is generated automatically using Prop (version 2.3.6),
3 // last updated on Nov 2, 1999.
4 // The original source file is "visual2.pcc".
5 ///////////////////////////////////////////////////////////////////////////////
7 #line 1 "visual2.pcc"
8 //////////////////////////////////////////////////////////////////////////////
9 //
10 // This file implements the datatype definitions layout generator
11 // for visualizing datatype definitions using vcg.
13 //////////////////////////////////////////////////////////////////////////////
14 #include <AD/strings/quark.h>
15 #include "ir.h"
16 #include "type.h"
17 #include "classdef.h"
18 #include "datatype.h"
19 #include "hashtab.h"
20 #include "visualize.h"
22 //////////////////////////////////////////////////////////////////////////////
24 // This method visualizes all the class definitions.
26 //////////////////////////////////////////////////////////////////////////////
27 void PropVisualizer::visualize_datatype_definitions()
28 { const char * Datatypes = "All datatypes definitions";
30 begin_node(Datatypes);
31 label (Datatypes);
32 end_node (Datatypes);
34 for (HashTable::Entry * e = ClassDefinition::defined_classes.first();
35 e != 0; e = ClassDefinition::defined_classes.next(e))
37 ClassDefinition * C = (ClassDefinition *)(e->v);
38 C->visualize(*this);
42 //////////////////////////////////////////////////////////////////////////////
44 // This method a particular class definitions.
46 //////////////////////////////////////////////////////////////////////////////
47 void ClassDefinition::visualize(PropVisualizer& v)
48 { v . begin_node (class_name);
49 v . add_label ("%s %s", class_type_name[class_type], class_name);
50 v . make_label ();
51 v . end_node (class_name);
54 //////////////////////////////////////////////////////////////////////////////
56 // This method visualizes a datatype hierarchy.
58 //////////////////////////////////////////////////////////////////////////////
59 void DatatypeHierarchy::visualize(PropVisualizer& v)
60 { v . begin_node (datatype_name);
61 v . add_label ("datatype %s%V\n", datatype_name, parameters);
62 v . add_label ("(\"%s\" line %i)\n", file_name, begin_line);
63 for (int i = 0; i < arity; i++)
64 { Cons c = constructor_terms[i];
65 v . add_label(" %s\n", constructor_terms[i]->name);
67 v . make_label ();
69 int offset = 2;
71 // Make a node for each of the constructors.
72 for (int i = 0; i < arity; i++)
73 { Cons c = constructor_terms[i];
74 if (c->ty == NOty) // unit constructors
75 { v . begin_node(c->name);
76 v . label(c->name);
77 v . end_node(c->name);
79 v . begin_edge(datatype_name, c->name);
80 v . color (VCG::darkblue);
81 v . arrowcolor (VCG::red);
82 v . thickness (4);
83 //v . anchor(offset + i + 1);
84 v . end_edge(datatype_name, c->name);
87 v . end_node (datatype_name);
89 // Argument constructors
91 // Generate the only argument
92 if (cons != NOcons) DatatypeClass::visualize(v);
95 //////////////////////////////////////////////////////////////////////////////
97 // This method visualizes a datatype subclass
99 //////////////////////////////////////////////////////////////////////////////
100 void DatatypeClass::visualize(PropVisualizer& v)
101 { v . begin_node (constructor_name);
102 v . add_label ("%s\n", constructor_name);
104 // Print each type on a single line
105 int anchor = 2;
107 #line 99 "visual2.pcc"
108 #line 108 "visual2.pcc"
110 Ty _V1 = cons->ty;
111 if (_V1) {
112 switch (_V1->tag__) {
113 case a_Ty::tag_TYCONty: {
114 if (boxed(((Ty_TYCONty *)_V1)->_1)) {
115 switch (((Ty_TYCONty *)_V1)->_1->tag__) {
116 case a_TyCon::tag_RECORDtycon: {
117 #line 104 "visual2.pcc"
118 Ids ls; Tys ts;
119 for(ls = ((TyCon_RECORDtycon *)((Ty_TYCONty *)_V1)->_1)->_1, ts = ((Ty_TYCONty *)_V1)->_2; ls && ts; ls = ls->_2, ts = ts->_2)
120 { v . add_type(constructor_name,ls->_1, ts->_1,anchor++); }
122 #line 107 "visual2.pcc"
123 } break;
124 default: {
125 L1:;
126 #line 108 "visual2.pcc"
127 v . add_type(constructor_name,0,_V1,anchor);
128 #line 108 "visual2.pcc"
129 } break;
131 } else {
132 switch ((int)((Ty_TYCONty *)_V1)->_1) {
133 case ((int)TUPLEtycon): {
134 #line 101 "visual2.pcc"
135 for_each(Ty, t, ((Ty_TYCONty *)_V1)->_2)
136 { v . add_type(constructor_name,0,t,anchor++); }
137 #line 102 "visual2.pcc"
138 } break;
139 default: { goto L1; } break;
142 } break;
143 default: { goto L1; } break;
145 } else { goto L1; }
147 #line 109 "visual2.pcc"
148 #line 109 "visual2.pcc"
151 v . make_label ();
152 v . end_node (constructor_name);
155 //////////////////////////////////////////////////////////////////////////////
157 // This method adds a type component for a datatype constructor
159 //////////////////////////////////////////////////////////////////////////////
160 void PropVisualizer::add_type(Id cons_name, Id label, Ty ty, int anch)
162 add_label(" ");
163 if (label != 0) add_label("%s : ", label);
164 add_label("%T\n", ty);
166 // Create a has-a edge
168 #line 127 "visual2.pcc"
169 #line 135 "visual2.pcc"
171 Ty _V2 = deref_all(ty);
172 if (_V2) {
173 switch (_V2->tag__) {
174 case a_Ty::tag_TYCONty: {
175 if (boxed(((Ty_TYCONty *)_V2)->_1)) {
176 switch (((Ty_TYCONty *)_V2)->_1->tag__) {
177 case a_TyCon::tag_DATATYPEtycon: {
178 #line 129 "visual2.pcc"
179 // begin_edge(cons_name,id);
180 // color (lightgreen);
181 // anchor(anch);
182 // end_edge(cons_name,id);
184 #line 133 "visual2.pcc"
185 } break;
186 default: {
187 L2:; } break;
189 } else { goto L2; }
190 } break;
191 default: { goto L2; } break;
193 } else { goto L2; }
195 #line 135 "visual2.pcc"
196 #line 135 "visual2.pcc"
199 #line 137 "visual2.pcc"
201 ------------------------------- Statistics -------------------------------
202 Merge matching rules = yes
203 Number of DFA nodes merged = 44
204 Number of ifs generated = 4
205 Number of switches generated = 5
206 Number of labels = 2
207 Number of gotos = 6
208 Adaptive matching = enabled
209 Fast string matching = disabled
210 Inline downcasts = enabled
211 --------------------------------------------------------------------------