1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
|
// file : CCF/IDL2/SyntaxTree/Translation.hpp
// author : Boris Kolpackov <boris@dre.vanderbilt.edu>
// cvs-id : $id$
#ifndef CCF_IDL2_SYNTAX_TREE_TRANSLATION_HPP
#define CCF_IDL2_SYNTAX_TREE_TRANSLATION_HPP
#include "CCF/IDL2/SyntaxTree/Elements.hpp"
namespace CCF
{
namespace IDL2
{
namespace SyntaxTree
{
//
//
//
class FileScope : public virtual Scope
{
public:
virtual
~FileScope () throw () {}
FileScope (DeclarationTable& table, Order const& order);
virtual ScopePtr
scope () const throw (NotInScope)
{
throw NotInScope ();
}
// Runtime declaration type information
public:
virtual std::string
declaration_class ()
{
return "file scope";
}
public:
static Introspection::TypeInfo const&
static_type_info ();
};
typedef
StrictPtr<FileScope>
FileScopePtr;
typedef
DeclarationOrderComparator<FileScopePtr>
FileScopeOrderComparator;
typedef
std::set<FileScopePtr, FileScopeOrderComparator>
FileScopeSet;
//
//
//
class TranslationRegion;
typedef
StrictPtr<TranslationRegion>
TranslationRegionPtr;
typedef
std::vector<TranslationRegionPtr>
TranslationRegionList;
class TranslationRegion : public virtual Node
{
public:
virtual
~TranslationRegion () throw () {}
TranslationRegion (fs::path const& file_path,
DeclarationTable& table,
Order const& order)
: order_ (order),
table_ (table),
next_order_ (0),
file_path_ (file_path)
{
type_info (static_type_info ());
scope_ = FileScopePtr (new FileScope (table_, Order (order_, 1)));
//@@ eh!
table.insert (scope_);
}
public:
DeclarationTable const&
table () const
{
return table_;
}
DeclarationTable&
table ()
{
return table_;
}
public:
Order
create_order ()
{
return Order (Order (order_, 0), next_order_++);
}
public:
FileScopePtr
scope ()
{
return scope_;
}
public:
virtual fs::path
file_path () const
{
return file_path_;
}
public:
class InvalidArgument {};
void
insert (TranslationRegionPtr const& tr) throw (InvalidArgument);
typedef
TranslationRegionList::const_iterator
Iterator;
Iterator
begin () const;
Iterator
end () const;
public:
static Introspection::TypeInfo const&
static_type_info ();
private:
Order order_;
FileScopePtr scope_;
DeclarationTable& table_;
unsigned long next_order_;
TranslationRegionList region_list_;
fs::path file_path_;
};
//
//
//
class IncludeTranslationRegion : public virtual TranslationRegion
{
public:
virtual
~IncludeTranslationRegion () throw () {}
IncludeTranslationRegion (fs::path const& file_path,
DeclarationTable& table,
Order const& order)
: TranslationRegion (file_path, table, order)
{
type_info (static_type_info ());
}
public:
static Introspection::TypeInfo const&
static_type_info ();
};
typedef
StrictPtr<IncludeTranslationRegion>
IncludeTranslationRegionPtr;
//
//
//
class UserIncludeTranslationRegion :
public virtual IncludeTranslationRegion
{
public:
virtual
~UserIncludeTranslationRegion () throw () {}
UserIncludeTranslationRegion (fs::path const& file_path,
DeclarationTable& table,
Order const& order)
: TranslationRegion (file_path, table, order),
IncludeTranslationRegion (file_path, table, order)
{
type_info (static_type_info ());
}
public:
static Introspection::TypeInfo const&
static_type_info ();
};
typedef
StrictPtr<UserIncludeTranslationRegion>
UserIncludeTranslationRegionPtr;
//
//
//
class SysIncludeTranslationRegion :
public virtual IncludeTranslationRegion
{
public:
virtual
~SysIncludeTranslationRegion () throw () {}
SysIncludeTranslationRegion (fs::path const& file_path,
DeclarationTable& table,
Order const& order)
: TranslationRegion (file_path, table, order),
IncludeTranslationRegion (file_path, table, order)
{
type_info (static_type_info ());
}
public:
static Introspection::TypeInfo const&
static_type_info ();
};
typedef
StrictPtr<SysIncludeTranslationRegion>
SysIncludeTranslationRegionPtr;
//
//
//
class ImpliedIncludeTranslationRegion :
public virtual IncludeTranslationRegion
{
public:
virtual
~ImpliedIncludeTranslationRegion () throw () {}
ImpliedIncludeTranslationRegion (fs::path const& file_path,
DeclarationTable& table,
Order const& order)
: TranslationRegion (file_path, table, order),
IncludeTranslationRegion (file_path, table, order)
{
type_info (static_type_info ());
}
public:
static Introspection::TypeInfo const&
static_type_info ();
};
typedef
StrictPtr<ImpliedIncludeTranslationRegion>
ImpliedIncludeTranslationRegionPtr;
//
//
//
class PrincipalTranslationRegion : public virtual TranslationRegion
{
public:
virtual
~PrincipalTranslationRegion () throw () {}
PrincipalTranslationRegion (fs::path const& file_path,
DeclarationTable& table,
Order const& order)
: TranslationRegion (file_path, table, order)
{
type_info (static_type_info ());
}
public:
static Introspection::TypeInfo const&
static_type_info ();
};
typedef
StrictPtr<PrincipalTranslationRegion>
PrincipalTranslationRegionPtr;
//
//
//
class TranslationUnit : public virtual Node
{
public:
virtual
~TranslationUnit () throw () {}
TranslationUnit ()
: order_ (0),
next_order_ (0)
{
type_info (static_type_info ());
}
public:
DeclarationTable const&
table () const
{
return table_;
}
DeclarationTable&
table ()
{
return table_;
}
public:
Order
create_order ()
{
return Order (order_, next_order_++);
}
public:
class InvalidArgument {};
void
insert (TranslationRegionPtr const& tr) throw (InvalidArgument);
typedef
TranslationRegionList::const_iterator
Iterator;
Iterator
begin () const;
Iterator
end () const;
class NotFound {};
PrincipalTranslationRegionPtr
principal_translation_region () const throw (NotFound)
{
for (Iterator i = begin (); i != end (); i++)
{
if ((*i)->is_a<PrincipalTranslationRegion> ())
{
return (*i)->dynamic_type<PrincipalTranslationRegion> ();
}
}
throw NotFound ();
}
private:
Order order_;
DeclarationTable table_;
unsigned long next_order_;
TranslationRegionList region_list_;
public:
static Introspection::TypeInfo const&
static_type_info ();
};
typedef
StrictPtr<TranslationUnit>
TranslationUnitPtr;
}
}
}
#endif // CCF_IDL2_SYNTAX_TREE_TRANSLATION_HPP
|