not needed
[prop.git] / prop-src / graphrep.cc
blob6d09a071dcedb47767328728c7e6c480a4b67de0
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 "graphrep.pcc".
5 ///////////////////////////////////////////////////////////////////////////////
7 #line 1 "graphrep.pcc"
8 ///////////////////////////////////////////////////////////////////////////////
9 //
10 // This file implements data structure mapping for graph nodes and edges.
12 ///////////////////////////////////////////////////////////////////////////////
13 #include "graphedges.h"
15 ///////////////////////////////////////////////////////////////////////////////
17 // Instantiate the nodes and edges datatypes
19 ///////////////////////////////////////////////////////////////////////////////
20 #line 13 "graphrep.pcc"
21 #line 13 "graphrep.pcc"
22 ///////////////////////////////////////////////////////////////////////////////
24 // Interface specification of datatype List<NodeDef *>
26 ///////////////////////////////////////////////////////////////////////////////
27 #line 13 "graphrep.pcc"
30 ///////////////////////////////////////////////////////////////////////////////
32 // Interface specification of datatype List<EdgeDef *>
34 ///////////////////////////////////////////////////////////////////////////////
35 #line 13 "graphrep.pcc"
38 ///////////////////////////////////////////////////////////////////////////////
40 // Instantiation of datatype List<NodeDef *>
42 ///////////////////////////////////////////////////////////////////////////////
43 #line 13 "graphrep.pcc"
44 #ifdef PROP_EXPLICIT_TEMPLATE_INSTANTIATION
45 template class a_List<NodeDef *>;
46 template a_List<NodeDef *> * list_1_(EdgeDef * x_1, a_List<EdgeDef *> * x_2);
47 template a_List<NodeDef *> * list_1_(EdgeDef * x_list_1_);
48 template int boxed(const a_List<NodeDef *> *);
49 template int untag(const a_List<NodeDef *> *);
50 #endif /* PROP_EXPLICIT_TEMPLATE_INSTANTIATION */
52 ///////////////////////////////////////////////////////////////////////////////
54 // Instantiation of datatype List<EdgeDef *>
56 ///////////////////////////////////////////////////////////////////////////////
57 #line 13 "graphrep.pcc"
58 #ifdef PROP_EXPLICIT_TEMPLATE_INSTANTIATION
59 template class a_List<EdgeDef *>;
60 template a_List<EdgeDef *> * list_1_(NodeDef * x_1, a_List<NodeDef *> * x_2);
61 template a_List<EdgeDef *> * list_1_(NodeDef * x_list_1_);
62 template int boxed(const a_List<EdgeDef *> *);
63 template int untag(const a_List<EdgeDef *> *);
64 #endif /* PROP_EXPLICIT_TEMPLATE_INSTANTIATION */
66 #line 13 "graphrep.pcc"
67 #line 13 "graphrep.pcc"
70 ///////////////////////////////////////////////////////////////////////////////
72 // Constructors for all edge classes
74 ///////////////////////////////////////////////////////////////////////////////
75 MapEdge::MapEdge(GraphTypeDef * G,
76 Id id, NodeDef* a, NodeDef* b, GraphIndexing i, LabTys attribs)
77 : EdgeDef(G,id,a,b,i,attribs) {}
79 MultiMapEdge::MultiMapEdge
80 (GraphTypeDef * G,
81 Id id, NodeDef* a, NodeDef* b, GraphIndexing i, LabTys attribs)
82 : EdgeDef(G,id,a,b,i,attribs) {}
84 BijectionEdge::BijectionEdge
85 (GraphTypeDef * G,
86 Id id, NodeDef* a, NodeDef* b, GraphIndexing i, LabTys attribs)
87 : MapEdge(G,id,a,b,i,attribs) {}
89 EquivRelationEdge::EquivRelationEdge
90 (GraphTypeDef * G,
91 Id id, NodeDef* a, NodeDef* b, GraphIndexing i, LabTys attribs)
92 : MapEdge(G,id,a,b,i,attribs) {}
94 ///////////////////////////////////////////////////////////////////////////////
96 // Method to computing the proper representation for a node
98 ///////////////////////////////////////////////////////////////////////////////
99 void NodeDef::choose_representation()
103 ///////////////////////////////////////////////////////////////////////////////
105 // Methods to computing the proper representation for an edge
107 ///////////////////////////////////////////////////////////////////////////////
108 void EdgeDef::choose_representation()
109 { // If we have f(x) or f{x} then we also have 'x in dom f' for free
110 if (ops & (IMAGEgop | IMAGESETgop))
111 ops |= INDOMgop;
112 if (ops & INDOMgop)
113 ops |= INgop; // x in f
116 void MapEdge::choose_representation()
117 { ops |= IMAGEgop; // f(x)
118 ops |= DOMgop; // dom f
119 ops |= RANgop; // ran f
120 ops |= DOMSIZEgop; // #dom f
121 ops |= RANSIZEgop; // #ran f
122 ops |= UPDATEIMAGEgop; // f(x) := y
123 ops |= SIZEgop; // # f
124 Super::choose_representation();
127 void MultiMapEdge::choose_representation()
128 { ops |= IMAGESETgop; // f{x}
129 ops |= DOMgop; // dom f
130 ops |= DOMSIZEgop; // #dom f
131 ops |= RANSIZEgop; // #ran f
132 ops |= UPDATEIMAGEgop; // f{x} with := y
133 ops |= SIZEgop; // # f
134 Super::choose_representation();
137 void BijectionEdge::choose_representation()
139 Super::choose_representation();
142 void EquivRelationEdge::choose_representation()
144 Super::choose_representation();
147 ///////////////////////////////////////////////////////////////////////////////
149 // Generic method to generate forward declarations for a node object
151 ///////////////////////////////////////////////////////////////////////////////
152 void NodeDef::generate_forward_decls (CodeGen& C)
154 C.pr("%^class %s_%s_node;", graph()->class_name, node_name);
157 ///////////////////////////////////////////////////////////////////////////////
159 // Generic method to generate representation for a node object class.
161 ///////////////////////////////////////////////////////////////////////////////
162 void NodeDef::generate_representation (CodeGen& C)
163 { C.pr("\n"
164 "%^%/"
165 "%^//"
166 "%^// Representation of node %s::%s(%T)"
167 "%^//"
168 "%^%/",
169 graph()->class_name, node_name, node_type
172 C.pr("%^class %s_%s_node {%+"
173 "%^// no copy constructor or assignment"
174 "%^%s_%s_node(const %s_%s_node&);"
175 "%^void operator = (const %s_%s_node&);"
176 "%^%T the_label;"
177 "%-%^public:%+"
178 "%^%T label() const { return the_label; }"
179 "%^operator %T () const { return the_label; }"
180 "%^friend class %s;",
181 graph()->class_name, node_name,
182 graph()->class_name, node_name, graph()->class_name, node_name,
183 graph()->class_name, node_name,
184 node_type, node_type, node_type, graph()->class_name
187 for_each (EdgeDef *, e, graph()->edge_defs)
188 { e->generate_node_representation(C,this);
191 C.pr("%-%^public:%+"
192 "%^%s_%s_node();"
193 "%^~%s_%s_node();"
194 "%-%^};",
195 graph()->class_name, node_name,
196 graph()->class_name, node_name
199 C.pr("\n\n");
202 ///////////////////////////////////////////////////////////////////////////////
204 // Generic method to generate interface for a node object
206 ///////////////////////////////////////////////////////////////////////////////
207 void NodeDef::generate_interface (CodeGen& C)
208 { C.pr("%-%^public:%+"
209 "%^%/"
210 "%^//"
211 "%^// Interface to node %s(%T)"
212 "%^//"
213 "%^%/",
214 node_name, node_type
217 if (node_type == NOty)
219 C.pr("%^// Create a new node; the new node is unique."
220 "%^// The new node is now attached to the graph."
221 "%^virtual %s create_%s();",
222 node_name, node_name
224 } else
226 C.pr("%-%^protected:%+"
227 "%^// HashTable< %T, %s, %s< %T >, %s< %T > > %s_table;"
228 "%-%^public:%+",
229 node_type, node_name, hash_fun, node_type,
230 eq_fun, node_type, node_name
233 C.pr("%^// Create a new node, or lookup an existing node."
234 "%^// The node is now attached to the graph."
235 "%^virtual %s create_%s(%T);"
236 "%^\n"
237 "%^// Lookup a node by its label."
238 "%^// Returns nil if no such node exists."
239 "%^%s lookup_%s(%T) const;"
240 "%^\n"
241 "%^// Does a node of a certain label exists?"
242 "%^Bool has_%s(%T l) const { return lookup_%s(l) != 0; }"
243 "%^\n"
244 "%^// Insert a new node into the graph by label."
245 "%^// A no-op if the graph with the label already exists"
246 "%^%s insert_%s(%T l) { return create_%s(l); }"
247 "%^\n"
248 "%^// Remove a node by label."
249 "%^// Returns true if the graph is changed."
250 "%^Bool remove_%s(%T l) { return remove(lookup_%s(l)); }",
251 node_name, node_name, node_type,
252 node_name, node_name, node_type,
253 node_name, node_type, node_name,
254 node_name, node_name, node_type, node_name,
255 node_name, node_type, node_name
259 C.pr("%^\n"
260 "%^// Insert a node into the graph."
261 "%^// Returns true if the graph is changed."
262 "%^virtual Bool insert(%s);"
263 "%^\n"
264 "%^// Remove a node from the graph."
265 "%^// The node is destroyed."
266 "%^// Returns true if the graph is changed."
267 "%^virtual Bool remove(%s);",
268 node_name, node_name
272 ///////////////////////////////////////////////////////////////////////////////
274 // Generic method to generate the implementation for a node object
276 ///////////////////////////////////////////////////////////////////////////////
277 void NodeDef::generate_implementation (CodeGen& C)
278 { C.pr("%^%/"
279 "%^// Implementation of node %s::%s(%T)"
280 "%^%/",
281 graph()->class_name, node_name, node_type
285 ///////////////////////////////////////////////////////////////////////////////
287 // Generic method to generate representation for an edge within a node
289 ///////////////////////////////////////////////////////////////////////////////
290 void EdgeDef::generate_node_representation (CodeGen& C, NodeDef * n)
291 { if (n != domain_type && n != range_type) return;
292 C.pr("%^struct {%+");
293 if (n == domain_type) generate_dom_rep(C);
294 if (n == range_type) generate_ran_rep(C);
295 C.pr("%-%^} %s;",edge_name);
298 ///////////////////////////////////////////////////////////////////////////////
300 // Generic method to generate representation for an edge within the graph
302 ///////////////////////////////////////////////////////////////////////////////
303 void EdgeDef::generate_edge_representation (CodeGen& C)
304 { generate_edge_rep(C);
307 ///////////////////////////////////////////////////////////////////////////////
309 // Generic method to generate representation for an edge within the graph
311 ///////////////////////////////////////////////////////////////////////////////
312 void EdgeDef::generate_edge_rep (CodeGen& C)
313 { if (ops & SIZEgop) C.pr("%^int count; // number of edges ");
314 if (ops & DOMgop) C.pr("%^GraphType::Link domset; // the domain");
315 if (ops & DOMSIZEgop) C.pr("%^int dom_count; // size of domain");
316 if (ops & RANgop) C.pr("%^GraphType::Link ranset; // the range");
317 if (ops & RANSIZEgop) C.pr("%^int ran_count; // size of range");
320 ///////////////////////////////////////////////////////////////////////////////
322 // Methods to compute the representation
324 ///////////////////////////////////////////////////////////////////////////////
325 void EdgeDef::generate_dom_rep(CodeGen& C)
327 if (ops & DOMgop) C.pr("%^GraphType::Link dom_link;");
330 void EdgeDef::generate_ran_rep(CodeGen& C)
332 if (ops & RANgop)
333 C.pr("%^GraphType::Link ran_link;"
334 "%^int ran_count;");
337 void MapEdge::generate_dom_rep(CodeGen& C)
338 { Super::generate_dom_rep(C);
339 if (ops & IMAGEgop)
340 C.pr("%^%s_%s_node * image;", graph->class_name, range_type->name());
343 void MapEdge::generate_ran_rep(CodeGen& C)
344 { Super::generate_ran_rep(C);
347 void MultiMapEdge::generate_dom_rep(CodeGen& C)
348 { Super::generate_dom_rep(C);
349 if (ops & IMAGESETgop) C.pr("%^GraphType::Link image;");
352 void MultiMapEdge::generate_ran_rep(CodeGen& C)
353 { Super::generate_ran_rep(C);
356 void BijectionEdge::generate_dom_rep(CodeGen& C)
357 { Super::generate_dom_rep(C);
360 void BijectionEdge::generate_ran_rep(CodeGen& C)
361 { Super::generate_ran_rep(C);
364 void EquivRelationEdge::generate_dom_rep(CodeGen& C)
365 { Super::generate_dom_rep(C);
368 void EquivRelationEdge::generate_ran_rep(CodeGen& C)
369 { Super::generate_ran_rep(C);
372 ///////////////////////////////////////////////////////////////////////////////
374 // Generic methods to generate the interface of an edge
376 ///////////////////////////////////////////////////////////////////////////////
377 void EdgeDef::generate_interface (CodeGen& C)
379 if (domain_type == 0 || range_type == 0) return;
382 // Encapsulate all methods to manipulate this edge into an edge record
384 C.pr("%^class %s_record {"
385 "%^protected:%+"
386 "%^friend class %s;",
387 edge_name, graph->class_name);
388 generate_edge_representation(C); // how to represent this edge
389 C.pr("%-%^public:%+");
390 generate_interf(C); // the methods
391 C.pr("%-%^} %s;"
392 "%^", edge_name);
395 ///////////////////////////////////////////////////////////////////////////////
397 // Methods to generate the interface of an edge
399 ///////////////////////////////////////////////////////////////////////////////
400 void EdgeDef::generate_interf (CodeGen& C)
402 if (ops & DOMgop) gen_dom(C); // dom f
403 if (ops & RANgop) gen_ran(C); // ran f
404 if (ops & INDOMgop) gen_in_dom(C); // x in dom f
405 if (ops & INRANgop) gen_in_ran(C); // x in ran f
406 if (ops & INgop) gen_in(C); // x in f
407 if (ops & SIZEgop) gen_size(C); // size of relation
408 if (ops & DOMSIZEgop) gen_dom_size(C); // size of domain
409 if (ops & RANSIZEgop) gen_ran_size(C); // size of range
410 if (ops & (IMAGEgop | IMAGESETgop)) gen_image(C); // f(x) or f{x}
411 if (ops & UPDATEIMAGEgop) gen_update_image(C); // f(x) := y or f{x} with := y
414 void MapEdge::generate_interf(CodeGen& C)
415 { Super::generate_interf(C);
418 void MultiMapEdge::generate_interf(CodeGen& C)
419 { Super::generate_interf(C);
422 void BijectionEdge::generate_interf(CodeGen& C)
423 { Super::generate_interf(C);
426 void EquivRelationEdge::generate_interf(CodeGen& C)
427 { Super::generate_interf(C);
430 ///////////////////////////////////////////////////////////////////////////////
432 // Generic methods to generate the implementation of an edge
434 ///////////////////////////////////////////////////////////////////////////////
435 void EdgeDef::generate_implementation (CodeGen& C)
437 generate_impl(C);
440 ///////////////////////////////////////////////////////////////////////////////
442 // Methods to generate the implementation
444 ///////////////////////////////////////////////////////////////////////////////
445 void EdgeDef::generate_impl(CodeGen& C)
449 void MapEdge::generate_impl(CodeGen& C)
450 { Super::generate_impl(C);
453 void MultiMapEdge::generate_impl(CodeGen& C)
454 { Super::generate_impl(C);
457 void BijectionEdge::generate_impl(CodeGen& C)
458 { Super::generate_impl(C);
461 void EquivRelationEdge::generate_impl(CodeGen& C)
462 { Super::generate_impl(C);
464 #line 409 "graphrep.pcc"
466 ------------------------------- Statistics -------------------------------
467 Merge matching rules = yes
468 Number of DFA nodes merged = 0
469 Number of ifs generated = 0
470 Number of switches generated = 0
471 Number of labels = 0
472 Number of gotos = 0
473 Adaptive matching = enabled
474 Fast string matching = disabled
475 Inline downcasts = enabled
476 --------------------------------------------------------------------------