~ubuntu-branches/ubuntu/lucid/aspectc++/lucid

« back to all changes in this revision

Viewing changes to Puma/gen-release/step1/inc/Puma/ACTree.h

  • Committer: Bazaar Package Importer
  • Author(s): Reinhard Tartler
  • Date: 2008-07-07 14:41:02 UTC
  • mfrom: (1.1.3 upstream) (6.1.1 lenny)
  • Revision ID: james.westby@ubuntu.com-20080707144102-lzml7t07f3sl00r5
Tags: 1.0pre4~svn.20080711-1
* new upstream snapshot.
* include all upstream documentation. Clarifying emails regarding
  licensing has been included into debian/copyright.
* reformat description following recomendations of
  http://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Description
  (Closes: #480316)

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 
22
22
#include "Puma/CTree.h"
23
23
 
 
24
/** \file
 
25
 *  AspectC++ specific syntax tree classes. */
 
26
 
24
27
namespace Puma {
25
28
 
26
29
 
 
30
/** \class CT_AdviceDecl ACTree.h Puma/ACTree.h
 
31
 *  Tree node representing an advice declaration. 
 
32
 *  Example: 
 
33
 *  \code 
 
34
 * advice "% main(...)" : before() { 
 
35
 *   printf('init'); 
 
36
 * } 
 
37
 *  \endcode */
27
38
class CT_AdviceDecl : public CT_Decl {
28
39
  CTree *_advice;    // CT_Token
29
40
  CTree *_pointcut;
31
42
  CTree *_decl;
32
43
 
33
44
public:
 
45
  /** Constructor.
 
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; }
 
58
  /** Get the n-th son.
 
59
   *  \param n The index of the son.
 
60
   *  \return The n-th son or NULL. */
39
61
  CTree *Son (int n) const { 
40
62
    switch (n) { 
41
63
      case 0: return _advice;
45
67
      default: return (CTree*)0;
46
68
    }
47
69
  }
 
70
  /** Replace a son.
 
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; 
53
78
  }
 
79
  /** Get the pointcut expression. */
54
80
  CTree *Pointcut () const { return _pointcut; }
 
81
  /** Get the advice declaration. */
55
82
  CTree *Decl () const { return _decl; }
56
83
};
57
84
 
 
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 {
59
89
public:
 
90
  /** Constructor. */
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 (); }
63
96
};
64
97
 
 
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 {
66
102
  CTree *_order;
67
103
  CTree *_order_list;
68
104
  CTree *_semi_colon;
 
105
 
69
106
public:
 
107
  /** Constructor.
 
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 { 
76
123
    switch (n) { 
77
124
      case 0: return _order;
80
127
      default: return (CTree*)0;
81
128
    }
82
129
  }
 
130
  /** Replace a son.
 
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; 
87
137
  }
 
138
  /** Get the list of pointcut expressions. */
88
139
  CT_OrderList *OrderList () const { return (CT_OrderList*)_order_list; }
89
140
};
90
141
 
 
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
93
147
  CTree *_decl;
94
148
 
95
149
public:
 
150
  /** Constructor.
 
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 { 
101
164
    switch (n) { 
102
165
      case 0: return _pointcut;
104
167
      default: return (CTree*)0;
105
168
    }
106
169
  }
 
170
  /** Replace a son.
 
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; 
110
176
  }
 
177
  /** Get the pointcut declaration. */
111
178
  CTree *Decl () const { return _decl; }
112
179
};
113
180
 
 
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
119
 
                               // qualified name
 
188
  Array<bool> _name_qual;      // true if the token should be replaced by a qualified name
 
189
 
120
190
public:
 
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);
127
201
  }
 
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);
132
209
  }
 
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) {
141
220
        break;
142
221
    }
143
222
  }
 
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); }
148
235
};
149
236
 
 
237
/** \class CT_ClassSliceDecl ACTree.h Puma/ACTree.h
 
238
 *  Tree node representing a slice declaration for a class. 
 
239
 *  Example: 
 
240
 *  \code 
 
241
 * slice class X : Y { 
 
242
 *   int x; 
 
243
 * }; 
 
244
 *  \endcode */
150
245
class CT_ClassSliceDecl : public CTree, public CSemObject {
151
246
  CTree *sons[6]; // SLICE? <key>? <name>? <baseclasses>? <members> ;
 
247
  
152
248
public:
 
249
  /** Constructor.
 
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;
155
258
  }
 
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); }
 
269
  /** Replace a son.
 
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);
162
274
  }
 
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]; }
167
283
};
168
284
 
 
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 {
170
289
  CTree *sons[3];
 
290
  
171
291
public:
 
292
  /** Constructor.
 
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;
174
298
  }
 
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); }
 
309
  /** Replace a son.
 
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);
181
314
  }
 
315
  /** Get the name of the slice. */
182
316
  CT_SimpleName *name () const { return (CT_SimpleName*)sons[1]; }
183
317
};
184
318