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 ///////////////////////////////////////////////////////////////////////////////
8 //////////////////////////////////////////////////////////////////////////////
10 // This file implements the datatype definitions layout generator
11 // for visualizing datatype definitions using vcg.
13 //////////////////////////////////////////////////////////////////////////////
14 #include <AD/strings/quark.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
);
34 for (HashTable::Entry
* e
= ClassDefinition::defined_classes
.first();
35 e
!= 0; e
= ClassDefinition::defined_classes
.next(e
))
37 ClassDefinition
* C
= (ClassDefinition
*)(e
->v
);
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
);
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
);
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
);
77 v
. end_node(c
->name
);
79 v
. begin_edge(datatype_name
, c
->name
);
80 v
. color (VCG::darkblue
);
81 v
. arrowcolor (VCG::red
);
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
107 #line 99 "visual2.pcc"
108 #line 108 "visual2.pcc"
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"
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"
126 #line 108 "visual2.pcc"
127 v
. add_type(constructor_name
,0,_V1
,anchor
);
128 #line 108 "visual2.pcc"
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"
139 default: { goto L1
; } break;
143 default: { goto L1
; } break;
147 #line 109 "visual2.pcc"
148 #line 109 "visual2.pcc"
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
)
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
);
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);
182 // end_edge(cons_name,id);
184 #line 133 "visual2.pcc"
191 default: { goto L2
; } break;
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
208 Adaptive matching = enabled
209 Fast string matching = disabled
210 Inline downcasts = enabled
211 --------------------------------------------------------------------------