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.pcc".
5 ///////////////////////////////////////////////////////////////////////////////
7 #line 1 "graphtype.pcc"
8 ///////////////////////////////////////////////////////////////////////////////
10 // This file implements the graph type generator
12 ///////////////////////////////////////////////////////////////////////////////
15 #include "graphtype.h"
18 ///////////////////////////////////////////////////////////////////////////////
20 // Method to create a graph type definition.
22 ///////////////////////////////////////////////////////////////////////////////
23 GraphTypeDef::GraphTypeDef
24 (Id id
, Inherits i
, TyQual q
, NodeDefs nodes
, EdgeDefs edges
, Decls b
)
25 : ClassDefinition(GRAPHTYPE_CLASS
, id
,
26 #line 18 "graphtype.pcc"
27 #line 18 "graphtype.pcc"
29 #line 18 "graphtype.pcc"
30 #line 18 "graphtype.pcc"
32 add_inherit("GraphType",
33 #line 19 "graphtype.pcc"
34 #line 19 "graphtype.pcc"
36 #line 19 "graphtype.pcc"
37 #line 19 "graphtype.pcc"
38 ,i
,PUBLICscope
,QUALvirtualdestr
), q
, b
),
39 node_defs(nodes
), edge_defs(edges
)
41 #line 21 "graphtype.pcc"
42 #line 21 "graphtype.pcc"
44 #line 21 "graphtype.pcc"
45 #line 21 "graphtype.pcc"
46 , TYCONty(GRAPHtycon(this),
47 #line 21 "graphtype.pcc"
48 #line 21 "graphtype.pcc"
50 #line 21 "graphtype.pcc"
51 #line 21 "graphtype.pcc"
54 GraphTypeDef::~GraphTypeDef() {}
56 ///////////////////////////////////////////////////////////////////////////////
58 // Method to create a node type definition.
60 ///////////////////////////////////////////////////////////////////////////////
61 NodeDef::NodeDef(GraphTypeDef
* g
, Id id
, Ty ty
,
62 Id hash
, Id eq
, LabTys attribs
)
63 : G(g
), node_name(id
), node_type(ty
), hash_fun(hash
), eq_fun(eq
),
64 attributes(attribs
), rep(UNBASEDrep
)
65 { if (hash_fun
== 0) hash_fun
= "hash";
66 if (eq_fun
== 0) eq_fun
= "equal";
68 NodeDef::~NodeDef() {}
70 ///////////////////////////////////////////////////////////////////////////////
72 // Method to create an edge type definition.
74 ///////////////////////////////////////////////////////////////////////////////
75 EdgeDef::EdgeDef(GraphTypeDef
* G
,
76 Id id
, NodeDef
* a
, NodeDef
* b
,
77 GraphIndexing i
, LabTys attribs
)
78 : graph(G
), edge_name(id
), domain_type(a
), range_type(b
), indexing(i
),
79 attributes(attribs
), ops(NOgop
)
82 EdgeDef::~EdgeDef() {}
84 void GraphTypeDef::set_nodes(NodeDefs n
) { node_defs
= n
; }
85 void GraphTypeDef::set_edges(EdgeDefs e
) { edge_defs
= e
; }
86 void GraphTypeDef::set_body(Decls b
) { class_body
= b
; }
88 ///////////////////////////////////////////////////////////////////////////////
90 // Method to lookup a node definition by name
92 ///////////////////////////////////////////////////////////////////////////////
93 NodeDef
* GraphTypeDef::lookup_node (Id id
)
94 { for_each (NodeDef
*, n
, node_defs
)
96 if (n
->node_name
== id
) return n
;
98 error("%Lnode %s is not defined in graphtype %s\n", id
, class_name
);
102 ///////////////////////////////////////////////////////////////////////////////
104 // Method to lookup an edge definition by name
106 ///////////////////////////////////////////////////////////////////////////////
107 EdgeDef
* GraphTypeDef::lookup_edge (Id id
)
108 { for_each (EdgeDef
*, e
, edge_defs
)
110 if (e
->edge_name
== id
) return e
;
112 error("%Ledge %s is not defined in graphtype %s\n", id
, class_name
);
116 ///////////////////////////////////////////////////////////////////////////////
118 // Method to choose a representation for the graph type.
120 ///////////////////////////////////////////////////////////////////////////////
121 void GraphTypeDef::choose_representation()
122 { for_each(EdgeDef
*, e
, edge_defs
)
123 e
->choose_representation();
124 for_each(NodeDef
*, n
, node_defs
)
125 n
->choose_representation();
128 ///////////////////////////////////////////////////////////////////////////////
130 // Method to generate the graph type internals.
132 ///////////////////////////////////////////////////////////////////////////////
133 void GraphTypeDef::gen_class_predefinition (CodeGen
& C
)
135 choose_representation();
139 "%^// Internal representation of nodes in graphtype %s"
144 ////////////////////////////////////////////////////////////////////////////
146 // Generate any forward declarations from the node definitions
148 ////////////////////////////////////////////////////////////////////////////
149 { for_each(NodeDef
*, n
, node_defs
)
150 n
->generate_forward_decls(C
);
153 ////////////////////////////////////////////////////////////////////////////
155 // Generate the representation for the nodes
157 ////////////////////////////////////////////////////////////////////////////
158 { for_each(NodeDef
*, n
, node_defs
)
159 n
->generate_representation(C
);
164 "%^// Definition of graphtype %s"
170 ///////////////////////////////////////////////////////////////////////////////
172 // Method to generate the interface methods
174 ///////////////////////////////////////////////////////////////////////////////
175 void GraphTypeDef::gen_class_interface (CodeGen
& C
)
177 ////////////////////////////////////////////////////////////////////////////
179 // Generate forward type definitions
181 ////////////////////////////////////////////////////////////////////////////
182 { C
.pr("%-%^public:%+");
183 for_each(NodeDef
*, n
, node_defs
)
184 { C
.pr("%^typedef %s_%s_node * %s;"
187 "%^ friend class %s_iterator;"
188 "%^ const GraphType::Link& link;"
190 "%^ %s_set(const GraphType::Link& l, long n = 0)"
191 "%^ : link(l), offset(n) {}"
192 "%^ Bool is_empty() const { return link.is_empty(); }"
193 "%^ operator Bool () const { return link.is_empty(); }"
195 "%^class %s_iterator {"
197 "%^ const GraphType::Link * cursor, * sentinel;"
199 "%^ %s_iterator(const %s_set& s) : "
200 "%^ offset(s.offset), cursor(s.link.next),"
201 "%^ sentinel(&s.link) {}"
202 "%^ operator Bool () const { return cursor != sentinel; }"
203 "%^ %s operator * () const"
204 "%^ { return (%s)(((char *)cursor) - offset); }"
205 "%^ %s operator -> () const"
206 "%^ { return (%s)(((char *)cursor) - offset); }"
207 "%^ void operator ++ () { cursor = cursor->next; }"
208 "%^ void operator ++ (int) { cursor = cursor->next; }"
210 class_name
, n
->name(), n
->name(),
211 n
->name(), n
->name(),
212 n
->name(), n
->name(),
213 n
->name(), n
->name(),
214 n
->name(), n
->name(),
220 ////////////////////////////////////////////////////////////////////////////
222 // Generate the interface methods for the nodes
224 ////////////////////////////////////////////////////////////////////////////
225 { for_each(NodeDef
*, n
, node_defs
)
226 n
->generate_interface(C
);
229 ////////////////////////////////////////////////////////////////////////////
230 // Generate the interface methods for the edges
231 ////////////////////////////////////////////////////////////////////////////
232 { for_each(EdgeDef
*, e
, edge_defs
)
233 e
->generate_interface(C
);
237 ///////////////////////////////////////////////////////////////////////////////
239 // Method to generate the graph type implementation.
241 ///////////////////////////////////////////////////////////////////////////////
242 void GraphTypeDef::gen_class_implementation (CodeGen
& C
)
250 void GraphTypeDef::gen_init_graph (CodeGen
& C
) {}
251 void GraphTypeDef::gen_lookup_node (CodeGen
& C
) {}
252 void GraphTypeDef::gen_insert_node (CodeGen
& C
) {}
253 void GraphTypeDef::gen_remove_node (CodeGen
& C
) {}
254 #line 223 "graphtype.pcc"
256 ------------------------------- Statistics -------------------------------
257 Merge matching rules = yes
258 Number of DFA nodes merged = 0
259 Number of ifs generated = 0
260 Number of switches generated = 0
263 Adaptive matching = enabled
264 Fast string matching = disabled
265 Inline downcasts = enabled
266 --------------------------------------------------------------------------