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 "graphtype.ph".
5 ///////////////////////////////////////////////////////////////////////////////
8 ///////////////////////////////////////////////////////////////////////////////
10 // This file implements the graph type generator
12 ///////////////////////////////////////////////////////////////////////////////
13 #ifndef graph_type_generator_h
14 #define graph_type_generator_h
22 ///////////////////////////////////////////////////////////////////////////////
24 // Forward type definitions
26 ///////////////////////////////////////////////////////////////////////////////
31 #line 24 "graphtype.ph"
32 #line 26 "graphtype.ph"
33 ///////////////////////////////////////////////////////////////////////////////
34 // Definition of type NodeDefs
35 ///////////////////////////////////////////////////////////////////////////////
36 #line 24 "graphtype.ph"
37 typedef a_List
<NodeDef
*> * NodeDefs
;
39 ///////////////////////////////////////////////////////////////////////////////
40 // Definition of type EdgeDefs
41 ///////////////////////////////////////////////////////////////////////////////
42 #line 25 "graphtype.ph"
43 typedef a_List
<EdgeDef
*> * EdgeDefs
;
45 #line 26 "graphtype.ph"
46 #line 26 "graphtype.ph"
49 ///////////////////////////////////////////////////////////////////////////////
51 // Indexing options of graph types
53 ///////////////////////////////////////////////////////////////////////////////
55 DOMindex
= 1<<0, // index on domain
56 RANindex
= 1<<1, // index on range
57 COUNTindex
= 1<<2, // counting index
58 FORWARDindex
= 1<<3, // map from domain to range
59 INVERSEindex
= 1<<4, // map from range to domain
60 BITMAPindex
= 1<<5, // use bitmaps to represent index
61 UNIONFINDindex
= 1<<6 // use union/find to represent index
64 enum { UNBASEDrep
= 0, // unbased
65 WEAKLYBASEDrep
= 1<<1, // weakly based
66 STRONGLYBASEDrep
= 1<<2, // strongly based
67 TABLEDrep
= 1<<3 // also allow address arithmetic on base
70 enum { NOgop
= 0, // no operations
71 SIZEgop
= 1<<0, // # f
72 DOMgop
= 1<<1, // dom f
73 RANgop
= 1<<2, // ran f
74 DOMSIZEgop
= 1<<3, // # dom f
75 RANSIZEgop
= 1<<4, // # ran f
76 IMAGEgop
= 1<<5, // f(x)
77 IMAGESETgop
= 1<<6, // f{x}
78 REVIMAGEgop
= 1<<7, // (inv f)(x)
79 REVIMAGEMAPgop
= 1<<8, // (inv f){x}
80 UNIONgop
= 1<<9, // f union := g
81 BITSETgop
= 1<<10, // bitvector operations
82 UNIONFINDgop
= 1<<11, // union find operations
83 INDOMgop
= 1<<12, // x in dom f
84 INRANgop
= 1<<13, // x in ran f
85 INgop
= 1<<14, // x in f
86 UPDATEIMAGEgop
= 1<<15 // f(x) := y or f{x} with := y
89 #line 68 "graphtype.ph"
90 #line 68 "graphtype.ph"
91 ///////////////////////////////////////////////////////////////////////////////
92 // Definition of type GraphIndexing
93 ///////////////////////////////////////////////////////////////////////////////
94 #line 68 "graphtype.ph"
95 typedef int GraphIndexing
;
97 #line 68 "graphtype.ph"
98 #line 68 "graphtype.ph"
100 #line 69 "graphtype.ph"
101 #line 69 "graphtype.ph"
102 ///////////////////////////////////////////////////////////////////////////////
103 // Definition of type GraphOps
104 ///////////////////////////////////////////////////////////////////////////////
105 #line 69 "graphtype.ph"
106 typedef int GraphOps
;
108 #line 69 "graphtype.ph"
109 #line 69 "graphtype.ph"
111 #line 70 "graphtype.ph"
112 #line 70 "graphtype.ph"
113 ///////////////////////////////////////////////////////////////////////////////
114 // Definition of type GraphRep
115 ///////////////////////////////////////////////////////////////////////////////
116 #line 70 "graphtype.ph"
117 typedef int GraphRep
;
119 #line 70 "graphtype.ph"
120 #line 70 "graphtype.ph"
123 ///////////////////////////////////////////////////////////////////////////////
125 // Class to represent a graph type definition.
127 ///////////////////////////////////////////////////////////////////////////////
128 class GraphTypeDef
: public ClassDefinition
129 { GraphTypeDef(const GraphTypeDef
&);
130 void operator = (const GraphTypeDef
&);
132 friend class NodeDef
;
133 friend class EdgeDef
;
137 GraphTypeDef(Id name
, Inherits
, TyQual
,
139 #line 87 "graphtype.ph"
140 #line 87 "graphtype.ph"
142 #line 87 "graphtype.ph"
143 #line 87 "graphtype.ph"
145 #line 87 "graphtype.ph"
146 #line 87 "graphtype.ph"
148 #line 87 "graphtype.ph"
149 #line 87 "graphtype.ph"
151 #line 87 "graphtype.ph"
152 #line 87 "graphtype.ph"
154 #line 87 "graphtype.ph"
155 #line 87 "graphtype.ph"
157 virtual ~GraphTypeDef();
159 virtual NodeDef
* lookup_node (Id
);
160 virtual EdgeDef
* lookup_edge (Id
);
161 virtual void choose_representation();
162 virtual void print_report(CodeGen
&);
163 void set_nodes (NodeDefs
);
164 void set_edges (EdgeDefs
);
165 void set_body (Decls
);
167 virtual void gen_class_predefinition (CodeGen
&);
168 virtual void gen_class_interface (CodeGen
&);
169 virtual void gen_class_implementation (CodeGen
&);
170 void gen_init_graph(CodeGen
&);
171 void gen_lookup_node(CodeGen
&);
172 void gen_insert_node(CodeGen
&);
173 void gen_remove_node(CodeGen
&);
176 ///////////////////////////////////////////////////////////////////////////////
178 // Class to represent a node definition.
180 ///////////////////////////////////////////////////////////////////////////////
181 class NodeDef
: public Loc
182 { NodeDef(const NodeDef
&);
183 void operator = (const NodeDef
&);
185 friend class GraphTypeDef
;
186 friend class EdgeDef
;
187 GraphTypeDef
* G
; // the parent graph
188 Id node_name
; // name of this node
189 Ty node_type
; // node label is a value from this type
190 Id hash_fun
; // hash function
191 Id eq_fun
; // equality function
192 LabTys attributes
; // additional attributes
193 GraphRep rep
; // representation of this domain
195 NodeDef(GraphTypeDef
*, Id
, Ty
= NOty
, Id
= 0, Id
= 0, LabTys
=
196 #line 126 "graphtype.ph"
197 #line 126 "graphtype.ph"
199 #line 126 "graphtype.ph"
200 #line 126 "graphtype.ph"
204 inline Id
name () const { return node_name
; }
205 inline GraphTypeDef
* graph () const { return G
; }
206 virtual void choose_representation();
207 virtual void generate_forward_decls (CodeGen
&);
208 virtual void generate_representation (CodeGen
&);
209 virtual void generate_interface (CodeGen
&);
210 virtual void generate_implementation (CodeGen
&);
211 virtual void print_report(CodeGen
&);
214 ///////////////////////////////////////////////////////////////////////////////
216 // Class to represent an edge definition.
218 ///////////////////////////////////////////////////////////////////////////////
219 class EdgeDef
: public Loc
220 { EdgeDef(const EdgeDef
&);
221 void operator = (const EdgeDef
&);
223 friend class GraphTypeDef
;
224 friend class NodeDef
;
225 GraphTypeDef
* graph
; // our graph
226 Id edge_name
; // name of this edge
227 NodeDef
* domain_type
; // domain of this type
228 NodeDef
* range_type
; // range of this type
229 GraphIndexing indexing
; // indexing information
230 LabTys attributes
; // additional attributes
231 GraphOps ops
; // defined operations
234 EdgeDef(GraphTypeDef
*, Id
, NodeDef
*, NodeDef
*,
235 GraphIndexing
, LabTys
=
236 #line 160 "graphtype.ph"
237 #line 160 "graphtype.ph"
239 #line 160 "graphtype.ph"
240 #line 160 "graphtype.ph"
245 inline Id
name () const { return edge_name
; }
246 virtual void choose_representation ();
247 virtual void generate_node_representation (CodeGen
&, NodeDef
*);
248 virtual void generate_edge_representation (CodeGen
&);
249 virtual void generate_interface (CodeGen
&);
250 virtual void generate_implementation (CodeGen
&);
251 virtual void print_report(CodeGen
&);
255 virtual void generate_edge_rep(CodeGen
&);
256 virtual void generate_dom_rep (CodeGen
&);
257 virtual void generate_ran_rep (CodeGen
&);
258 virtual void generate_interf (CodeGen
&);
259 virtual void generate_impl (CodeGen
&);
261 ////////////////////////////////////////////////////////////////////////////
263 // Methods to generate various methods to implement various set operations
265 ////////////////////////////////////////////////////////////////////////////
266 virtual void gen_dom (CodeGen
&); // dom f
267 virtual void gen_ran (CodeGen
&); // ran f
268 virtual void gen_in_dom (CodeGen
&); // x in dom f
269 virtual void gen_in_ran (CodeGen
&); // x in ran f
270 virtual void gen_in (CodeGen
&) = 0; // x in f
271 virtual void gen_size (CodeGen
&); // # f
272 virtual void gen_dom_size (CodeGen
&); // # dom f
273 virtual void gen_ran_size (CodeGen
&); // # ran f
274 virtual void gen_image (CodeGen
&); // f(x) or f{x}
275 virtual void gen_update_image(CodeGen
&); // f(x) := y or f{x} with := y
279 #line 198 "graphtype.ph"
281 ------------------------------- Statistics -------------------------------
282 Merge matching rules = yes
283 Number of DFA nodes merged = 0
284 Number of ifs generated = 0
285 Number of switches generated = 0
288 Adaptive matching = enabled
289 Fast string matching = disabled
290 Inline downcasts = enabled
291 --------------------------------------------------------------------------