with debug
[prop.git] / prop-src / graphops.cc
blob6d7995453ea20116803f58f04b019269790bfbb9
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 "graphops.pcc".
5 ///////////////////////////////////////////////////////////////////////////////
7 #line 1 "graphops.pcc"
8 ///////////////////////////////////////////////////////////////////////////////
9 //
10 // This file implements the low level graph operators.
11 // We assume that these functions are called only if the appropriate
12 // representations are defined.
14 ///////////////////////////////////////////////////////////////////////////////
16 #include "graphtype.h"
17 #include "graphedges.h"
19 ///////////////////////////////////////////////////////////////////////////////
21 // Return the domain set as a doubly linked list
23 ///////////////////////////////////////////////////////////////////////////////
24 void EdgeDef::gen_dom (CodeGen& C) // dom f
26 C.pr("%^%s_set domain() const { return %s_set(domset); }",
27 domain_type->name(), domain_type->name());
30 ///////////////////////////////////////////////////////////////////////////////
32 // Return the range set as a doubly linked list
34 ///////////////////////////////////////////////////////////////////////////////
35 void EdgeDef::gen_ran (CodeGen& C) // ran f
37 C.pr("%^%s_set range() const { return %s_set(ranset); }",
38 range_type->name(), range_type->name());
42 ///////////////////////////////////////////////////////////////////////////////
44 // Test if an element is defined in the domain
46 ///////////////////////////////////////////////////////////////////////////////
47 void EdgeDef::gen_in_dom (CodeGen& C) // x in dom f
48 { C.pr("%^Bool domain_has (%s x) const"
49 "%^ { return x->%s.dom_link.non_nil(); }",
50 domain_type->name(), edge_name
54 void MapEdge::gen_in_dom (CodeGen& C) // x in dom f
55 { if (ops & DOMgop) { Super::gen_in_dom(C); return; }
56 C.pr("%^Bool domain_has (%s x) const"
57 "%^ { return x->%s.image != 0; }",
58 domain_type->name(), edge_name
59 );
62 void MultiMapEdge::gen_in_dom (CodeGen& C) // x in dom f
63 { if (ops & DOMgop) { Super::gen_in_dom(C); return; }
64 C.pr("%^Bool domain_has (%s x) const"
65 "%^ { return ! x->%s.image.is_empty(); }",
66 domain_type->name(), edge_name
67 );
70 ///////////////////////////////////////////////////////////////////////////////
72 // Test if an element is defined in the range
74 ///////////////////////////////////////////////////////////////////////////////
75 void EdgeDef::gen_in_ran (CodeGen& C) // x in ran f
77 C.pr("%^Bool range_has (%s x) const"
78 "%^ { return x->%s.coimage != 0; }",
79 range_type->name(), edge_name
83 ///////////////////////////////////////////////////////////////////////////////
85 // Test if a pair is defined
87 ///////////////////////////////////////////////////////////////////////////////
88 void MapEdge::gen_in (CodeGen& C) // x in f
89 { C.pr("%^Bool has (%s x, %s y) const"
90 "%^ { return x->%s.image && x->%s.image == y; }",
91 domain_type->name(), range_type->name(),
92 edge_name, edge_name
96 void MultiMapEdge::gen_in (CodeGen& C) // x in f
97 { C.pr("%^Bool has (%s x, %s y) const"
98 "%^ { return false; }",
99 domain_type->name(), range_type->name()
103 ///////////////////////////////////////////////////////////////////////////////
105 // Return the cardinality of a relation
107 ///////////////////////////////////////////////////////////////////////////////
108 void EdgeDef::gen_size (CodeGen& C) // # f
110 C.pr("%^int size () const { return count; }");
113 ///////////////////////////////////////////////////////////////////////////////
115 // Return the cardinality of the domain
117 ///////////////////////////////////////////////////////////////////////////////
118 void EdgeDef::gen_dom_size (CodeGen& C) // # dom f
120 C.pr("%^int domain_size () const { return dom_count; }");
123 ///////////////////////////////////////////////////////////////////////////////
125 // Return the cardinality of the range
127 ///////////////////////////////////////////////////////////////////////////////
128 void EdgeDef::gen_ran_size (CodeGen& C) // # ran f
130 C.pr("%^int range_size () const { return ran_count; }");
133 ///////////////////////////////////////////////////////////////////////////////
135 // Return the image or image set
137 ///////////////////////////////////////////////////////////////////////////////
138 void EdgeDef::gen_image (CodeGen& C) // f(x) or f{x}
139 { bug("%Limage operation is undefined for edge %s", edge_name);
142 void MapEdge::gen_image (CodeGen& C) // f(x)
143 { C.pr("%^%s operator () (%s x) const"
144 "%^ { return x->%s.image; }",
145 range_type->name(), domain_type->name(), edge_name
149 void MultiMapEdge::gen_image (CodeGen& C) // f{x}
150 { C.pr("%^%s_set operator () (%s x) const"
151 "%^ { return %s_set(x->%s.image); }",
152 range_type->name(), domain_type->name(),
153 range_type->name(), edge_name
157 ///////////////////////////////////////////////////////////////////////////////
159 // Update the image or image set
161 ///////////////////////////////////////////////////////////////////////////////
162 void EdgeDef::gen_update_image (CodeGen& C) // f(x) or f{x}
163 { bug("%Limage operation is undefined for edge %s", edge_name);
166 void MapEdge::gen_update_image (CodeGen& C) // f(x)
167 { C.pr("%^Bool update(%s x, %s y)%^{%+",
168 domain_type->name(), range_type->name());
170 // If the edge is already there do nothing
171 C.pr("%^%s z = x->%s.image;"
172 "%^if (z == y) return false;",
173 range_type->name(), edge_name);
175 C.pr("%^if (z)"
176 "%^{%+");
178 // f(x) was defined
180 if (ops & RANgop)
181 { // Update the range set; remove the old element
182 C.pr("%^if(--z->%s.ran_count == 0)"
183 "%^{ z->%s.ran_link.unlink();",
184 edge_name, edge_name);
185 if (ops & RANSIZEgop) C.pr("%^ --ran_count;");
186 C.pr("%^}");
189 C.pr("%-%^}%^else%^{%+");
191 // f(x) was undefined
193 if (ops & SIZEgop) C.pr("%^++count;"); // a new edge is added
194 if (ops & DOMSIZEgop) C.pr("%^++dom_count;"); // a new domain element
195 if (ops & DOMgop) // link the new element
196 C.pr("%^domset.link(x->%s.dom_link);", edge_name);
198 C.pr("%-%^}");
200 // f(x) := y
202 C.pr("%^x->%s.image = y;", edge_name);
204 if (ops & RANgop)
205 { // Update the new range set
206 C.pr("%^if (++y->%s.ran_count == 1)"
207 "%^{ ranset.link(y->%s.ran_link);",
208 edge_name, edge_name);
209 if (ops & RANSIZEgop) C.pr("%^ ++ran_count;");
210 C.pr("%^}");
213 // The graph has changed
215 C.pr("%^return true;"
216 "%-%^}");
219 void MultiMapEdge::gen_update_image (CodeGen& C) // f(x)
220 { C.pr("%^Bool update(%s x, const %s_set& y)"
221 "%^ { x->%s.image = y.link; }",
222 domain_type->name(), range_type->name(), edge_name
225 #line 218 "graphops.pcc"
227 ------------------------------- Statistics -------------------------------
228 Merge matching rules = yes
229 Number of DFA nodes merged = 0
230 Number of ifs generated = 0
231 Number of switches generated = 0
232 Number of labels = 0
233 Number of gotos = 0
234 Adaptive matching = enabled
235 Fast string matching = disabled
236 Inline downcasts = enabled
237 --------------------------------------------------------------------------