46
* \param a The keyword 'advice'.
47
* \param p The pointcut expression.
48
* \param c The colon before the advice declaration.
49
* \param d The advice declaration. */
34
50
CT_AdviceDecl (CTree *a, CTree *p, CTree *c, CTree *d) :
35
51
_advice (a), _pointcut (p), _colon (c), _decl (d) {}
52
/** Get the identifier for this node type. Can be compared with NodeName(). */
36
53
static const char *NodeId ();
54
/** Get the name of the node. Can be compared with NodeId(). */
37
55
const char *NodeName () const { return NodeId (); }
56
/** Get the number of sons. */
38
57
int Sons () const { return 4; }
59
* \param n The index of the son.
60
* \return The n-th son or NULL. */
39
61
CTree *Son (int n) const {
41
63
case 0: return _advice;
45
67
default: return (CTree*)0;
71
* \param old_son The son to replace.
72
* \param new_son The new son. */
48
73
void ReplaceSon (CTree *old_son, CTree *new_son) {
49
74
if (old_son == _decl) _decl = new_son;
50
75
else if (old_son == _pointcut) _pointcut = new_son;
51
76
else if (old_son == _advice) _advice = new_son;
52
77
else if (old_son == _colon) _colon = new_son;
79
/** Get the pointcut expression. */
54
80
CTree *Pointcut () const { return _pointcut; }
81
/** Get the advice declaration. */
55
82
CTree *Decl () const { return _decl; }
85
/** \class CT_OrderList ACTree.h Puma/ACTree.h
86
* Tree node representing an order list.
87
* Example: \code ( "pointcut1", "pointcut2" ) \endcode */
58
88
class CT_OrderList : public CT_List {
60
91
CT_OrderList () { AddProperties (SEPARATORS | OPEN_CLOSE); }
92
/** Get the identifier for this node type. Can be compared with NodeName(). */
61
93
static const char *NodeId ();
94
/** Get the name of the node. Can be compared with NodeId(). */
62
95
const char *NodeName () const { return NodeId (); }
98
/** \class CT_OrderDecl ACTree.h Puma/ACTree.h
99
* Tree node representing an order declaration.
100
* Example: \code order("pointcut1","pointcut2") \endcode */
65
101
class CT_OrderDecl : public CTree {
67
103
CTree *_order_list;
68
104
CTree *_semi_colon;
108
* \param o The keyword 'order'.
109
* \param ol The list of pointcut expressions.
110
* \param s The trailing semi-colon. */
70
111
CT_OrderDecl (CTree *o, CTree *ol, CTree *s) :
71
112
_order (o), _order_list (ol), _semi_colon (s) {}
113
/** Get the identifier for this node type. Can be compared with NodeName(). */
72
114
static const char *NodeId ();
115
/** Get the name of the node. Can be compared with NodeId(). */
73
116
const char *NodeName () const { return NodeId (); }
117
/** Get the number of sons. */
74
118
int Sons () const { return 3; }
119
/** Get the n-th son.
120
* \param n The index of the son.
121
* \return The n-th son or NULL. */
75
122
CTree *Son (int n) const {
77
124
case 0: return _order;
80
127
default: return (CTree*)0;
131
* \param old_son The son to replace.
132
* \param new_son The new son. */
83
133
void ReplaceSon (CTree *old_son, CTree *new_son) {
84
134
if (old_son == _order) _order = new_son;
85
135
else if (old_son == _order_list) _order_list = new_son;
86
136
else if (old_son == _semi_colon) _semi_colon = new_son;
138
/** Get the list of pointcut expressions. */
88
139
CT_OrderList *OrderList () const { return (CT_OrderList*)_order_list; }
142
/** \class CT_PointcutDecl ACTree.h Puma/ACTree.h
143
* Tree node representing a pointcut declaration.
144
* Example: \code pointcut main() = "% main(...)"; \endcode */
91
145
class CT_PointcutDecl : public CT_Decl {
92
146
CTree *_pointcut; // CT_Token
151
* \param p The keyword 'pointcut'.
152
* \param d The pointcut declaration. */
96
153
CT_PointcutDecl (CTree *p, CTree *d) : _pointcut (p), _decl (d) {}
154
/** Get the identifier for this node type. Can be compared with NodeName(). */
97
155
static const char *NodeId ();
156
/** Get the name of the node. Can be compared with NodeId(). */
98
157
const char *NodeName () const { return NodeId (); }
158
/** Get the number of sons. */
99
159
int Sons () const { return 2; }
160
/** Get the n-th son.
161
* \param n The index of the son.
162
* \return The n-th son or NULL. */
100
163
CTree *Son (int n) const {
102
165
case 0: return _pointcut;
104
167
default: return (CTree*)0;
171
* \param old_son The son to replace.
172
* \param new_son The new son. */
107
173
void ReplaceSon (CTree *old_son, CTree *new_son) {
108
174
if (old_son == _decl) _decl = new_son;
109
175
else if (old_son == _pointcut) _pointcut = new_son;
177
/** Get the pointcut declaration. */
111
178
CTree *Decl () const { return _decl; }
181
/** \class CT_Intro ACTree.h Puma/ACTree.h
182
* Tree node representing an introduction advice declaration.
183
* Example: \code around() \endcode */
114
184
class CT_Intro : public CT_List, public CSemScope {
115
185
// indices of aspect or slice names in introduction
116
186
Array<int> _name_indices; // start index
117
187
Array<int> _name_to_indices; // end index
118
Array<bool> _name_qual; // true if the token should be replaced by a
188
Array<bool> _name_qual; // true if the token should be replaced by a qualified name
191
/** Get the identifier for this node type. Can be compared with NodeName(). */
121
192
static const char *NodeId ();
193
/** Get the name of the node. Can be compared with NodeId(). */
122
194
const char *NodeName () const { return NodeId (); }
195
/** Add a name index.
196
* \param index The name index. */
123
197
void AddNameIndex (int index) {
124
198
_name_indices.append (index);
125
199
_name_to_indices.append (index);
126
200
_name_qual.append (false);
202
/** Add a name index.
203
* \param index_from Start index.
204
* \param index_to End index. */
128
205
void AddNameIndex (int index_from, int index_to) {
129
206
_name_indices.append (index_from);
130
207
_name_to_indices.append (index_to);
131
208
_name_qual.append (true);
210
/** Roll back the name index to the given position.
211
* \param pos The position up to which to roll back. */
133
212
void RollbackNameIndex (int pos) {
134
213
for (int i = NameIndices () - 1; i >= 0; i--) {
135
214
if (NameIndex (i) >= pos) {
223
/** Get the name indices. */
144
224
int NameIndices () const { return _name_indices.length (); }
225
/** Get the start index of the name with the given index.
226
* \param i The index. */
145
227
int NameIndex (int i) const { return _name_indices.lookup (i); }
228
/** Get the end index for the name with the given index.
229
* \param i The index. */
146
230
int NameToIndex (int i) const { return _name_to_indices.lookup (i); }
231
/** Check if the name at the given index should
232
* be replaced by a qualified name.
233
* \param i The index. */
147
234
bool NameQual (int i) const { return _name_qual.lookup (i); }
237
/** \class CT_ClassSliceDecl ACTree.h Puma/ACTree.h
238
* Tree node representing a slice declaration for a class.
241
* slice class X : Y {
150
245
class CT_ClassSliceDecl : public CTree, public CSemObject {
151
246
CTree *sons[6]; // SLICE? <key>? <name>? <baseclasses>? <members> ;
250
* \param sl The keyword 'slice'.
251
* \param k The keyword 'class' or 'struct'.
252
* \param n The name of the class.
253
* \param b The base class list.
254
* \param m The class member declarations list.
255
* \param se The trailing semi-colon. */
153
256
CT_ClassSliceDecl (CTree *sl, CTree *k, CTree *n, CTree *b, CTree *m, CTree *se) {
154
257
sons[0] = sl; sons[1] = k; sons[2] = n; sons[3] = b; sons[4] = m; sons[5] = se;
259
/** Get the identifier for this node type. Can be compared with NodeName(). */
156
260
static const char *NodeId ();
261
/** Get the name of the node. Can be compared with NodeId(). */
157
262
const char *NodeName () const { return NodeId (); }
263
/** Get the number of sons. */
158
264
int Sons () const { return CTree::Sons (sons, 6); }
265
/** Get the n-th son.
266
* \param n The index of the son.
267
* \return The n-th son or NULL. */
159
268
CTree *Son (int n) const { return CTree::Son (sons, 6, n); }
270
* \param old_son The son to replace.
271
* \param new_son The new son. */
160
272
void ReplaceSon (CTree *old_son, CTree *new_son) {
161
273
CTree::ReplaceSon (sons, 6, old_son, new_son);
275
/** Get the class keyword, i.e. 'class' or 'struct'. */
163
276
CT_Token *key () const { return (CT_Token*)sons[1]; }
277
/** Get the name of the class. */
164
278
CT_SimpleName *name () const { return (CT_SimpleName*)sons[2]; }
279
/** Get the base class list. */
165
280
CT_Intro *base_clause () const { return (CT_Intro*)sons[3]; }
281
/** Get the class member declarations list. */
166
282
CT_Intro *members () const { return (CT_Intro*)sons[4]; }
285
/** \class CT_SliceRef ACTree.h Puma/ACTree.h
286
* Tree node representing a slice reference.
287
* Example: \code slice X; \endcode */
169
288
class CT_SliceRef : public CTree {
293
* \param sl The keyword 'slice'.
294
* \param n The name of the slice.
295
* \param se The trailing semi-colon. */
172
296
CT_SliceRef (CTree *sl, CTree *n, CTree *se) {
173
297
sons[0] = sl; sons[1] = n; sons[2] = se;
299
/** Get the identifier for this node type. Can be compared with NodeName(). */
175
300
static const char *NodeId ();
301
/** Get the name of the node. Can be compared with NodeId(). */
176
302
const char *NodeName () const { return NodeId (); }
303
/** Get the number of sons. */
177
304
int Sons () const { return 3; }
305
/** Get the n-th son.
306
* \param n The index of the son.
307
* \return The n-th son or NULL. */
178
308
CTree *Son (int n) const { return CTree::Son (sons, 3, n); }
310
* \param old_son The son to replace.
311
* \param new_son The new son. */
179
312
void ReplaceSon (CTree *old_son, CTree *new_son) {
180
313
CTree::ReplaceSon (sons, 3, old_son, new_son);
315
/** Get the name of the slice. */
182
316
CT_SimpleName *name () const { return (CT_SimpleName*)sons[1]; }