~ubuntu-branches/ubuntu/maverick/aspectc++/maverick

« back to all changes in this revision

Viewing changes to Puma/src/parser/cparser/CTree.h

  • Committer: Bazaar Package Importer
  • Author(s): Reinhard Tartler
  • Date: 2008-04-10 17:40:52 UTC
  • mto: This revision was merged to the branch mainline in revision 10.
  • Revision ID: james.westby@ubuntu.com-20080410174052-dbne39zue793jgrh
Tags: upstream-1.0pre4~svn.20080409+dfsg
ImportĀ upstreamĀ versionĀ 1.0pre4~svn.20080409+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
42
42
class     CT_DefaultStmt;
43
43
class     CT_TryStmt;
44
44
class   CT_Expression;
 
45
class     CT_Call;
 
46
class       CT_CallExpr;
 
47
class       CT_ImplicitCall;
45
48
class     CT_ThrowExpr;
46
49
class     CT_NewExpr;
47
50
class     CT_DeleteExpr;
62
65
class     CT_IfThenExpr;
63
66
class     CT_CmpdLiteral;
64
67
class     CT_IndexExpr;
65
 
class     CT_CallExpr;
66
68
class     CT_CastExpr;
67
69
class     CT_StaticCast;
68
70
class       CT_ConstCast;
109
111
class     CT_NamespaceDef;
110
112
class     CT_NamespaceAliasDef;
111
113
class     CT_UsingDirective;
 
114
class     CT_Condition;
112
115
class   CT_List;
113
116
class     CT_CmpdStmt;
114
117
class     CT_DeclSpecSeq;
139
142
class     CT_TemplateArgList;
140
143
class   CT_Token;
141
144
class   CT_Error;
142
 
class   CT_Condition;
143
145
class   CT_BaseSpec;
144
146
class   CT_AccessSpec;
145
147
class   CT_ArrayDelimiter;
179
181
/*                                                                           */
180
182
/*****************************************************************************/
181
183
 
 
184
/** \file
 
185
 *  C/C++ syntax tree classes.
 
186
 *  \see Puma::CTree */
 
187
 
 
188
/** \class CTree CTree.h Puma/CTree.h
 
189
 *  Base class for all C/C++ syntax tree classes. */
182
190
class CTree {
 
191
  CTree * _parent;
 
192
 
183
193
public:
184
194
  /*DEBUG*/static int alloc;
185
195
  /*DEBUG*/static int release;
186
196
 
187
197
protected:
188
 
  CTree *Son (CTree * const *, int, int) const;
189
 
  int Sons (CTree * const *, int) const;
190
 
  void ReplaceSon (CTree * const *, int, CTree *, CTree *) const;
 
198
  /** Get the n-th son from given sons array. Skips empty (NULL) array items.
 
199
   *  \param sons The sons array.
 
200
   *  \param len Length of the sons array.
 
201
   *  \param n Index of the son.
 
202
   *  \return The n-th son or NULL. */
 
203
  CTree *Son (CTree * const *sons, int len, int n) const;
 
204
  /** Get the number of sons in the given sons array. Skips empty (NULL) array items.
 
205
   *  \param sons The sons array.
 
206
   *  \param len Length of the sons array. */
 
207
  int Sons (CTree * const *sons, int len) const;
 
208
  /** Replace a son.
 
209
   *  \param sons The sons array.
 
210
   *  \param len Length of the sons array.
 
211
   *  \param old_son The son to replace.
 
212
   *  \param new_son The new son. */
 
213
  void ReplaceSon (CTree **sons, int len, CTree *old_son, CTree *new_son);
 
214
  /** Replace a son if it equals the given son.
 
215
   *  \param son The actual son.
 
216
   *  \param old_son The son to replace, must match the actual son.
 
217
   *  \param new_son The new son, overwrites the actual son. */
 
218
  void ReplaceSon (CTree *&son, CTree *old_son, CTree *new_son);
 
219
  /** Add a new son.
 
220
   *  \param son The actual son.
 
221
   *  \param new_son The new son, overwrites the actual son. */
 
222
  void AddSon (CTree *&son, CTree *new_son);
 
223
  /** Set the parent tree node.
 
224
   *  \param parent The new parent tree node. */
 
225
  void SetParent (const CTree *parent) { _parent = (CTree*)parent; }
 
226
  /** Set the parent tree node of the given tree node.
 
227
   *  \param node The tree node.
 
228
   *  \param parent The new parent. */
 
229
  void SetParent (CTree *node, const CTree *parent) { node->_parent = (CTree*)parent; }
191
230
  
192
231
protected:
193
 
  CTree () { /*DEBUG*/alloc++; }
 
232
  /** Default constructor. */
 
233
  CTree () : _parent(0) { /*DEBUG*/alloc++; }
194
234
 
195
235
public:
 
236
  /** Destructor. */
196
237
  virtual ~CTree () { /*DEBUG*/release++; }
 
238
  /** Get the number of sons. */
197
239
  virtual int Sons () const = 0;
 
240
  /** Get the n-th son.
 
241
   *  \param n The index of the son.
 
242
   *  \return The n-th son or NULL. */
198
243
  virtual CTree *Son (int n) const { return (CTree*)0; }
 
244
  /** Get the node name (node identifier). */
199
245
  virtual const char *NodeName () const = 0;
 
246
  /** Get the first token of the syntactic construct represented by this sub-tree.
 
247
   *  \return The token or NULL. */
200
248
  virtual Token *token () const;
 
249
  /** Get the last token of the syntactic construct represented by this sub-tree.
 
250
   *  \return The token or NULL. */
201
251
  virtual Token *end_token () const;
 
252
  /** Get the CT_Token node of the first token of the syntactic construct represented by this sub-tree.
 
253
   *  \return The token node or NULL. */
202
254
  virtual CT_Token *token_node () const;
 
255
  /** Get the CT_Token node of the last token of the syntactic construct represented by this sub-tree.
 
256
   *  \return The token node or NULL. */
203
257
  virtual CT_Token *end_token_node () const;
204
 
  virtual void ReplaceSon (CTree *, CTree *) {}
 
258
  /** Replace a son.
 
259
   *  \param old_son The son to replace.
 
260
   *  \param new_son The son with which to replace. */
 
261
  virtual void ReplaceSon (CTree *old_son, CTree *new_son) {}
 
262
  /** Get the parent node.
 
263
   *  \return The parent node or NULL. */
 
264
  virtual CTree *Parent () const { return (CTree*)_parent; }
205
265
 
206
266
public: // semantic information
 
267
  /** Get the semantic type of the node.
 
268
   *  \return The type object or NULL. */
207
269
  virtual CTypeInfo *Type () const { return (CTypeInfo*)0; }
 
270
  /** Get the calculated value of the expression.
 
271
   *  \return The value object or NULL. */
208
272
  virtual CExprValue *Value () const { return (CExprValue*)0; }
209
273
  
 
274
  /** Get the semantic scope of the node.
 
275
   *  \return The scope object or NULL. */
 
276
  virtual CSemScope *SemScope () const { return (CSemScope*)0; }
 
277
  /** Get the semantic value of the node.
 
278
   *  \return The value object or NULL. */
210
279
  virtual CSemValue *SemValue () const { return (CSemValue*)0; }
 
280
  /** Get the semantic object of the node.
 
281
   *  \return The semantic object or NULL. */
211
282
  virtual CSemObject *SemObject () const { return (CSemObject*)0; }
212
283
  
213
284
public: // node classification function
 
285
  /** Get a pointer to CT_SimpleName if the current node represents a name.
 
286
   *  \return The CT_SimpleName node or NULL. */
214
287
  virtual CT_SimpleName *IsSimpleName () { return 0; }
 
288
  /** Get a pointer to CT_String if the current node represents a string.
 
289
   *  \return The CT_String node or NULL. */
 
290
  virtual CT_String *IsString () { return 0; }
 
291
  /** Get a pointer to CT_Declarator if the current node represents a declarator.
 
292
   *  \return The CT_Declarator pointer or NULL. */
215
293
  virtual CT_Declarator *IsDeclarator () { return 0; }
 
294
  /** Get a pointer to CT_Statement if the current node represents a statement.
 
295
   *  \return The CT_Statement pointer or NULL. */
 
296
  virtual CT_Statement *IsStatement () { return 0; }
 
297
  /** Get a pointer to CT_Expression if the current node represents a expression.
 
298
   *  \return The CT_Expression pointer or NULL. */
 
299
  virtual CT_Expression *IsExpression () { return 0; }
 
300
  /** Get a pointer to CT_Decl if the current node represents a declaration.
 
301
   *  \return The CT_Decl pointer or NULL. */
 
302
  virtual CT_Decl *IsDeclaration () { return 0; }
 
303
  /** Get a pointer to CT_Call if the current node represents a call expression.
 
304
   *  \return The CT_Call pointer or NULL. */
 
305
  virtual CT_Call *IsCall () { return 0; }
216
306
};
217
307
 
 
308
/** \class CT_Error CTree.h Puma/CTree.h
 
309
 *  Error tree node that is inserted into the tree for syntactic constructs
 
310
 *  that could not be parsed. */
218
311
class CT_Error : public CTree {
219
312
public:
 
313
  /** Get the identifier for this node type. Can be compared with NodeName(). */
220
314
  static const char *NodeId ();
 
315
  /** Get the name of the node. Can be compared with NodeId(). */
221
316
  const char *NodeName () const { return NodeId (); }
 
317
  /** Get the number of sons. */
222
318
  int Sons () const { return 0; }
223
319
};
224
320
 
 
321
/** \class CT_Token CTree.h Puma/CTree.h
 
322
 *  Tree node representing a single token in the source code. */
225
323
class CT_Token : public CTree {
226
324
  Token *_token;
227
325
  unsigned long int _number;
228
326
  
229
327
public:
230
 
  CT_Token (Token *t, unsigned long int n = 0) : 
231
 
    _token (t), _number (n) {}
 
328
  /** Constructor. 
 
329
   *  \param token The represented token.
 
330
   *  \param number The token number (a consecutive number). */
 
331
  CT_Token (Token *token, unsigned long int number = 0) : 
 
332
    _token (token), _number (number) {}
 
333
  /** Get the identifier for this node type. Can be compared with NodeName(). */
232
334
  static const char *NodeId ();
 
335
  /** Get the name of the node. Can be compared with NodeId(). */
233
336
  const char *NodeName () const { return NodeId (); }
 
337
  /** Get the number of sons. */
234
338
  int Sons () const { return 0; }
 
339
  /** Get the represented token. */
235
340
  Token *token () const { return _token; }
 
341
  /** Get the represented token. */
236
342
  Token *end_token () const { return _token; }
 
343
  /** Get this. */
237
344
  CT_Token *token_node () const { return (CT_Token*)this; }
 
345
  /** Get this. */
238
346
  CT_Token *end_token_node () const { return (CT_Token*)this; }
239
 
  void Number (unsigned long int n) { _number = n; }
 
347
  /** Set the token number. 
 
348
   *  \param number The token number. */ 
 
349
  void Number (unsigned long int number) { _number = number; }
 
350
  /** Get the token number. Can be used to indentify this token. */
240
351
  unsigned long int Number () const { return _number; }
241
 
  // special new / delete with reusing memory
 
352
  
 
353
public:
 
354
  /** Own new operator reusing memory. */
242
355
  void *operator new (size_t);
243
 
  void  operator delete (void *);
 
356
  /** Own delete operator. */
 
357
  void operator delete (void *);
244
358
};
245
359
 
246
360
/*****************************************************************************/
249
363
/*                                                                           */
250
364
/*****************************************************************************/
251
365
 
 
366
/** \class CT_List CTree.h Puma/CTree.h
 
367
 *  Base class for tree nodes representing lists. */
252
368
class CT_List : public CTree {
253
369
  Array<CTree*> _sons;
254
370
  int _properties;
255
371
 
256
372
protected:
 
373
  /** Constructor.
 
374
   *  \param size The initial list size.
 
375
   *  \param incr The initial increment count. 
 
376
   *  \param props The list properties (bit array). */
257
377
  CT_List(int size = 5, int incr = 5, int props = 0) : 
258
378
    _sons (size, incr), _properties (props) {}
259
379
 
260
380
public:
 
381
  /** List properties. */
261
382
  enum {
262
 
    OPEN = 1,         // has a start token like ':' in ":a(1),b(2)"
263
 
    CLOSE = 2,
264
 
    OPEN_CLOSE = 3,   // has opening and closing delimiters, e.g. '(' ')'
265
 
    SEPARATORS = 4,   // the list has separators like ','
266
 
    FORCE_EMPTY = 8,  // pretend to be empty, e.g. for "(void)"
267
 
    END_SEP = 16,     // has separator after last element, e.g. "a,b,c,"
268
 
    NO_LAST_SEP = 32, // no separator before last element, e.g. "(a,b...)"
269
 
    INTRO = 64        // has an introduction char, e.g. "=" in "={a,b}"
 
383
    OPEN = 1,         /** List has a start token, like ':' in ":a(1),b(2)" */
 
384
    CLOSE = 2,        /** List has an end token */
 
385
    OPEN_CLOSE = 3,   /** List has opening and closing delimiters, like '(' and ')' */
 
386
    SEPARATORS = 4,   /** List has separators, like ',' */
 
387
    FORCE_EMPTY = 8,  /** List pretend to be empty, e.g. for "(void)" */
 
388
    END_SEP = 16,     /** List has trailing separator, e.g. "a,b,c," */
 
389
    NO_LAST_SEP = 32, /** List has no separator before last element, e.g. "(a,b...)" */
 
390
    INTRO = 64        /** List has an introduction chararacter, e.g. "=" in "={a,b}" */
270
391
  };
271
392
 
 
393
  /** Get the number of list entries. */
272
394
  int Entries () const;
273
 
  CTree *Entry (int no) const;
 
395
  /** Get the n-th list entry.
 
396
   *  \param n The index of the entry. 
 
397
   *  \return The list entry or NULL. */
 
398
  CTree *Entry (int n) const;
 
399
  /** Get the number of sons. */
274
400
  int Sons () const { return _sons.length (); }
 
401
  /** Get the n-th son.
 
402
   *  \param n The index of the son. 
 
403
   *  \return The n-th son or NULL. */
275
404
  CTree *Son (int n) const { return _sons.lookup (n); }
 
405
  /** Get the list properties. */
276
406
  int GetProperties () const { return _properties; }
 
407
  /** Add a list property.
 
408
   *  \param p The property to add. */
277
409
  void AddProperties (int p) { _properties |= p; }
278
 
  void AddSon (CTree *s) { if (s) _sons.append (s); }
279
 
  void PrefixSon (CTree *s) { if (s) _sons.prepend (s); }
280
 
  void InsertSon (CTree *, CTree *);  // before given son
281
 
  void ReplaceSon (CTree *, CTree *);
282
 
  void RemoveSon (CTree *);
 
410
  /** Add a son.
 
411
   *  \param s The son to add. */
 
412
  void AddSon (CTree *s) { if (s) { _sons.append (s); SetParent (s, this); } }
 
413
  /** Prepend a son.
 
414
   *  \param s The son to prepend. */
 
415
  void PrefixSon (CTree *s) { if (s) { _sons.prepend (s); SetParent (s, this); } }
 
416
  /** Insert a son before another son.
 
417
   *  \param before The son to insert the new son before.
 
418
   *  \param son The son to insert. */
 
419
  void InsertSon (CTree *before, CTree *son); 
 
420
  /** Replace a son.
 
421
   *  \param old_son The son to replace.
 
422
   *  \param new_son The new son. */
 
423
  void ReplaceSon (CTree *old_son, CTree *new_son);
 
424
  /** Remove a son.
 
425
   *  \param son The son to remove. */
 
426
  void RemoveSon (CTree *son);
 
427
  /** Insert a son at the given index. 
 
428
   *  \param idx The index at which to insert.
 
429
   *  \param s The son to insert. */
283
430
  void InsertSon (int idx, CTree *s)
284
 
   { if (idx <= Sons ()) _sons.insert (idx, s); }
 
431
   { if (s && idx <= Sons ()) { _sons.insert (idx, s); SetParent (s, this); } }
 
432
  /** Replace the son at the given index.
 
433
   *  \param idx The index of the son to replace.
 
434
   *  \param s The new son. */
285
435
  void ReplaceSon (int idx, CTree *s) 
286
 
   { if (idx < Sons ()) _sons[idx] = s; }
 
436
   { if (s && idx < Sons ()) { SetParent (_sons[idx], 0); _sons[idx] = s; SetParent (s, this); } }
 
437
  /** Remove the son at the given index. 
 
438
   *  \param idx The index of the son to remove. */
287
439
  void RemoveSon (int idx) 
288
 
   { if (idx < Sons ()) _sons.remove (idx); }
 
440
   { if (idx < Sons ()) { SetParent (_sons[idx], 0); _sons.remove (idx); } }
289
441
};
290
442
 
 
443
/** \class CT_ExprList CTree.h Puma/CTree.h
 
444
 *  Tree node representing an expression list. */
291
445
class CT_ExprList : public CT_List, public CSemValue, public CSemObject {
292
446
public:
 
447
  /** Constructor. */
293
448
  CT_ExprList () { AddProperties (SEPARATORS); }
 
449
  /** Get the identifier for this node type. Can be compared with NodeName(). */
294
450
  static const char *NodeId ();
 
451
  /** Get the name of the node. Can be compared with NodeId(). */
295
452
  const char *NodeName () const { return NodeId (); }
296
453
 
 
454
  /** Get the type of the last expression in the expression list.
 
455
   *  \return The type or NULL. */
297
456
  CTypeInfo *Type () const { return type; }
 
457
  /** Get the value of the last expression in the expression list.
 
458
   *  \return The value of NULL. */
298
459
  CExprValue *Value () const { return value; }
 
460
  /** Get the semantic value of the node. */
299
461
  CSemValue *SemValue () const { return (CSemValue*)this; }
 
462
  /** Get the semantic object of the node. */
300
463
  CSemObject *SemObject () const { return (CSemObject*)this; }
301
464
};
302
465
 
 
466
/** \class CT_DeclaratorList CTree.h Puma/CTree.h
 
467
 *  Tree node representing a list of declarators. */
303
468
class CT_DeclaratorList : public CT_List {
304
469
public:
 
470
  /** Get the identifier for this node type. Can be compared with NodeName(). */
305
471
  static const char *NodeId ();
 
472
  /** Get the name of the node. Can be compared with NodeId(). */
306
473
  const char *NodeName () const { return NodeId (); }
307
474
};
308
475
 
 
476
/** \class CT_DeclaratorList CTree.h Puma/CTree.h
 
477
 *  Tree node representing a list of enumerator constants. */
309
478
class CT_EnumeratorList : public CT_List {
310
479
public:
 
480
  /** Constructor. */
311
481
  CT_EnumeratorList () { AddProperties (SEPARATORS | OPEN_CLOSE); }
 
482
  /** Get the identifier for this node type. Can be compared with NodeName(). */
312
483
  static const char *NodeId ();
 
484
  /** Get the name of the node. Can be compared with NodeId(). */
313
485
  const char *NodeName () const { return NodeId (); }
314
486
};
315
487
   
 
488
/** \class CT_DeclList CTree.h Puma/CTree.h
 
489
 *  Tree node representing a list of declarations. */
316
490
class CT_DeclList : public CT_List {
317
491
public:
 
492
  /** Constructor. 
 
493
   *  \param size The initial size of the list.
 
494
   *  \param incr The initial increment count of the list. */
318
495
  CT_DeclList (int size = 20, int incr = 20) : CT_List (size, incr) {}
 
496
  /** Get the identifier for this node type. Can be compared with NodeName(). */
319
497
  static const char *NodeId ();
 
498
  /** Get the name of the node. Can be compared with NodeId(). */
320
499
  const char *NodeName () const { return NodeId (); }
 
500
  /** Set the linkage specifiers to each declaration in the list.
 
501
   *  \param l The linkage specifiers node. */
321
502
  void Linkage (CT_LinkageSpec *l);
322
503
};
323
504
 
 
505
/** \class CT_DeclSpecSeq CTree.h Puma/CTree.h
 
506
 *  Tree node representing a sequence of declaration specifiers. */
324
507
class CT_DeclSpecSeq : public CT_List {
325
508
public:
 
509
  /** Get the identifier for this node type. Can be compared with NodeName(). */
326
510
  static const char *NodeId ();
 
511
  /** Get the name of the node. Can be compared with NodeId(). */
327
512
  const char *NodeName () const { return NodeId (); }
328
513
};
329
514
 
 
515
/** \class CT_CmpdStmt CTree.h Puma/CTree.h
 
516
 *  Tree node representing a compound statement. */
330
517
class CT_CmpdStmt : public CT_List, public CSemScope {
331
518
public:
 
519
  /* Constructor. */
332
520
  CT_CmpdStmt () { AddProperties (OPEN_CLOSE); }
 
521
  /** Get the identifier for this node type. Can be compared with NodeName(). */
333
522
  static const char *NodeId ();
 
523
  /** Get the name of the node. Can be compared with NodeId(). */
334
524
  const char *NodeName () const { return NodeId (); }
 
525
  /** Get the local scope of the compound statement. */
 
526
  CSemScope *SemScope () const { return (CSemScope*)this; }
335
527
};
336
528
 
 
529
/** \class CT_HandlerSeq CTree.h Puma/CTree.h
 
530
 *  Tree node representing an exception handler sequence. */
337
531
class CT_HandlerSeq : public CT_List {
338
532
public:
 
533
  /** Get the identifier for this node type. Can be compared with NodeName(). */
339
534
  static const char *NodeId ();
 
535
  /** Get the name of the node. Can be compared with NodeId(). */
340
536
  const char *NodeName () const { return NodeId (); }
341
537
};
342
538
 
 
539
/** \class CT_TemplateParamList CTree.h Puma/CTree.h
 
540
 *  Tree node representing a template parameter list. */
343
541
class CT_TemplateParamList : public CT_List, public CSemScope {
344
542
public:
345
543
  CT_TemplateParamList () { AddProperties (INTRO | SEPARATORS | OPEN_CLOSE); }
 
544
  /** Get the identifier for this node type. Can be compared with NodeName(). */
346
545
  static const char *NodeId ();
 
546
  /** Get the name of the node. Can be compared with NodeId(). */
347
547
  const char *NodeName () const { return NodeId (); }
 
548
  /** Get the scope of the template parameter list. */
 
549
  CSemScope *SemScope () const { return (CSemScope*)this; }
348
550
};
349
551
 
 
552
/** \class CT_TemplateArgList CTree.h Puma/CTree.h
 
553
 *  Tree node representing a template argument list. */
350
554
class CT_TemplateArgList : public CT_List {
351
555
public:
 
556
  /** Constructor. */
352
557
  CT_TemplateArgList () { AddProperties (SEPARATORS | OPEN_CLOSE); }
 
558
  /** Get the identifier for this node type. Can be compared with NodeName(). */
353
559
  static const char *NodeId ();
 
560
  /** Get the name of the node. Can be compared with NodeId(). */
354
561
  const char *NodeName () const { return NodeId (); }
355
562
};
356
563
 
360
567
/*                                                                           */
361
568
/*****************************************************************************/
362
569
 
 
570
/** \class CT_Expression CTree.h Puma/CTree.h
 
571
 *  Base class for all expression tree nodes. */
363
572
class CT_Expression : public CTree, public CSemValue {
364
573
protected:
 
574
  /** Constructor. */
365
575
  CT_Expression () {}
366
576
 
367
577
public:
 
578
  /** Get the identifier for this node type. Can be compared with NodeName(). */
368
579
  static const char *NodeId ();
 
580
  /** Get the name of the node. Can be compared with NodeId(). */
369
581
  const char *NodeName () const { return NodeId (); }
 
582
  /** Get the type of the expression.
 
583
   *  \return The type information object or NULL. */
370
584
  CTypeInfo *Type () const { return type; }
 
585
  /** Get the value of the expression.
 
586
   *  \return The value object or NULL. */
371
587
  CExprValue *Value () const { return value; }
 
588
  /** Get the semantic value information of the expression.
 
589
   *  \return The value object or NULL. */
372
590
  CSemValue *SemValue () const { return (CSemValue*)this; }
373
 
};
374
 
 
 
591
  /** Get this. */
 
592
  virtual CT_Expression *IsExpression () { return this; }
 
593
};
 
594
 
 
595
/** \class CT_Call CTree.h Puma/CTree.h
 
596
 *  Tree node representing explicit or implicit function calls 
 
597
 *  including built-in or user-defined functions and overloaded
 
598
 *  operators. */
 
599
class CT_Call : public CT_Expression, public CSemObject {
 
600
protected:
 
601
  /** Constructor. */
 
602
  CT_Call () {}
 
603
  
 
604
public:
 
605
  /** Get the identifier for this node type. Can be compared with NodeName(). */
 
606
  static const char *NodeId ();
 
607
  /** Get the name of the node. Can be compared with NodeId(). */
 
608
  const char *NodeName () const { return NodeId (); }
 
609
  /** Get the semantic information of the call.
 
610
   *  \return The semantic information or NULL. */
 
611
  CSemObject *SemObject () const { return (CSemObject*)this; }
 
612
  /** Get this. */
 
613
  CT_Call *IsCall () { return this; }
 
614
};
 
615
 
 
616
/** \class CT_ImplicitCall CTree.h Puma/CTree.h
 
617
 *  Tree node representing implicit function calls detected by
 
618
 *  the semantic analysis. */
 
619
class CT_ImplicitCall : public CT_Call {
 
620
  CTree *_arg;
 
621
 
 
622
public:
 
623
  /** Constructor.
 
624
   *  \param arg The call argument. */
 
625
  CT_ImplicitCall (CTree *arg) { AddSon (_arg, arg); }
 
626
  /** Get the identifier for this node type. Can be compared with NodeName(). */
 
627
  static const char *NodeId ();
 
628
  /** Get the name of the node. Can be compared with NodeId(). */
 
629
  const char *NodeName () const { return NodeId (); }
 
630
  /** Get the number of sons. */
 
631
  int Sons () const { return 1; }
 
632
  /** Get the n-th son.
 
633
   *  \param n The index of the son.
 
634
   *  \return The n-th son or NULL. */
 
635
  CTree *Son (int n) const { return (n == 0) ? _arg : (CTree*)0; }
 
636
  /** Replace a son.
 
637
   *  \param old_son The son to replace.
 
638
   *  \param new_son The new son. */
 
639
  void ReplaceSon (CTree *old_son, CTree *new_son) 
 
640
   { CTree::ReplaceSon (_arg, old_son, new_son); }
 
641
};
 
642
 
 
643
/** \class CT_String CTree.h Puma/CTree.h
 
644
 *  Tree node representing a string literal. */
375
645
class CT_String : public CT_List, public CSemValue {
376
646
public:
 
647
  /** Constructor. 
 
648
   *  \param size The number of sub-strings. */
377
649
  CT_String (int size) : CT_List (size, 1) {}
 
650
  /** Get the identifier for this node type. Can be compared with NodeName(). */
378
651
  static const char *NodeId ();
 
652
  /** Get the name of the node. Can be compared with NodeId(). */
379
653
  const char *NodeName () const { return NodeId (); }
380
654
 
 
655
  /** Get the type of the string. 
 
656
   *  \return The type or NULL. */
381
657
  CTypeInfo *Type () const { return type; }
 
658
  /** Get the string value.
 
659
   *  \return The value or NULL. */
382
660
  CExprValue *Value () const { return value; }
 
661
  /** Get the semantic value info object.
 
662
   *  \return The semantic value object or NULL. */
383
663
  CSemValue *SemValue () const { return (CSemValue*)this; }
 
664
  /** Get this. */
 
665
  virtual CT_String *IsString () { return this; }
384
666
};
385
667
 
 
668
/** \class CT_WideString CTree.h Puma/CTree.h
 
669
 *  Tree node representing a wide string literal. */
386
670
class CT_WideString : public CT_String {
387
671
public:
 
672
  /** Constructor.
 
673
   *  \param size The number of sub-strings. */
388
674
  CT_WideString (int size) : CT_String (size) {}
 
675
  /** Get the identifier for this node type. Can be compared with NodeName(). */
389
676
  static const char *NodeId ();
 
677
  /** Get the name of the node. Can be compared with NodeId(). */
390
678
  const char *NodeName () const { return NodeId (); }
391
679
};
392
680
 
 
681
/** \class CT_Integer CTree.h Puma/CTree.h
 
682
 *  Tree node representing an integer constant. */
393
683
class CT_Integer : public CT_Expression {
394
684
  CTree *_value;  // CT_Token
395
685
 
396
686
public:
397
 
  CT_Integer (CTree *t) : _value (t) {}
 
687
  /** Constructor.
 
688
   *  \param token The token containing the integer value. */
 
689
  CT_Integer (CTree *token) { AddSon (_value, token); }
 
690
  /** Get the identifier for this node type. Can be compared with NodeName(). */
398
691
  static const char *NodeId ();
 
692
  /** Get the name of the node. Can be compared with NodeId(). */
399
693
  const char *NodeName () const { return NodeId (); }
 
694
  /** Get the number of sons. */
400
695
  int Sons () const { return _value ? 1 : 0; }
 
696
  /** Get the n-th son.
 
697
   *  \param n The index of the son.
 
698
   *  \return The n-th son or NULL. */
401
699
  CTree *Son (int n) const { return (n == 0) ? _value : (CTree*)0; }
 
700
  /** Replace a son.
 
701
   *  \param old_son The son to replace.
 
702
   *  \param new_son The new son. */
402
703
  void ReplaceSon (CTree *old_son, CTree *new_son) 
403
 
   { if (old_son == _value) _value = new_son; }
 
704
   { CTree::ReplaceSon (_value, old_son, new_son); }
404
705
};
405
706
 
 
707
/** \class CT_Character CTree.h Puma/CTree.h
 
708
 *  Tree node representing a single character constant. */
406
709
class CT_Character : public CT_Expression {
407
710
  CTree *_value;  // CT_Token
408
711
 
409
712
public:
410
 
  CT_Character (CTree *t) : _value (t) {}
 
713
  /** Constructor.
 
714
   *  \param token The token containing the character value. */
 
715
  CT_Character (CTree *token) { AddSon (_value, token); }
 
716
  /** Get the identifier for this node type. Can be compared with NodeName(). */
411
717
  static const char *NodeId ();
 
718
  /** Get the name of the node. Can be compared with NodeId(). */
412
719
  const char *NodeName () const { return NodeId (); }
 
720
  /** Get the number of sons. */
413
721
  int Sons () const { return 1; }
 
722
  /** Get the n-th son.
 
723
   *  \param n The index of the son.
 
724
   *  \return The n-th son or NULL. */
414
725
  CTree *Son (int n) const { return (n == 0) ? _value : (CTree*)0; }
 
726
  /** Replace a son.
 
727
   *  \param old_son The son to replace.
 
728
   *  \param new_son The new son. */
415
729
  void ReplaceSon (CTree *old_son, CTree *new_son) 
416
 
   { if (old_son == _value) _value = new_son; }
 
730
   { CTree::ReplaceSon (_value, old_son, new_son); }
417
731
};
418
732
 
 
733
/** \class CT_WideCharacter CTree.h Puma/CTree.h
 
734
 *  Tree node representing a wide character constant. */
419
735
class CT_WideCharacter : public CT_Character {
420
 
  CTree *_value;  // CT_Token
421
 
 
422
736
public:
423
 
  CT_WideCharacter (CTree *t) : CT_Character (t) {}
 
737
  /** Constructor.
 
738
   *  \param token The token containing the wide character value. */
 
739
  CT_WideCharacter (CTree *token) : CT_Character (token) {}
 
740
  /** Get the identifier for this node type. Can be compared with NodeName(). */
424
741
  static const char *NodeId ();
 
742
  /** Get the name of the node. Can be compared with NodeId(). */
425
743
  const char *NodeName () const { return NodeId (); }
426
 
  void ReplaceSon (CTree *old_son, CTree *new_son) 
427
 
   { if (old_son == _value) _value = new_son; }
428
744
};
429
745
 
 
746
/** \class CT_Float CTree.h Puma/CTree.h
 
747
 *  Tree node representing a floating point constant. */
430
748
class CT_Float : public CT_Expression {
431
749
  CTree *_value;  // CT_Token
432
750
 
433
751
public:
434
 
  CT_Float (CTree *t) : _value (t) {}
 
752
  /** Constructor.
 
753
   *  \param token The token containing the floating point value. */
 
754
  CT_Float (CTree *token) { AddSon (_value, token); }
 
755
  /** Get the identifier for this node type. Can be compared with NodeName(). */
435
756
  static const char *NodeId ();
 
757
  /** Get the name of the node. Can be compared with NodeId(). */
436
758
  const char *NodeName () const { return NodeId (); }
 
759
  /** Get the number of sons. */
437
760
  int Sons () const { return 1; }
 
761
  /** Get the n-th son.
 
762
   *  \param n The index of the son.
 
763
   *  \return The n-th son or NULL. */
438
764
  CTree *Son (int n) const { return (n == 0) ? _value : (CTree*)0; }
 
765
  /** Replace a son.
 
766
   *  \param old_son The son to replace.
 
767
   *  \param new_son The new son. */
439
768
  void ReplaceSon (CTree *old_son, CTree *new_son) 
440
 
   { if (old_son == _value) _value = new_son; }
 
769
   { CTree::ReplaceSon (_value, old_son, new_son); }
441
770
};
442
771
 
 
772
/** \class CT_Bool CTree.h Puma/CTree.h
 
773
 *  Tree node representing a boolean literal, i.e. 'true' or 'false'. */
443
774
class CT_Bool : public CT_Expression {
444
775
  CTree *_value;  // CT_Token
445
776
 
446
777
public:
447
 
  CT_Bool (CTree *t) : _value (t) {}
 
778
  /** Constructor.
 
779
   *  \param token The token containing the boolean value. */
 
780
  CT_Bool (CTree *token) { AddSon (_value, token); }
 
781
  /** Get the identifier for this node type. Can be compared with NodeName(). */
448
782
  static const char *NodeId ();
 
783
  /** Get the name of the node. Can be compared with NodeId(). */
449
784
  const char *NodeName () const { return NodeId (); }
 
785
  /** Get the number of sons. */
450
786
  int Sons () const { return 1; }
 
787
  /** Get the n-th son.
 
788
   *  \param n The index of the son.
 
789
   *  \return The n-th son or NULL. */
451
790
  CTree *Son (int n) const { return (n == 0) ? _value : (CTree*)0; }
 
791
  /** Replace a son.
 
792
   *  \param old_son The son to replace.
 
793
   *  \param new_son The new son. */
452
794
  void ReplaceSon (CTree *old_son, CTree *new_son) 
453
 
   { if (old_son == _value) _value = new_son; }
 
795
   { CTree::ReplaceSon (_value, old_son, new_son); }
454
796
};
455
797
 
 
798
/** \class CT_BracedExpr CTree.h Puma/CTree.h
 
799
 *  Tree node representing a braced expression, e.g. (a+b). */
456
800
class CT_BracedExpr : public CT_Expression {
457
801
  CTree *sons[3]; // open, expr, close
458
802
 
459
803
public:
 
804
  /** Constructor.
 
805
   *  \param o The opening brace.
 
806
   *  \param e The enclosed expression.
 
807
   *  \param c The closing brace. */
460
808
  CT_BracedExpr (CTree *o, CTree *e, CTree *c) { 
461
 
    sons[0] = o; sons[1] = e; sons[2] = c; 
 
809
    AddSon (sons[0], o); AddSon (sons[1], e); AddSon (sons[2], c); 
462
810
  }
 
811
  /** Get the identifier for this node type. Can be compared with NodeName(). */
463
812
  static const char *NodeId ();
 
813
  /** Get the name of the node. Can be compared with NodeId(). */
464
814
  const char *NodeName () const { return NodeId (); }
 
815
  /** Get the number of sons. */
465
816
  int Sons () const { return 3; }
 
817
  /** Get the n-th son.
 
818
   *  \param n The index of the son.
 
819
   *  \return The n-th son or NULL. */
466
820
  CTree *Son (int n) const { return CTree::Son (sons, 3, n); }
 
821
  /** Get the enclosed expression. */
467
822
  CTree *Expr () const { return sons[1]; }
 
823
  /** Get the type of the enclosed expression. */
468
824
  CTypeInfo *Type () const { return Expr ()->Type (); }
 
825
  /** Get the value of the enclosed expression. */
469
826
  CExprValue *Value () const { return Expr ()->Value (); }
 
827
  /** Get the semantic value object. */
470
828
  CSemValue *SemValue () const { return (CSemValue*)this; }
 
829
  /** Replace a son.
 
830
   *  \param old_son The son to replace.
 
831
   *  \param new_son The new son. */
471
832
  void ReplaceSon (CTree *old_son, CTree *new_son) { 
472
833
    CTree::ReplaceSon (sons, 3, old_son, new_son);
473
834
  }
474
835
};
475
836
 
 
837
/** \class CT_SimpleName CTree.h Puma/CTree.h
 
838
 *  Base class for all tree nodes representing a name. */
476
839
class CT_SimpleName : public CT_List, public Printable, 
477
840
                      public CSemValue, public CSemObject {
478
841
protected:
 
842
  /** Constructor.
 
843
   *  \param size The number of sub-names (for qualified names). */
479
844
  CT_SimpleName (int size) : CT_List (size, 1) {}
 
845
  /** Constructor.
 
846
   *  \param size The number of sub-names (for qualified names). 
 
847
   *  \param properties Additional name list properties (for root qualified names). */
480
848
  CT_SimpleName (int size, int properties) : 
481
849
    CT_List (size, 2, properties) {}
482
850
  
483
851
public:
 
852
  /** Constructor.
 
853
   *  \param n The sub-tree containing the name. */
484
854
  CT_SimpleName (CTree *n) : CT_List (1, 1) { AddSon (n); }
 
855
  /** Get the identifier for this node type. Can be compared with NodeName(). */
485
856
  static const char *NodeId ();
 
857
  /** Get the name of the node. Can be compared with NodeId(). */
486
858
  const char *NodeName () const { return NodeId (); }
 
859
  /** Get the string containing the name. */
487
860
  virtual const char *Text () const 
488
861
   { return Son (Sons ()-1)->token ()->text (); }
 
862
  /** Print the name on the given stream. 
 
863
   *  \param os The output stream. */
489
864
  virtual void print (ostream &os) const { os << Text (); }
 
865
  /** Get this. */
490
866
  virtual CT_SimpleName *Name () const { return (CT_SimpleName*)this; }
 
867
  /** Get the type of the entity represented by the name. */
491
868
  CTypeInfo *Type () const { return type; }
 
869
  /** Get the value of the entity represented by the name. */ 
492
870
  CExprValue *Value () const { return value; }
 
871
  /** Get the sematic value information object. */
493
872
  CSemValue *SemValue () const { return (CSemValue*)this; }
 
873
  /** Get the sematic information object. */
494
874
  CSemObject *SemObject () const { return (CSemObject*)this; }
495
 
  // special new / delete with reusing memory
496
 
  void *operator new (size_t);
497
 
  void  operator delete (void *);
498
 
  // classification function
 
875
  /** Get this. */
499
876
  virtual CT_SimpleName *IsSimpleName () { return this; }  
 
877
 
 
878
public:
 
879
  /** Own new operator reusing memory. */
 
880
  void *operator new (size_t);
 
881
  /** Own delete operator. */
 
882
  void operator delete (void *);
500
883
};
501
884
 
 
885
/** \class CT_SpecialName CTree.h Puma/CTree.h
 
886
 *  Base class for tree nodes representing a special name, like destructor names. */
502
887
class CT_SpecialName : public CT_SimpleName {
503
888
  char *_name;
504
889
  
505
890
protected:
 
891
  /** Constructor.
 
892
   *  \param size The number of sub-names (for qualified names). */
506
893
  CT_SpecialName (int size = 1) : CT_SimpleName (size), _name (0) {}
507
894
  
508
895
public:
 
896
  /** Destructor. Deletes the name string. */
509
897
  ~CT_SpecialName () { if (_name) delete[] _name; }
 
898
  /** Get the string containing the name. */
510
899
  const char *Text () const { return _name; }
 
900
  /** Set the name. The name is copied.
 
901
   *  \param n The name. */
511
902
  void Name (const char *n) { 
512
903
    if (n) { 
513
904
      _name = new char[strlen(n) + 1];
514
905
      strcpy (_name,n);
515
906
    }
516
907
  }
517
 
  // special new / delete with reusing memory
 
908
 
 
909
public:
 
910
  /** Own new operator reusing memory. */
518
911
  void *operator new (size_t);
519
 
  void  operator delete (void *);
 
912
  /** Own delete operator. */
 
913
  void operator delete (void *);
520
914
};
521
915
 
 
916
/** \class CT_PrivateName CTree.h Puma/CTree.h
 
917
 *  Tree node representing a private name. Private names 
 
918
 *  are generated names for abstract declarators etc. */
522
919
class CT_PrivateName : public CT_SpecialName {
523
920
public:
 
921
  /** Constructor.
 
922
   *  \param n The private (generated) name. */
524
923
  CT_PrivateName (const char *n) { Name (n); }
 
924
  /** Get the identifier for this node type. Can be compared with NodeName(). */
525
925
  static const char *NodeId ();
 
926
  /** Get the name of the node. Can be compared with NodeId(). */
526
927
  const char *NodeName () const { return NodeId (); }
 
928
  /** Get the number of sons. */
527
929
  int Sons () const { return 0; }
 
930
  /** Get the n-th son.
 
931
   *  \param n The index of the son.
 
932
   *  \return The n-th son or NULL. */
528
933
  CTree *Son (int n) const { return (CTree*)0; }
529
 
  // special new / delete with reusing memory
 
934
 
 
935
public:
 
936
  /** Own new operator reusing memory. */
530
937
  void *operator new (size_t);
531
 
  void  operator delete (void *);
 
938
  /** Own delete operator. */
 
939
  void operator delete (void *);
532
940
};
533
941
 
 
942
/** \class CT_DestructorName CTree.h Puma/CTree.h
 
943
 *  Tree node representing a destructor name. */
534
944
class CT_DestructorName : public CT_SpecialName {
535
945
public:
536
 
  CT_DestructorName (CTree *, CTree *);
 
946
  /** Constructor.
 
947
   *  \param t The tilde operator.
 
948
   *  \param n The class name. */
 
949
  CT_DestructorName (CTree *t, CTree *n);
 
950
  /** Get the identifier for this node type. Can be compared with NodeName(). */
537
951
  static const char *NodeId ();
 
952
  /** Get the name of the node. Can be compared with NodeId(). */
538
953
  const char *NodeName () const { return NodeId (); }
539
 
  // special new / delete with reusing memory
 
954
 
 
955
public:
 
956
  /** Own new operator reusing memory. */
540
957
  void *operator new (size_t);
541
 
  void  operator delete (void *);
 
958
  /** Own delete operator. */
 
959
  void operator delete (void *);
542
960
};
543
961
 
 
962
/** \class CT_TemplateName CTree.h Puma/CTree.h
 
963
 *  Tree node representing a template name. */
544
964
class CT_TemplateName : public CT_SpecialName {
545
965
public:
 
966
  /** Constructor.
 
967
   *  \param n The template class or function name.
 
968
   *  \param a The template argument list. */
546
969
  CT_TemplateName (CTree *n, CTree *a) 
547
970
   { AddSon (n); AddSon (a); }
 
971
  /** Get the identifier for this node type. Can be compared with NodeName(). */
548
972
  static const char *NodeId ();
 
973
  /** Get the name of the node. Can be compared with NodeId(). */
549
974
  const char *NodeName () const { return NodeId (); }
 
975
  /** Get the template argument list. */
550
976
  CT_TemplateArgList *Arguments () const 
551
977
   { return (CT_TemplateArgList*)Son (Sons ()-1); }
 
978
  /** Get the template class or function name. */
552
979
  CT_SimpleName *TemplateName () const 
553
980
   { return (CT_SimpleName*)Son (Sons ()-2); }
554
981
  // may change in the future
555
982
  const char *Text () const { return TemplateName ()->Text (); }
556
 
  // special new / delete with reusing memory
 
983
 
 
984
public:
 
985
  /** Own new operator reusing memory. */
557
986
  void *operator new (size_t);
558
 
  void  operator delete (void *);
 
987
  /** Own delete operator. */
 
988
  void operator delete (void *);
559
989
};
560
990
 
 
991
/** \class CT_OperatorName CTree.h Puma/CTree.h
 
992
 *  Tree node representing the name of an overloaded operator. */
561
993
class CT_OperatorName : public CT_SpecialName {
562
994
  int _oper;
563
995
 
564
996
public:
565
 
  enum { // complex operators
566
 
    FCT_CALL = -100,
567
 
    SUBSCRIPT,
568
 
    NEW_ARRAY,
569
 
    DEL_ARRAY
 
997
  /** Complex operator types. */
 
998
  enum { 
 
999
    FCT_CALL = -100,  /** Function call operator, i.e. (). */
 
1000
    SUBSCRIPT,        /** Array subscript operator, i.e. []. */
 
1001
    NEW_ARRAY,        /** New array operator, i.e. new[]. */
 
1002
    DEL_ARRAY         /** Delete array operator, i.e. delete[]. */
570
1003
  };
571
1004
 
572
1005
public:
573
 
  CT_OperatorName (CTree *);
574
 
  CT_OperatorName (CTree *, CTree *, CTree *, CTree *);
 
1006
  /** Constructor.
 
1007
   *  \param op The token containing the operator. */
 
1008
  CT_OperatorName (CTree *op);
 
1009
  /** Constructor.
 
1010
   *  \param f The operator function keyword 'operator'.
 
1011
   *  \param op The token containing the operator. 
 
1012
   *  \param o The token of '[' or '('.
 
1013
   *  \param c The token of ']' or ')'. */
 
1014
  CT_OperatorName (CTree *f, CTree *op, CTree *o, CTree *c);
 
1015
  /** Get the identifier for this node type. Can be compared with NodeName(). */
575
1016
  static const char *NodeId ();
 
1017
  /** Get the name of the node. Can be compared with NodeId(). */
576
1018
  const char *NodeName () const { return NodeId (); }
 
1019
  /** Get the operator type (either the token type or one of 
 
1020
   *  the complex operator types). */
577
1021
  int Operator () const { return _oper; }
578
 
  // special new / delete with reusing memory
 
1022
 
 
1023
public:
 
1024
  /** Own new operator reusing memory. */
579
1025
  void *operator new (size_t);
580
 
  void  operator delete (void *);
 
1026
  /** Own delete operator. */
 
1027
  void operator delete (void *);
581
1028
};
582
1029
 
 
1030
/** \class CT_ConversionName CTree.h Puma/CTree.h
 
1031
 *  Tree node representing the name of a conversion function. */
583
1032
class CT_ConversionName : public CT_SpecialName {
584
1033
public:
585
 
  CT_ConversionName (CTree *, CTree *);
 
1034
  /** Constructor.
 
1035
   *  \param f The operator function keyword 'operator'.
 
1036
   *  \param t The sub-tree containing the conversion type. */
 
1037
  CT_ConversionName (CTree *f, CTree *t);
 
1038
  /** Get the identifier for this node type. Can be compared with NodeName(). */
586
1039
  static const char *NodeId ();
 
1040
  /** Get the name of the node. Can be compared with NodeId(). */
587
1041
  const char *NodeName () const { return NodeId (); }
 
1042
  /** Get the conversion type. */
588
1043
  CT_NamedType *TypeName () const { return (CT_NamedType*)Son (Sons ()-1); }
589
 
  // special new / delete with reusing memory
 
1044
 
 
1045
public:
 
1046
  /** Own new operator reusing memory. */
590
1047
  void *operator new (size_t);
591
 
  void  operator delete (void *);
 
1048
  /** Own delete operator. */
 
1049
  void operator delete (void *);
592
1050
};
593
1051
 
 
1052
/** \class CT_QualName CTree.h Puma/CTree.h
 
1053
 *  Tree node representing a qualified name, e.g. X::Y::Z. */
594
1054
class CT_QualName : public CT_SimpleName {
595
1055
public:
 
1056
  /** Constructor.
 
1057
   *  \param size The initial number sub-names plus separators. */
596
1058
  CT_QualName (int size = 3) : 
597
1059
    CT_SimpleName (size, CT_List::SEPARATORS) {}
 
1060
  /** Get the identifier for this node type. Can be compared with NodeName(). */
598
1061
  static const char *NodeId ();
 
1062
  /** Get the name of the node. Can be compared with NodeId(). */
599
1063
  const char *NodeName () const { return NodeId (); }
600
 
  void print (ostream &) const;
 
1064
  /** Print the qualified name on the given stream. 
 
1065
   *  \param os The output stream. */
 
1066
  void print (ostream &os) const;
 
1067
  /** Get the last name of the qualified name, e.g. Z of qualified name X::Y::Z. */
601
1068
  CT_SimpleName *Name () const { return (CT_SimpleName*)Son (Sons ()-1); }
 
1069
  /** Get the string containing the last name of the qualified name. */
602
1070
  const char *Text () const { return Name ()->Text (); }
 
1071
  /** Get the type of the last name. */
603
1072
  CTypeInfo *Type () const { return Name ()->Type (); }
 
1073
  /** Get the value of the last name. */
604
1074
  CExprValue *Value () const { return Name ()->Value (); }
 
1075
  /** Get the semantic value object of the last name. */
605
1076
  CSemValue *SemValue () const { return Name ()->SemValue (); }
 
1077
  /** Get the semantic information object of the last name. */
606
1078
  CSemObject *SemObject () const { return Name ()->SemObject (); }
607
 
  // special new / delete with reusing memory
 
1079
 
 
1080
public:
 
1081
  /** Own new operator reusing memory. */
608
1082
  void *operator new (size_t);
609
 
  void  operator delete (void *);
 
1083
  /** Own delete operator. */
 
1084
  void operator delete (void *);
610
1085
};
611
1086
 
 
1087
/** \class CT_RootQualName CTree.h Puma/CTree.h
 
1088
 *  Tree node representing a qualified name with introducing name separator,
 
1089
 *  e.g. ::X::Y::Z. */
612
1090
class CT_RootQualName : public CT_QualName {
613
1091
public:
 
1092
  /** Constructor.
 
1093
   *  \param size Initial number of sub-name plus separator. */
614
1094
  CT_RootQualName (int size = 2) : 
615
1095
    CT_QualName (size) { AddProperties (INTRO); }
 
1096
  /** Get the identifier for this node type. Can be compared with NodeName(). */
616
1097
  static const char *NodeId ();
 
1098
  /** Get the name of the node. Can be compared with NodeId(). */
617
1099
  const char *NodeName () const { return NodeId (); }
618
 
  // special new / delete with reusing memory
 
1100
 
 
1101
public:
 
1102
  /** Own new operator reusing memory. */
619
1103
  void *operator new (size_t);
620
 
  void  operator delete (void *);
 
1104
  /** Own delete operator. */
 
1105
  void operator delete (void *);
621
1106
};
622
1107
 
623
 
class CT_BinaryExpr : public CT_Expression {
 
1108
/** \class CT_BinaryExpr CTree.h Puma/CTree.h
 
1109
 *  Tree node representing a binary expression, e.g. a+b. */
 
1110
class CT_BinaryExpr : public CT_Call {
624
1111
  CTree *sons[3]; // expr, oper, expr
625
1112
 
626
1113
public:
 
1114
  /** Constructor. 
 
1115
   *  \param l Left hand side of the expression. 
 
1116
   *  \param o The operator token. 
 
1117
   *  \param r Right hand side of the expression. */
627
1118
  CT_BinaryExpr (CTree *l, CTree *o, CTree *r) {
628
 
    sons[0] = l; sons[1] = o; sons[2] = r;
 
1119
    AddSon (sons[0], l); AddSon (sons[1], o); AddSon (sons[2], r);
629
1120
  }
 
1121
  /** Get the identifier for this node type. Can be compared with NodeName(). */
630
1122
  static const char *NodeId ();
 
1123
  /** Get the name of the node. Can be compared with NodeId(). */
631
1124
  const char *NodeName () const { return NodeId (); }
 
1125
  /** Get the number of sons. */
632
1126
  int Sons () const { return 3; }
 
1127
  /** Get the n-th son.
 
1128
   *  \param n The index of the son.
 
1129
   *  \return The n-th son or NULL. */
633
1130
  CTree *Son (int n) const { return CTree::Son (sons, 3, n); }
 
1131
  /** Replace a son.
 
1132
   *  \param old_son The son to replace.
 
1133
   *  \param new_son The new son. */
634
1134
  void ReplaceSon (CTree *old_son, CTree *new_son) { 
635
1135
    CTree::ReplaceSon (sons, 3, old_son, new_son);
636
1136
  }
637
1137
};
638
1138
 
639
 
class CT_MembPtrExpr : public CT_BinaryExpr, public CSemObject {
 
1139
/** \class CT_MembPtrExpr CTree.h Puma/CTree.h
 
1140
 *  Tree node representing a member pointer expression, e.g. a->b. */
 
1141
class CT_MembPtrExpr : public CT_Expression, public CSemObject {
 
1142
  CTree *sons[3]; // expr, oper, expr
 
1143
  
640
1144
public:
641
 
  CT_MembPtrExpr (CTree *e, CTree *o, CTree *i) :
642
 
    CT_BinaryExpr (e, o, i) {}
 
1145
  /** Constructor.
 
1146
   *  \param e Expression on which to call the member.
 
1147
   *  \param o The arrow operator token.
 
1148
   *  \param i The member name. */
 
1149
  CT_MembPtrExpr (CTree *e, CTree *o, CTree *i) {
 
1150
    AddSon (sons[0], e); AddSon (sons[1], o); AddSon (sons[2], i);
 
1151
  }
 
1152
  /** Get the identifier for this node type. Can be compared with NodeName(). */
643
1153
  static const char *NodeId ();
 
1154
  /** Get the name of the node. Can be compared with NodeId(). */
644
1155
  const char *NodeName () const { return NodeId (); }
645
 
  CSemObject *SemObject () const { return (CSemObject*)this; }
 
1156
  /** Get the number of sons. */
 
1157
  int Sons () const { return 3; }
 
1158
  /** Get the n-th son.
 
1159
   *  \param n The index of the son.
 
1160
   *  \return The n-th son or NULL. */
 
1161
  CTree *Son (int n) const { return CTree::Son (sons, 3, n); }
 
1162
  /** Replace a son.
 
1163
   *  \param old_son The son to replace.
 
1164
   *  \param new_son The new son. */
 
1165
  void ReplaceSon (CTree *old_son, CTree *new_son) { 
 
1166
    CTree::ReplaceSon (sons, 3, old_son, new_son);
 
1167
  }
646
1168
};
647
1169
 
 
1170
/** \class CT_MembRefExpr CTree.h Puma/CTree.h
 
1171
 *  Tree node representing a member reference expression, e.g. a.b. */
648
1172
class CT_MembRefExpr : public CT_MembPtrExpr {
649
1173
public:
 
1174
  /** Constructor.
 
1175
   *  \param e Expression on which to call the member.
 
1176
   *  \param o The dot operator.
 
1177
   *  \param i The member name. */
650
1178
  CT_MembRefExpr (CTree *e, CTree *o, CTree *i) :
651
1179
    CT_MembPtrExpr (e, o, i) {}
 
1180
  /** Get the identifier for this node type. Can be compared with NodeName(). */
652
1181
  static const char *NodeId ();
 
1182
  /** Get the name of the node. Can be compared with NodeId(). */
653
1183
  const char *NodeName () const { return NodeId (); }
654
1184
};
655
1185
 
656
 
class CT_UnaryExpr : public CT_Expression {
 
1186
/** \class CT_UnaryExpr CTree.h Puma/CTree.h
 
1187
 *  Base class for tree nodes representing unary expressions. */
 
1188
class CT_UnaryExpr : public CT_Call {
657
1189
  CTree *sons[2]; // oper, expr
658
1190
 
659
1191
public:
660
 
  CT_UnaryExpr (CTree *o, CTree *e) { sons[0] = o; sons[1] = e; }
 
1192
  /** Constructor.
 
1193
   *  \param o The unary operator.
 
1194
   *  \param e The expression on which the operator is invoked. */
 
1195
  CT_UnaryExpr (CTree *o, CTree *e) { AddSon (sons[0], o); AddSon (sons[1], e); }
 
1196
  /** Get the identifier for this node type. Can be compared with NodeName(). */
661
1197
  static const char *NodeId ();
 
1198
  /** Get the name of the node. Can be compared with NodeId(). */
662
1199
  const char *NodeName () const { return NodeId (); }
 
1200
  /** Get the number of sons. */
663
1201
  int Sons () const { return 2; }
 
1202
  /** Get the n-th son.
 
1203
   *  \param n The index of the son.
 
1204
   *  \return The n-th son or NULL. */
664
1205
  CTree *Son (int n) const { return CTree::Son (sons, 2, n); }
 
1206
  /** Replace a son.
 
1207
   *  \param old_son The son to replace.
 
1208
   *  \param new_son The new son. */
665
1209
  void ReplaceSon (CTree *old_son, CTree *new_son) { 
666
1210
    CTree::ReplaceSon (sons, 2, old_son, new_son);
667
1211
  }
 
1212
  /** Get the expression node. */
668
1213
  CTree *Expr () const { return sons[1]; }
669
1214
};
670
1215
 
 
1216
/** \class CT_PostfixExpr CTree.h Puma/CTree.h
 
1217
 *  Tree node representing a postfix expression, e.g. a++. */
671
1218
class CT_PostfixExpr : public CT_UnaryExpr {
672
1219
public:
 
1220
  /** Constructor.
 
1221
   *  \param e The expression on which to invoke the operator. 
 
1222
   *  \param o The postfix operator. */
673
1223
  CT_PostfixExpr (CTree *e, CTree *o) :
674
1224
    CT_UnaryExpr (e, o) {}
 
1225
  /** Get the identifier for this node type. Can be compared with NodeName(). */
675
1226
  static const char *NodeId ();
 
1227
  /** Get the name of the node. Can be compared with NodeId(). */
676
1228
  const char *NodeName () const { return NodeId (); }
677
1229
};
678
1230
 
 
1231
/** \class CT_AddrExpr CTree.h Puma/CTree.h
 
1232
 *  Tree node representing an address expression, e.g. &a. */
679
1233
class CT_AddrExpr : public CT_UnaryExpr {
680
1234
public:
 
1235
  /** Constructor.
 
1236
   *  \param o The address operator, i.e. '&'.
 
1237
   *  \param e The expression from which to take the address. */
681
1238
  CT_AddrExpr (CTree *o, CTree *e) :
682
1239
    CT_UnaryExpr (o, e) {}
 
1240
  /** Get the identifier for this node type. Can be compared with NodeName(). */
683
1241
  static const char *NodeId ();
 
1242
  /** Get the name of the node. Can be compared with NodeId(). */
684
1243
  const char *NodeName () const { return NodeId (); }
685
1244
};
686
1245
 
 
1246
/** \class CT_DerefExpr CTree.h Puma/CTree.h
 
1247
 *  Tree node representing a pointer dereferencing expression, e.g. *a. */
687
1248
class CT_DerefExpr : public CT_UnaryExpr {
688
1249
public:
 
1250
  /** Constructor.
 
1251
   *  \param o The dereferencing operator, i.e. '*'.
 
1252
   *  \param e The expression to dereference. */
689
1253
  CT_DerefExpr (CTree *o, CTree *e) :
690
1254
    CT_UnaryExpr (o, e) {}
 
1255
  /** Get the identifier for this node type. Can be compared with NodeName(). */
691
1256
  static const char *NodeId ();
 
1257
  /** Get the name of the node. Can be compared with NodeId(). */
692
1258
  const char *NodeName () const { return NodeId (); }
693
1259
};
694
1260
 
 
1261
/** \class CT_DeleteExpr CTree.h Puma/CTree.h
 
1262
 *  Tree node representing a delete expression, e.g. delete a. */
695
1263
class CT_DeleteExpr : public CT_Expression, public CSemObject {
696
1264
  CTree *sons[2]; // oper, expr
697
1265
 
698
1266
public:
699
 
  CT_DeleteExpr (CTree *op, CTree *e) { sons[0] = op; sons[1] = e; }
 
1267
  /** Constructor.
 
1268
   *  \param op The delete operator.
 
1269
   *  \param e The expression representing the object to delete. */
 
1270
  CT_DeleteExpr (CTree *op, CTree *e) { AddSon (sons[0], op); AddSon (sons[1], e); }
 
1271
  /** Get the identifier for this node type. Can be compared with NodeName(). */
700
1272
  static const char *NodeId ();
 
1273
  /** Get the name of the node. Can be compared with NodeId(). */
701
1274
  const char *NodeName () const { return NodeId (); }
 
1275
  /** Get the number of sons. */
702
1276
  int Sons () const { return 2; }
 
1277
  /** Get the n-th son.
 
1278
   *  \param n The index of the son.
 
1279
   *  \return The n-th son or NULL. */
703
1280
  CTree *Son (int n) const { return CTree::Son (sons, 2, n); }
 
1281
  /** Replace a son.
 
1282
   *  \param old_son The son to replace.
 
1283
   *  \param new_son The new son. */
704
1284
  void ReplaceSon (CTree *old_son, CTree *new_son) { 
705
1285
    CTree::ReplaceSon (sons, 2, old_son, new_son);
706
1286
  }
 
1287
  /** Get the expression. */
707
1288
  CTree *Expr () const { return sons[1]; }
 
1289
  /** Get the operator name, i.e. 'delete' or 'delete[]'. */
708
1290
  CT_SimpleName *OperName () const { return (CT_SimpleName*)sons[0]; }
 
1291
  /** Get the semantic information object. */
709
1292
  CSemObject *SemObject () const { return (CSemObject*)this; }
710
1293
};
711
1294
 
 
1295
/** \class CT_NewExpr CTree.h Puma/CTree.h
 
1296
 *  Tree node representing a new expression, e.g. new A(). */
712
1297
class CT_NewExpr : public CT_Expression, public CSemObject {
713
1298
  CTree *sons[6]; // oper, placement, open, type, close, init
714
1299
 
715
1300
public:
 
1301
  /** Constructor.
 
1302
   *  \param op The new operator.
 
1303
   *  \param p The optional placement expression.
 
1304
   *  \param o The optional left parenthesis around the type identifier.
 
1305
   *  \param t The type identifier specifying the type of the object to create.
 
1306
   *  \param c The optional right parenthesis around the type identifier.
 
1307
   *  \param i The optional initializer. */
716
1308
  CT_NewExpr (CTree *op, CTree *p, CTree *o, CTree *t, CTree *c, CTree *i) {
717
 
    sons[0] = op; sons[1] = p; sons[2] = o; sons[3] = t; sons[4] = c; sons[5] = i; 
 
1309
    AddSon (sons[0], op); AddSon (sons[1], p); AddSon (sons[2], o); 
 
1310
    AddSon (sons[3], t); AddSon (sons[4], c); AddSon (sons[5], i); 
718
1311
  }
 
1312
  /** Get the identifier for this node type. Can be compared with NodeName(). */
719
1313
  static const char *NodeId ();
 
1314
  /** Get the name of the node. Can be compared with NodeId(). */
720
1315
  const char *NodeName () const { return NodeId (); }
 
1316
  /** Get the number of sons. */
721
1317
  int Sons () const { return CTree::Sons (sons, 6); }
 
1318
  /** Get the n-th son.
 
1319
   *  \param n The index of the son.
 
1320
   *  \return The n-th son or NULL. */
722
1321
  CTree *Son (int n) const { return CTree::Son (sons, 6, n); }
 
1322
  /** Replace a son.
 
1323
   *  \param old_son The son to replace.
 
1324
   *  \param new_son The new son. */
723
1325
  void ReplaceSon (CTree *old_son, CTree *new_son) { 
724
1326
    CTree::ReplaceSon (sons, 6, old_son, new_son);
725
1327
  }
 
1328
  /** Get the operator name. */
726
1329
  CT_SimpleName *OperName () const { return (CT_SimpleName*)sons[0]; }
 
1330
  /** Get the placement expression. */
727
1331
  CT_ExprList *Placement () const { return (CT_ExprList*)sons[1];; }
 
1332
  /** Get the initializer. */
728
1333
  CT_ExprList *Initializer () const { return (CT_ExprList*)sons[5]; }
 
1334
  /** Get the type of the object to create. */
729
1335
  CT_NamedType *TypeName () const { return (CT_NamedType*)sons[3]; }
 
1336
  /** Get the semantic information object. */
730
1337
  CSemObject *SemObject () const { return (CSemObject*)this; }
731
1338
};
732
1339
 
 
1340
/** \class CT_IfThenExpr CTree.h Puma/CTree.h
 
1341
 *  Tree node representing an if-then expression, 
 
1342
 *  e.g. a>0?a:b or a?:b. */
733
1343
class CT_IfThenExpr : public CT_Expression {
734
1344
  CTree *sons[5]; // cond, oper, left, colon, right
735
1345
 
736
1346
public:
 
1347
  /** Constructor.
 
1348
   *  \param c1 The condition expression.
 
1349
   *  \param o The question mark operator. 
 
1350
   *  \param l The expression to the left of the colon.
 
1351
   *  \param c2 The colon operator.
 
1352
   *  \param r The expression to the right of the colon. */ 
737
1353
  CT_IfThenExpr (CTree *c1, CTree *o, CTree *l, CTree *c2, CTree *r) {
738
 
    sons[0] = c1; sons[1] = o; sons[2] = l; sons[3] = c2; sons[4] = r;
 
1354
    AddSon (sons[0], c1); AddSon (sons[1], o); AddSon (sons[2], l); 
 
1355
    AddSon (sons[3], c2); AddSon (sons[4], r);
739
1356
  }
 
1357
  /** Constructor.
 
1358
   *  \param c1 The condition expression.
 
1359
   *  \param o The question mark operator. 
 
1360
   *  \param c2 The colon operator.
 
1361
   *  \param r The expression to the right of the colon. */ 
740
1362
  CT_IfThenExpr (CTree *c1, CTree *o, CTree *c2, CTree *r) {
741
 
    sons[0] = c1; sons[1] = o; sons[2] = 0; sons[3] = c2; sons[4] = r;
 
1363
    AddSon (sons[0], c1); AddSon (sons[1], o); AddSon (sons[2], 0); 
 
1364
    AddSon (sons[3], c2); AddSon (sons[4], r);
742
1365
  }
 
1366
  /** Get the identifier for this node type. Can be compared with NodeName(). */
743
1367
  static const char *NodeId ();
 
1368
  /** Get the name of the node. Can be compared with NodeId(). */
744
1369
  const char *NodeName () const { return NodeId (); }
 
1370
  /** Get the number of sons. */
745
1371
  int Sons () const { return CTree::Sons (sons, 5); }
 
1372
  /** Get the n-th son.
 
1373
   *  \param n The index of the son.
 
1374
   *  \return The n-th son or NULL. */
746
1375
  CTree *Son (int n) const { return CTree::Son (sons, 5, n); }
 
1376
  /** Get the condition expression. */
747
1377
  CTree *Condition () const { return sons[0]; }
 
1378
  /** Get the left expression (condition=true). */
748
1379
  CTree *LeftOperand () const { return sons[2]; }
 
1380
  /** Get the right expression (condition=false). */
749
1381
  CTree *RightOperand () const { return sons[4]; }
 
1382
  /** Replace a son.
 
1383
   *  \param old_son The son to replace.
 
1384
   *  \param new_son The new son. */
750
1385
  void ReplaceSon (CTree *old_son, CTree *new_son) { 
751
1386
    CTree::ReplaceSon (sons, 5, old_son, new_son);
752
1387
  }
753
1388
};
754
1389
 
 
1390
/** \class CT_CmpdLiteral CTree.h Puma/CTree.h
 
1391
 *  Tree node representing a compound literal, e.g. (int[]){1,2,3). */
755
1392
class CT_CmpdLiteral : public CT_Expression, public CSemObject {
756
1393
  CTree *sons[4]; // open, type, close, init
757
1394
 
758
1395
public:
 
1396
  /** Constructor.
 
1397
   *  \param r Left parenthesis of the type name.
 
1398
   *  \param t The type name.
 
1399
   *  \param cr Right parenthesis of the type name.
 
1400
   *  \param i The initializer list. */
759
1401
  CT_CmpdLiteral (CTree *r, CTree *t, CTree *cr, CTree *i) {
760
 
    sons[0] = r; sons[1] = t; sons[2] = cr; sons[3] = i;
 
1402
    AddSon (sons[0], r); AddSon (sons[1], t); 
 
1403
    AddSon (sons[2], cr); AddSon (sons[3], i);
761
1404
  }
 
1405
  /** Get the identifier for this node type. Can be compared with NodeName(). */
762
1406
  static const char *NodeId ();
 
1407
  /** Get the name of the node. Can be compared with NodeId(). */
763
1408
  const char *NodeName () const { return NodeId (); }
 
1409
  /** Get the number of sons. */
764
1410
  int Sons () const { return 4; }
 
1411
  /** Get the n-th son.
 
1412
   *  \param n The index of the son.
 
1413
   *  \return The n-th son or NULL. */
765
1414
  CTree *Son (int n) const { return CTree::Son (sons, 4, n); }
 
1415
  /** Replace a son.
 
1416
   *  \param old_son The son to replace.
 
1417
   *  \param new_son The new son. */
766
1418
  void ReplaceSon (CTree *old_son, CTree *new_son) { 
767
1419
    CTree::ReplaceSon (sons, 4, old_son, new_son);
768
1420
  }
 
1421
  /** Get the type name. */
769
1422
  CT_NamedType *TypeName () const { return (CT_NamedType*)sons[1]; }
 
1423
  /** Get the initializer list. */
770
1424
  CT_ExprList *Initializer () const { return (CT_ExprList*)sons[3]; }
 
1425
  /** Get the semantic information object. */
771
1426
  CSemObject *SemObject () const { return (CSemObject*)this; }
772
1427
};
773
1428
 
 
1429
/** \class CT_ConstructExpr CTree.h Puma/CTree.h
 
1430
 *  Tree node representing a construct expression, e.g. std::string("abc"). */
774
1431
class CT_ConstructExpr : public CT_Expression, public CSemObject {
775
1432
  CTree *sons[2]; // type, init
776
1433
 
777
1434
public:
778
 
  CT_ConstructExpr (CTree *t, CTree *i) { sons[0] = t; sons[1] = i; }
 
1435
  /** Constructor.
 
1436
   *  \param t The type name.
 
1437
   *  \param i The initializer list. */
 
1438
  CT_ConstructExpr (CTree *t, CTree *i) { AddSon (sons[0], t); AddSon (sons[1], i); }
 
1439
  /** Get the identifier for this node type. Can be compared with NodeName(). */
779
1440
  static const char *NodeId ();
 
1441
  /** Get the name of the node. Can be compared with NodeId(). */
780
1442
  const char *NodeName () const { return NodeId (); }
 
1443
  /** Get the number of sons. */
781
1444
  int Sons () const { return 2; }
 
1445
  /** Get the n-th son.
 
1446
   *  \param n The index of the son.
 
1447
   *  \return The n-th son or NULL. */
782
1448
  CTree *Son (int n) const { return CTree::Son (sons, 2, n); }
 
1449
  /** Replace a son.
 
1450
   *  \param old_son The son to replace.
 
1451
   *  \param new_son The new son. */
783
1452
  void ReplaceSon (CTree *old_son, CTree *new_son) { 
784
1453
    CTree::ReplaceSon (sons, 2, old_son, new_son);
785
1454
  }
 
1455
  /** Get the type name. */
786
1456
  CT_NamedType *TypeName () const { return (CT_NamedType*)sons[0]; }
 
1457
  /** Get the initializer. */
787
1458
  CT_ExprList *Initializer () const { return (CT_ExprList*)sons[1]; }
 
1459
  /** Get the semantic information object. */
788
1460
  CSemObject *SemObject () const { return (CSemObject*)this; }
789
1461
};
790
1462
 
 
1463
/** \class CT_ThrowExpr CTree.h Puma/CTree.h
 
1464
 *  Tree node representing a throw expression, e.g. throw std::exception(). */
791
1465
class CT_ThrowExpr : public CT_Expression {
792
1466
  CTree *sons[2]; // throw, expr
793
1467
 
794
1468
public:
795
 
  CT_ThrowExpr (CTree *t, CTree *e = (CTree*)0) { sons[0] = t; sons[1] = e; }
 
1469
  /** Constructor.
 
1470
   *  \param t The 'throw' keyword.
 
1471
   *  \param e The expression. */
 
1472
  CT_ThrowExpr (CTree *t, CTree *e = (CTree*)0) { AddSon (sons[0], t); AddSon (sons[1], e); }
 
1473
  /** Get the identifier for this node type. Can be compared with NodeName(). */
796
1474
  static const char *NodeId ();
 
1475
  /** Get the name of the node. Can be compared with NodeId(). */
797
1476
  const char *NodeName () const { return NodeId (); }
 
1477
  /** Get the number of sons. */
798
1478
  int Sons () const { return CTree::Sons (sons, 2); }
 
1479
  /** Get the n-th son.
 
1480
   *  \param n The index of the son.
 
1481
   *  \return The n-th son or NULL. */
799
1482
  CTree *Son (int n) const { return CTree::Son (sons, 2, n); }
 
1483
  /** Replace a son.
 
1484
   *  \param old_son The son to replace.
 
1485
   *  \param new_son The new son. */
800
1486
  void ReplaceSon (CTree *old_son, CTree *new_son) { 
801
1487
    CTree::ReplaceSon (sons, 2, old_son, new_son);
802
1488
  }
 
1489
  /** Get the expression. */
803
1490
  CTree *Expr () const { return sons[1]; }
804
1491
};
805
1492
 
806
 
class CT_IndexExpr : public CT_Expression {
 
1493
/** \class CT_IndexExpr CTree.h Puma/CTree.h
 
1494
 *  Tree node representing an index expression. */
 
1495
class CT_IndexExpr : public CT_Call {
807
1496
  CTree *sons[4]; // expr, open, index, close
808
1497
 
809
1498
public:
 
1499
  /** Constructor.
 
1500
   *  \param e The expression on which to invoke the index operator.
 
1501
   *  \param o Left parenthesis of the index expression.
 
1502
   *  \param i The index expression. 
 
1503
   *  \param c Right parenthesis of the index expression. */
810
1504
  CT_IndexExpr (CTree *e, CTree *o, CTree *i, CTree *c) {
811
 
    sons[0] = e; sons[1] = o; sons[2] = i; sons[3] = c;
 
1505
    AddSon (sons[0], e); AddSon (sons[1], o); 
 
1506
    AddSon (sons[2], i); AddSon (sons[3], c);
812
1507
  }
 
1508
  /** Get the identifier for this node type. Can be compared with NodeName(). */
813
1509
  static const char *NodeId ();
 
1510
  /** Get the name of the node. Can be compared with NodeId(). */
814
1511
  const char *NodeName () const { return NodeId (); }
 
1512
  /** Get the number of sons. */
815
1513
  int Sons () const { return 4; }
 
1514
  /** Get the n-th son.
 
1515
   *  \param n The index of the son.
 
1516
   *  \return The n-th son or NULL. */
816
1517
  CTree *Son (int n) const { return CTree::Son (sons, 4, n); }
 
1518
  /** Replace a son.
 
1519
   *  \param old_son The son to replace.
 
1520
   *  \param new_son The new son. */
817
1521
  void ReplaceSon (CTree *old_son, CTree *new_son) { 
818
1522
    CTree::ReplaceSon (sons, 4, old_son, new_son);
819
1523
  }
820
1524
};
821
1525
 
822
 
class CT_CallExpr : public CT_Expression, public CSemObject {
 
1526
/** \class CT_CallExpr CTree.h Puma/CTree.h
 
1527
 *  Tree node representing a function call expression, e.g. f(i). */
 
1528
class CT_CallExpr : public CT_Call {
823
1529
  CTree *sons[2]; // expr, args
824
1530
 
825
1531
public:
826
 
  CT_CallExpr (CTree *e) { sons[0] = e; sons[1] = 0; }
827
 
  CT_CallExpr (CTree *e, CTree *l) { sons[0] = e; sons[1] = l; }
 
1532
  /** Constructor.
 
1533
   *  \param e The expression on which the call is invoked. */
 
1534
  CT_CallExpr (CTree *e) { AddSon (sons[0], e); AddSon (sons[1], 0); }
 
1535
  /** Constructor.
 
1536
   *  \param e The expression on which the call is invoked.
 
1537
   *  \param l The argument list of the call. */
 
1538
  CT_CallExpr (CTree *e, CTree *l) { AddSon (sons[0], e); AddSon (sons[1], l); }
 
1539
  /** Get the identifier for this node type. Can be compared with NodeName(). */
828
1540
  static const char *NodeId ();
 
1541
  /** Get the name of the node. Can be compared with NodeId(). */
829
1542
  const char *NodeName () const { return NodeId (); }
 
1543
  /** Get the number of sons. */
830
1544
  int Sons () const { return CTree::Sons (sons, 2); }
 
1545
  /** Get the n-th son.
 
1546
   *  \param n The index of the son.
 
1547
   *  \return The n-th son or NULL. */
831
1548
  CTree *Son (int n) const { return CTree::Son (sons, 2, n); } 
 
1549
  /** Replace a son.
 
1550
   *  \param old_son The son to replace.
 
1551
   *  \param new_son The new son. */
832
1552
  void ReplaceSon (CTree *old_son, CTree *new_son) { 
833
1553
    CTree::ReplaceSon (sons, 2, old_son, new_son);
834
1554
  }
835
1555
  CTree *Expr () const { return sons[0]; }
836
1556
  CT_ExprList *Arguments () const { return (CT_ExprList*)sons[1]; }
837
 
  CSemObject *SemObject () const { return (CSemObject*)this; }
838
1557
};
839
1558
 
 
1559
/** \class CT_CastExpr CTree.h Puma/CTree.h
 
1560
 *  Tree node representing a cast expression, e.g. (int)a. */
840
1561
class CT_CastExpr : public CT_Expression {
841
1562
  CTree *sons[4]; // open, type, close, expr
842
1563
 
843
1564
public:
 
1565
  /** Constructor.
 
1566
   *  \param o Left parenthesis of the type name.
 
1567
   *  \param t The type to cast to.
 
1568
   *  \param c Right parenthesis of the type name. 
 
1569
   *  \param e The expression to cast. */
844
1570
  CT_CastExpr (CTree *o, CTree *t, CTree *c, CTree *e) {
845
 
    sons[0] = o; sons[1] = t; sons[2] = c; sons[3] = e;
 
1571
    AddSon (sons[0], o); AddSon (sons[1], t); 
 
1572
    AddSon (sons[2], c); AddSon (sons[3], e);
846
1573
  }
 
1574
  /** Get the identifier for this node type. Can be compared with NodeName(). */
847
1575
  static const char *NodeId ();
 
1576
  /** Get the name of the node. Can be compared with NodeId(). */
848
1577
  const char *NodeName () const { return NodeId (); }
 
1578
  /** Get the number of sons. */
849
1579
  int Sons () const { return 4; }
 
1580
  /** Get the n-th son.
 
1581
   *  \param n The index of the son.
 
1582
   *  \return The n-th son or NULL. */
850
1583
  CTree *Son (int n) const { return CTree::Son (sons, 4, n); }
 
1584
  /** Replace a son.
 
1585
   *  \param old_son The son to replace.
 
1586
   *  \param new_son The new son. */
851
1587
  void ReplaceSon (CTree *old_son, CTree *new_son) { 
852
1588
    CTree::ReplaceSon (sons, 4, old_son, new_son);
853
1589
  }
 
1590
  /** Get the casted expression. */
854
1591
  CTree *Expr () const { return sons[3]; }
 
1592
  /** Get the type to cast to. */
855
1593
  CT_NamedType *TypeName () const { return (CT_NamedType*)sons[1]; }
856
1594
};
857
1595
 
 
1596
/** \class CT_StaticCast CTree.h Puma/CTree.h
 
1597
 *  Tree node representing a static cast, e.g. static_cast<int>(a). */
858
1598
class CT_StaticCast : public CT_Expression {
859
1599
  CTree *sons[5]; // cast, open, type, close, expr
860
1600
 
861
1601
public:
 
1602
  /** Constructor.
 
1603
   *  \param cst The cast operator, i.e. 'static_cast'.
 
1604
   *  \param o Left arrow bracket of the type name.
 
1605
   *  \param t The type to cast to.
 
1606
   *  \param c Right array bracket of the type name.
 
1607
   *  \param e The expression to cast. */
862
1608
  CT_StaticCast (CTree *cst, CTree *o, CTree *t, CTree *c, CTree *e) {
863
 
    sons[0] = cst; sons[1] = o; sons[2] = t; sons[3] = c; sons[4] = e;
 
1609
    AddSon (sons[0], cst); AddSon (sons[1], o); AddSon (sons[2], t); 
 
1610
    AddSon (sons[3], c); AddSon (sons[4], e);
864
1611
  }
 
1612
  /** Get the identifier for this node type. Can be compared with NodeName(). */
865
1613
  static const char *NodeId ();
 
1614
  /** Get the name of the node. Can be compared with NodeId(). */
866
1615
  const char *NodeName () const { return NodeId (); }
 
1616
  /** Get the number of sons. */
867
1617
  int Sons () const { return 5; }
 
1618
  /** Get the n-th son.
 
1619
   *  \param n The index of the son.
 
1620
   *  \return The n-th son or NULL. */
868
1621
  CTree *Son (int n) const { return CTree::Son (sons, 5, n); }
 
1622
  /** Replace a son.
 
1623
   *  \param old_son The son to replace.
 
1624
   *  \param new_son The new son. */
869
1625
  void ReplaceSon (CTree *old_son, CTree *new_son) { 
870
1626
    CTree::ReplaceSon (sons, 5, old_son, new_son);
871
1627
  }
 
1628
  /** Get the casted expression. */
872
1629
  CTree *Expr () const { return sons[4]; }
 
1630
  /** Get the type to cast to. */
873
1631
  CT_NamedType *TypeName () const { return (CT_NamedType*)sons[2]; }
874
1632
};
875
1633
 
 
1634
/** \class CT_ConstCast CTree.h Puma/CTree.h
 
1635
 *  Tree node representing a const cast, e.g. const_cast<int>(a). */
876
1636
class CT_ConstCast : public CT_StaticCast {
877
1637
public:
 
1638
  /** Constructor.
 
1639
   *  \param cst The cast operator, i.e. 'const_cast'.
 
1640
   *  \param o Left arrow bracket of the type name.
 
1641
   *  \param t The type to cast to.
 
1642
   *  \param c Right array bracket of the type name.
 
1643
   *  \param e The expression to cast. */
878
1644
  CT_ConstCast (CTree *cst, CTree *o, CTree *t, CTree *c, CTree *e) :
879
1645
    CT_StaticCast (cst, o, t, c, e) {}
 
1646
  /** Get the identifier for this node type. Can be compared with NodeName(). */
880
1647
  static const char *NodeId ();
 
1648
  /** Get the name of the node. Can be compared with NodeId(). */
881
1649
  const char *NodeName () const { return NodeId (); }
882
1650
};
883
1651
 
 
1652
/** \class CT_ReintCast CTree.h Puma/CTree.h
 
1653
 *  Tree node representing a reinterpret cast, e.g. reinterpret_cast<int>(a). */
884
1654
class CT_ReintCast : public CT_StaticCast {
885
1655
public:
 
1656
  /** Constructor.
 
1657
   *  \param cst The cast operator, i.e. 'reinterpret_cast'.
 
1658
   *  \param o Left arrow bracket of the type name.
 
1659
   *  \param t The type to cast to.
 
1660
   *  \param c Right array bracket of the type name.
 
1661
   *  \param e The expression to cast. */
886
1662
  CT_ReintCast (CTree *cst, CTree *o, CTree *t, CTree *c, CTree *e) :
887
1663
    CT_StaticCast (cst, o, t, c, e) {}
 
1664
  /** Get the identifier for this node type. Can be compared with NodeName(). */
888
1665
  static const char *NodeId ();
 
1666
  /** Get the name of the node. Can be compared with NodeId(). */
889
1667
  const char *NodeName () const { return NodeId (); }
890
1668
};
891
1669
 
 
1670
/** \class CT_DynamicCast CTree.h Puma/CTree.h
 
1671
 *  Tree node representing a dynamic cast, e.g. dynamic_cast<int>(a). */
892
1672
class CT_DynamicCast : public CT_StaticCast {
893
1673
public:
 
1674
  /** Constructor.
 
1675
   *  \param cst The cast operator, i.e. 'dynamic_cast'.
 
1676
   *  \param o Left arrow bracket of the type name.
 
1677
   *  \param t The type to cast to.
 
1678
   *  \param c Right array bracket of the type name.
 
1679
   *  \param e The expression to cast. */
894
1680
  CT_DynamicCast (CTree *cst, CTree *o, CTree *t, CTree *c, CTree *e) :
895
1681
    CT_StaticCast (cst, o, t, c, e) {}
 
1682
  /** Get the identifier for this node type. Can be compared with NodeName(). */
896
1683
  static const char *NodeId ();
 
1684
  /** Get the name of the node. Can be compared with NodeId(). */
897
1685
  const char *NodeName () const { return NodeId (); }
898
1686
};
899
1687
 
 
1688
/** \class CT_ImplicitCast CTree.h Puma/CTree.h
 
1689
 *  Tree node representing an implicit cast, e.g. int i = 1.2
 
1690
 *  where 1.2 is implicitely casted from float to int. */
900
1691
class CT_ImplicitCast : public CT_Expression {
901
1692
  CTree *_expr; // casted expression
902
1693
 
903
1694
public:
904
 
  CT_ImplicitCast (CTree *e) : _expr (e) {}
 
1695
  /** Constructor.
 
1696
   *  \param e The expression that is implicitely casted. */
 
1697
  CT_ImplicitCast (CTree *e) { AddSon (_expr, e); }
 
1698
  /** Get the identifier for this node type. Can be compared with NodeName(). */
905
1699
  static const char *NodeId ();
 
1700
  /** Get the name of the node. Can be compared with NodeId(). */
906
1701
  const char *NodeName () const { return NodeId (); }
 
1702
  /** Get the number of sons. */
907
1703
  int Sons () const { return 1; }
 
1704
  /** Get the n-th son.
 
1705
   *  \param n The index of the son.
 
1706
   *  \return The n-th son or NULL. */
908
1707
  CTree *Son (int n) const { return n == 0 ? _expr : (CTree*)0; }
 
1708
  /** Get the casted expression. */
909
1709
  CTree *Expr () const { return _expr; }
 
1710
  /** Replace a son.
 
1711
   *  \param old_son The son to replace.
 
1712
   *  \param new_son The new son. */
910
1713
  void ReplaceSon (CTree *old_son, CTree *new_son) 
911
 
   { if (old_son == _expr) _expr = new_son; }
 
1714
   { CTree::ReplaceSon (_expr, old_son, new_son); }
912
1715
};
913
1716
 
 
1717
/** \class CT_TypeidExpr CTree.h Puma/CTree.h
 
1718
 *  Tree node representing a typeid expression, e.g. typeid(X). */
914
1719
class CT_TypeidExpr : public CT_Expression {
915
1720
  CTree *sons[4]; // typeid, open, type_id/expr, close
916
1721
 
917
1722
public:
 
1723
  /** Constructor.
 
1724
   *  \param tid The 'typeid' operator.
 
1725
   *  \param o The left parenthesis of the type name or expression.
 
1726
   *  \param e The expression or type name for which to get the type identifier.
 
1727
   *  \param c The right parenthesis of the type name or expression. */
918
1728
  CT_TypeidExpr (CTree *tid, CTree *o, CTree *e, CTree *c) {
919
 
    sons[0] = tid; sons[1] = o; sons[2] = e; sons[3] = c;
 
1729
    AddSon (sons[0], tid); AddSon (sons[1], o); 
 
1730
    AddSon (sons[2], e); AddSon (sons[3], c);
920
1731
  }
 
1732
  /** Get the identifier for this node type. Can be compared with NodeName(). */
921
1733
  static const char *NodeId ();
 
1734
  /** Get the name of the node. Can be compared with NodeId(). */
922
1735
  const char *NodeName () const { return NodeId (); }
 
1736
  /** Get the number of sons. */
923
1737
  int Sons () const { return 4; }
 
1738
  /** Get the n-th son.
 
1739
   *  \param n The index of the son.
 
1740
   *  \return The n-th son or NULL. */
924
1741
  CTree *Son (int n) const { return CTree::Son (sons, 4, n); }
 
1742
  /** Replace a son.
 
1743
   *  \param old_son The son to replace.
 
1744
   *  \param new_son The new son. */
925
1745
  void ReplaceSon (CTree *old_son, CTree *new_son) { 
926
1746
    CTree::ReplaceSon (sons, 4, old_son, new_son);
927
1747
  }
 
1748
  /** Get the typeid argument, i.e. the expression or type name for
 
1749
   *  which to get the type identifier. */
928
1750
  CTree *Arg () const { return sons[2]; }
929
1751
};
930
1752
 
 
1753
/** \class CT_SizeofExpr CTree.h Puma/CTree.h
 
1754
 *  Tree node representing a sizeof expression, e.g. sizeof(int*). */
931
1755
class CT_SizeofExpr : public CT_Expression {
932
1756
  CTree *sons[5]; // key, open, type, close, expr
933
1757
 
934
1758
public:
 
1759
  /** Constructor.
 
1760
   *  \param k The 'sizeof' keyword.
 
1761
   *  \param o Left parenthesis around the type name.
 
1762
   *  \param t The type from which to get the size.
 
1763
   *  \param c Right parenthesis around the type name. */
935
1764
  CT_SizeofExpr (CTree *k, CTree *o, CTree *t, CTree *c) {
936
 
    sons[0] = k; sons[1] = o; sons[2] = t; sons[3] = c; sons[4] = 0;
 
1765
    AddSon (sons[0], k); AddSon (sons[1], o); AddSon (sons[2], t); 
 
1766
    AddSon (sons[3], c); AddSon (sons[4], 0);
937
1767
  }
 
1768
  /** Constructor.
 
1769
   *  \param k The 'sizeof' keyword.
 
1770
   *  \param e The expression from which to get the size. */
938
1771
  CT_SizeofExpr (CTree *k, CTree *e) {
939
 
    sons[0] = k; sons[1] = 0; sons[2] = 0; sons[3] = 0; sons[4] = e;
 
1772
    AddSon (sons[0], k); AddSon (sons[1], 0); AddSon (sons[2], 0); 
 
1773
    AddSon (sons[3], 0); AddSon (sons[4], e);
940
1774
  }
 
1775
  /** Get the identifier for this node type. Can be compared with NodeName(). */
941
1776
  static const char *NodeId ();
 
1777
  /** Get the name of the node. Can be compared with NodeId(). */
942
1778
  const char *NodeName () const { return NodeId (); }
 
1779
  /** Get the number of sons. */
943
1780
  int Sons () const { return CTree::Sons (sons, 5); }
 
1781
  /** Get the n-th son.
 
1782
   *  \param n The index of the son.
 
1783
   *  \return The n-th son or NULL. */
944
1784
  CTree *Son (int n) const { return CTree::Son (sons, 5, n); }
 
1785
  /** Replace a son.
 
1786
   *  \param old_son The son to replace.
 
1787
   *  \param new_son The new son. */
945
1788
  void ReplaceSon (CTree *old_son, CTree *new_son) { 
946
1789
    CTree::ReplaceSon (sons, 5, old_son, new_son);
947
1790
  }
 
1791
  /** Get the expression. */
948
1792
  CTree *Expr () const { return sons[4]; }
 
1793
  /** Get the type name. */
949
1794
  CT_NamedType *TypeName () const { return (CT_NamedType*)sons[2]; }
950
1795
};
951
1796
 
 
1797
/** \class CT_IndexDesignator CTree.h Puma/CTree.h
 
1798
 *  Tree node representing an index designator, i.e. [1]. */
952
1799
class CT_IndexDesignator : public CT_Expression {
953
1800
  CTree *sons[3]; // open, index, close
954
1801
 
955
1802
public:
 
1803
  /** Constructor.
 
1804
   *  \param o Left bracket of the index designator.
 
1805
   *  \param i The index expression.
 
1806
   *  \param c Right bracket of the index designator. */
956
1807
  CT_IndexDesignator (CTree *o, CTree *i, CTree *c) {
957
 
    sons[0] = o; sons[1] = i; sons[2] = c;
 
1808
    AddSon (sons[0], o); AddSon (sons[1], i); AddSon (sons[2], c);
958
1809
  }
 
1810
  /** Get the identifier for this node type. Can be compared with NodeName(). */
959
1811
  static const char *NodeId ();
 
1812
  /** Get the name of the node. Can be compared with NodeId(). */
960
1813
  const char *NodeName () const { return NodeId (); }
 
1814
  /** Get the number of sons. */
961
1815
  int Sons () const { return 3; }
 
1816
  /** Get the n-th son.
 
1817
   *  \param n The index of the son.
 
1818
   *  \return The n-th son or NULL. */
962
1819
  CTree *Son (int n) const { return CTree::Son (sons, 3, n); }
 
1820
  /** Replace a son.
 
1821
   *  \param old_son The son to replace.
 
1822
   *  \param new_son The new son. */
963
1823
  void ReplaceSon (CTree *old_son, CTree *new_son) { 
964
1824
    CTree::ReplaceSon (sons, 3, old_son, new_son);
965
1825
  }
966
1826
};
967
1827
 
 
1828
/** \class CT_MembDesignator CTree.h Puma/CTree.h
 
1829
 *  Tree node representing a member designator, e.g. .a. */
968
1830
class CT_MembDesignator : public CT_Expression {
969
1831
  CTree *sons[2]; // dot, member
970
1832
 
971
1833
public:
972
 
  CT_MembDesignator (CTree *d, CTree *m) { sons[0] = d; sons[1] = m; }
 
1834
  /** Constructor.
 
1835
   *  \param d The dot before the member name.
 
1836
   *  \param m The member name. */
 
1837
  CT_MembDesignator (CTree *d, CTree *m) { AddSon (sons[0], d); AddSon (sons[1], m); }
 
1838
  /** Get the identifier for this node type. Can be compared with NodeName(). */
973
1839
  static const char *NodeId ();
 
1840
  /** Get the name of the node. Can be compared with NodeId(). */
974
1841
  const char *NodeName () const { return NodeId (); }
 
1842
  /** Get the number of sons. */
975
1843
  int Sons () const { return 2; }
 
1844
  /** Get the n-th son.
 
1845
   *  \param n The index of the son.
 
1846
   *  \return The n-th son or NULL. */
976
1847
  CTree *Son (int n) const { return CTree::Son (sons, 2, n); }
 
1848
  /** Replace a son.
 
1849
   *  \param old_son The son to replace.
 
1850
   *  \param new_son The new son. */
977
1851
  void ReplaceSon (CTree *old_son, CTree *new_son) { 
978
1852
    CTree::ReplaceSon (sons, 2, old_son, new_son);
979
1853
  }
980
1854
};
981
1855
 
 
1856
/** \class CT_DesignatorSeq CTree.h Puma/CTree.h
 
1857
 *  Tree node representing a designator sequence, e.g. .a.b.c. */
982
1858
class CT_DesignatorSeq : public CT_List, public CSemValue {
983
1859
public:
 
1860
  /** Constructor.
 
1861
   *  \param size Initial number of designators. */
984
1862
  CT_DesignatorSeq (int size = 1) : CT_List (size, 2) {}
 
1863
  /** Get the identifier for this node type. Can be compared with NodeName(). */
985
1864
  static const char *NodeId ();
 
1865
  /** Get the name of the node. Can be compared with NodeId(). */
986
1866
  const char *NodeName () const { return NodeId (); }
987
1867
 
 
1868
  /** Get the type of the entity to initialize. */
988
1869
  CTypeInfo *Type () const { return type; }
 
1870
  /** Get the value of the entity to initialize. */
989
1871
  CExprValue *Value () const { return value; }
 
1872
  /** Get the semantic value object. */
990
1873
  CSemValue *SemValue () const { return (CSemValue*)this; }
991
1874
};
992
1875
 
996
1879
/*                                                                           */
997
1880
/*****************************************************************************/
998
1881
 
 
1882
/** \class CT_DeclSpec CTree.h Puma/CTree.h
 
1883
 *  Base class for all tree nodes representing declaration specifiers. */
999
1884
class CT_DeclSpec : public CTree {
1000
1885
protected:
 
1886
  /** Constructor. */
1001
1887
  CT_DeclSpec () {}
1002
1888
};
1003
1889
 
 
1890
/** \class CT_PrimDeclSpec CTree.h Puma/CTree.h
 
1891
 *  Tree node representing a primitive declaration specifier. */
1004
1892
class CT_PrimDeclSpec : public CT_DeclSpec {
1005
1893
public:
1006
 
  enum Type { PDS_FRIEND, PDS_TYPEDEF, PDS_AUTO, PDS_REGISTER, PDS_STATIC, 
1007
 
              PDS_EXTERN, PDS_MUTABLE, PDS_INLINE, PDS_VIRTUAL, PDS_EXPLICIT, 
1008
 
              PDS_CONST, PDS_VOLATILE, PDS_RESTRICT, PDS_CHAR, PDS_WCHAR_T, 
1009
 
              PDS_BOOL, PDS_SHORT, PDS_INT, PDS_LONG, PDS_SIGNED, PDS_UNSIGNED, 
1010
 
              PDS_FLOAT, PDS_DOUBLE, PDS_VOID, 
1011
 
              // AspectC++ specific type specifier
1012
 
              PDS_UNKNOWN_T,
1013
 
              // Win specific declaration specifiers
1014
 
              PDS_CDECL, PDS_STDCALL, PDS_FASTCALL, PDS_INT64,
1015
 
              PDS_UNKNOWN, PDS_NUM };
 
1894
  /** Declaration specifier types. */
 
1895
  enum Type { 
 
1896
    PDS_FRIEND,    /** friend */
 
1897
    PDS_TYPEDEF,   /** typedef */
 
1898
    PDS_AUTO,      /** auto */
 
1899
    PDS_REGISTER,  /** register */
 
1900
    PDS_STATIC,    /** static */
 
1901
    PDS_EXTERN,    /** extern */
 
1902
    PDS_MUTABLE,   /** mutable */
 
1903
    PDS_INLINE,    /** inline */
 
1904
    PDS_VIRTUAL,   /** virtual */
 
1905
    PDS_EXPLICIT,  /** explicit */
 
1906
    PDS_CONST,     /** const */
 
1907
    PDS_VOLATILE,  /** volatile */
 
1908
    PDS_RESTRICT,  /** restrict */
 
1909
    PDS_CHAR,      /** char */
 
1910
    PDS_WCHAR_T,   /** wchar_t */
 
1911
    PDS_BOOL,      /** bool */
 
1912
    PDS_SHORT,     /** short */
 
1913
    PDS_INT,       /** int */
 
1914
    PDS_LONG,      /** long */
 
1915
    PDS_SIGNED,    /** signed */
 
1916
    PDS_UNSIGNED,  /** unsigned */
 
1917
    PDS_FLOAT,     /** float */
 
1918
    PDS_DOUBLE,    /** double */
 
1919
    PDS_VOID,      /** void */
 
1920
    // AspectC++ specific type specifier
 
1921
    PDS_UNKNOWN_T, /** unknown_t */
 
1922
    // Win specific declaration specifiers
 
1923
    PDS_CDECL,     /** __cdecl */
 
1924
    PDS_STDCALL,   /** __stdcall */
 
1925
    PDS_FASTCALL,  /** __fastcall */
 
1926
    PDS_INT64,     /** __int64 */
 
1927
    PDS_UNKNOWN,   /** Unknown declaration specifier. */
 
1928
    PDS_NUM        /** Number of declaration specifier types. */
 
1929
  };
1016
1930
 
1017
1931
private:
1018
1932
  Type _type;
1019
 
  CT_Token *_token;
 
1933
  CTree *_token; // has to be a CT_Token
1020
1934
 
1021
1935
  void determine_type ();
1022
1936
 
1023
1937
public:
1024
 
  CT_PrimDeclSpec (CT_Token *t) : _token (t) { determine_type (); }
 
1938
  /** Constructor.
 
1939
   *  \param t The token containing the declaration specifier. */
 
1940
  CT_PrimDeclSpec (CT_Token *t) { AddSon (_token, (CTree*)t); determine_type (); }
 
1941
  /** Constructor.
 
1942
   *  \param t The declaration specifier type. */
1025
1943
  CT_PrimDeclSpec (Type t) : _token (0) { _type = t; }
 
1944
  /** Get the identifier for this node type. Can be compared with NodeName(). */
1026
1945
  static const char *NodeId ();
 
1946
  /** Get the name of the node. Can be compared with NodeId(). */
1027
1947
  const char *NodeName () const { return NodeId (); }
 
1948
  /** Get the number of sons. */
1028
1949
  int Sons () const { return _token ? 1 : 0; }
 
1950
  /** Get the n-th son.
 
1951
   *  \param n The index of the son.
 
1952
   *  \return The n-th son or NULL. */
1029
1953
  CTree *Son (int n) const 
1030
1954
   { return (n == 0) ? _token : (CTree*)0; }
 
1955
  /** Get the textual representation of the declaration specifier.
 
1956
   *  \return The string representation or " ". */
1031
1957
  const char *SpecText () const 
1032
 
   { return _token ? _token->token ()->text ().c_str () : " "; }
 
1958
   { return _token ? _token->token ()->text () : " "; }
 
1959
  /** Get the declaration specifier type. */
1033
1960
  Type SpecType () const { return _type; }
 
1961
  /** Number of declaration specifier types. */
1034
1962
  static const int NumTypes = PDS_NUM;
 
1963
  /** Replace a son.
 
1964
   *  \param old_son The son to replace.
 
1965
   *  \param new_son The new son. */
 
1966
  void ReplaceSon (CTree *old_son, CTree *new_son) { 
 
1967
    CTree::ReplaceSon (_token, (CTree*)old_son, (CTree*)new_son);
 
1968
    determine_type ();
 
1969
  }
1035
1970
};
1036
1971
 
 
1972
/** \class CT_NamedType CTree.h Puma/CTree.h
 
1973
 *  Tree node representing a named type, e.g. (int*)a. 
 
1974
 *  where int* is a type with a generated name. */
1037
1975
class CT_NamedType : public CT_DeclSpec, public CSemObject {
1038
1976
  CTree *sons[2]; // declspecs, declarator
1039
1977
 
1040
1978
public:
1041
 
  CT_NamedType (CTree *dss, CTree *d) { sons[0] = dss; sons[1] = d; }
 
1979
  /** Constructor.
 
1980
   *  \param dss The declaration specifier sequence of the type.
 
1981
   *  \param d The type declarator. */
 
1982
  CT_NamedType (CTree *dss, CTree *d) { AddSon (sons[0], dss); AddSon (sons[1], d); }
 
1983
  /** Get the identifier for this node type. Can be compared with NodeName(). */
1042
1984
  static const char *NodeId ();
 
1985
  /** Get the name of the node. Can be compared with NodeId(). */
1043
1986
  const char *NodeName () const { return NodeId (); }
 
1987
  /** Get the number of sons. */
1044
1988
  int Sons () const { return CTree::Sons (sons, 2); }
 
1989
  /** Get the n-th son.
 
1990
   *  \param n The index of the son.
 
1991
   *  \return The n-th son or NULL. */
1045
1992
  CTree *Son (int n) const { return CTree::Son (sons, 2, n); }
 
1993
  /** Get the declarator. */
1046
1994
  CTree *Declarator () const { return sons[1]; }
 
1995
  /** Replace a son.
 
1996
   *  \param old_son The son to replace.
 
1997
   *  \param new_son The new son. */
1047
1998
  void ReplaceSon (CTree *old_son, CTree *new_son) { 
1048
1999
    CTree::ReplaceSon (sons, 2, old_son, new_son);
1049
2000
  }
 
2001
  /** Get the semantic information object. */
1050
2002
  CSemObject *SemObject () const { return (CSemObject*)this; }
1051
2003
};
1052
2004
      
 
2005
/** \class CT_ClassSpec CTree.h Puma/CTree.h
 
2006
 *  Tree node representing a class specifier, e.g. class X. */
1053
2007
class CT_ClassSpec : public CT_DeclSpec, public CSemObject {
1054
2008
  CTree *sons[2]; // key, name
1055
2009
  
1056
2010
public:
1057
 
  CT_ClassSpec (CTree *k, CTree *n) { sons[0] = k; sons[1] = n; }
 
2011
  /** Constructor.
 
2012
   *  \param k The 'class' or 'struct' keyword.
 
2013
   *  \param n The class name. */
 
2014
  CT_ClassSpec (CTree *k, CTree *n) { AddSon (sons[0], k); AddSon (sons[1], n); }
 
2015
  /** Get the identifier for this node type. Can be compared with NodeName(). */
1058
2016
  static const char *NodeId ();
 
2017
  /** Get the name of the node. Can be compared with NodeId(). */
1059
2018
  const char *NodeName () const { return NodeId (); }
 
2019
  /** Get the number of sons. */
1060
2020
  int Sons () const { return 2; }
 
2021
  /** Get the n-th son.
 
2022
   *  \param n The index of the son.
 
2023
   *  \return The n-th son or NULL. */
1061
2024
  CTree *Son (int n) const { return CTree::Son (sons, 2, n); } 
 
2025
  /** Get the class name. */
1062
2026
  CT_SimpleName *Name () const { return (CT_SimpleName*)sons[1]; }
 
2027
  /** Get the semantic information object. */
1063
2028
  CSemObject *SemObject () const { return (CSemObject*)this; }
 
2029
  /** Replace a son.
 
2030
   *  \param old_son The son to replace.
 
2031
   *  \param new_son The new son. */
1064
2032
  void ReplaceSon (CTree *old_son, CTree *new_son) { 
1065
2033
    CTree::ReplaceSon (sons, 2, old_son, new_son);
1066
2034
  }
1067
2035
};
1068
2036
 
 
2037
/** \class CT_UnionSpec CTree.h Puma/CTree.h
 
2038
 *  Tree node representing a union specifier, e.g. union X. */
1069
2039
class CT_UnionSpec : public CT_ClassSpec {
1070
2040
public:
 
2041
  /** Constructor.
 
2042
   *  \param k The 'union' keyword.
 
2043
   *  \param n The name of the union. */
1071
2044
  CT_UnionSpec (CTree *k, CTree *n) : CT_ClassSpec (k, n) {}
 
2045
  /** Get the identifier for this node type. Can be compared with NodeName(). */
1072
2046
  static const char *NodeId ();
 
2047
  /** Get the name of the node. Can be compared with NodeId(). */
1073
2048
  const char *NodeName () const { return NodeId (); }
1074
2049
};
1075
2050
 
 
2051
/** \class CT_EnumSpec CTree.h Puma/CTree.h
 
2052
 *  Tree node representing an enumeration specifier, e.g. enum X. */
1076
2053
class CT_EnumSpec : public CT_ClassSpec {
1077
2054
public:
 
2055
  /** Constructor.
 
2056
   *  \param k The 'enum' keyword. 
 
2057
   *  \param n The name of the enumeration. */
1078
2058
  CT_EnumSpec (CTree *k, CTree *n) : CT_ClassSpec (k, n) {}
 
2059
  /** Get the identifier for this node type. Can be compared with NodeName(). */
1079
2060
  static const char *NodeId ();
 
2061
  /** Get the name of the node. Can be compared with NodeId(). */
1080
2062
  const char *NodeName () const { return NodeId (); }
1081
2063
};
1082
2064
 
 
2065
/** \class CT_ExceptionSpec CTree.h Puma/CTree.h
 
2066
 *  Tree node representing an exception specifier, e.g. throw(std::exception). */
1083
2067
class CT_ExceptionSpec : public CT_DeclSpec {
1084
2068
  CTree *sons[2]; // throw, type_id_list
1085
2069
  
1086
2070
public:
1087
 
  CT_ExceptionSpec (CTree *k, CTree *l) { sons[0] = k; sons[1] = l; }
 
2071
  /** Constructor.
 
2072
   *  \param k The 'throw' keyword.
 
2073
   *  \param l The type list for the exception type to throw. */
 
2074
  CT_ExceptionSpec (CTree *k, CTree *l) { AddSon (sons[0], k); AddSon (sons[1], l); }
 
2075
  /** Get the identifier for this node type. Can be compared with NodeName(). */
1088
2076
  static const char *NodeId ();
 
2077
  /** Get the name of the node. Can be compared with NodeId(). */
1089
2078
  const char *NodeName () const { return NodeId (); }
 
2079
  /** Get the number of sons. */
1090
2080
  int Sons () const { return 2; }
 
2081
  /** Get the n-th son.
 
2082
   *  \param n The index of the son.
 
2083
   *  \return The n-th son or NULL. */
1091
2084
  CTree *Son (int n) const { return CTree::Son (sons, 2, n); }
 
2085
  /** Get the exception type list. */
1092
2086
  CT_ArgDeclList *Arguments () const { return (CT_ArgDeclList*)sons[1]; }
 
2087
  /** Replace a son.
 
2088
   *  \param old_son The son to replace.
 
2089
   *  \param new_son The new son. */
1093
2090
  void ReplaceSon (CTree *old_son, CTree *new_son) { 
1094
2091
    CTree::ReplaceSon (sons, 2, old_son, new_son);
1095
2092
  }
1101
2098
/*                                                                           */
1102
2099
/*****************************************************************************/
1103
2100
 
 
2101
/** \class CT_Decl CTree.h Puma/CTree.h
 
2102
 *  Base class for all tree nodes representing declarations. */
1104
2103
class CT_Decl : public CTree { 
1105
2104
  CT_LinkageSpec *_linkage;
 
2105
  
1106
2106
protected:
 
2107
  /** Constructor. */
1107
2108
  CT_Decl () : _linkage (0) {}
 
2109
  
1108
2110
public:
 
2111
  /** Set the linkage of the declared entity.
 
2112
   *  \param l The linkage specifiers. */
1109
2113
  void Linkage (CT_LinkageSpec *l) { _linkage = l; }
 
2114
  /** Get the linkage specifiers. */
1110
2115
  CT_LinkageSpec *Linkage () const { return _linkage; }
 
2116
  /** Get this. */
 
2117
  virtual CT_Decl *IsDeclaration () { return this; }
1111
2118
};
1112
2119
 
 
2120
/** \class CT_Program CTree.h Puma/CTree.h
 
2121
 *  Root node of C/C++ syntax tree. */
1113
2122
class CT_Program : public CT_DeclList, public CSemScope {
1114
2123
public:
 
2124
  /** Constructor.
 
2125
   *  \param size The initial number of declarations in the program.
 
2126
   *  \param incr The initial increment count. */
1115
2127
  CT_Program (int size = 20, int incr = 20) : CT_DeclList (size, incr) {}
 
2128
  /** Get the identifier for this node type. Can be compared with NodeName(). */
1116
2129
  static const char *NodeId ();
 
2130
  /** Get the name of the node. Can be compared with NodeId(). */
1117
2131
  const char *NodeName () const { return NodeId (); }
 
2132
  /** Get the semantic scope object. */
 
2133
  CSemScope *SemScope () const { return (CSemScope*)this; }
1118
2134
};
1119
2135
   
 
2136
/** \class CT_ObjDecl CTree.h Puma/CTree.h
 
2137
 *  Tree node representing an object declaration, e.g. int *i. */
1120
2138
class CT_ObjDecl : public CT_Decl {
1121
2139
  CTree *sons[3]; // declspecs, declarators, colon
1122
2140
 
1123
2141
public:
 
2142
  /** Constructor.
 
2143
   *  \param dsl The declaration specifier sequence.
 
2144
   *  \param dl The declarator list.
 
2145
   *  \param c Optional colon. */
1124
2146
  CT_ObjDecl (CTree *dsl, CTree *dl, CTree *c) {
1125
 
    sons[0] = dsl; sons[1] = dl; sons[2] = c;
 
2147
    AddSon (sons[0], dsl); AddSon (sons[1], dl); AddSon (sons[2], c);
1126
2148
  }
 
2149
  /** Get the identifier for this node type. Can be compared with NodeName(). */
1127
2150
  static const char *NodeId ();
 
2151
  /** Get the name of the node. Can be compared with NodeId(). */
1128
2152
  const char *NodeName () const { return NodeId (); }
 
2153
  /** Get the number of sons. */
1129
2154
  int Sons () const { return 3; }
 
2155
  /** Get the n-th son.
 
2156
   *  \param n The index of the son.
 
2157
   *  \return The n-th son or NULL. */
1130
2158
  CTree *Son (int n) const { return CTree::Son (sons, 3, n); }
 
2159
  /** Get the declaration specifier sequence. */
1131
2160
  CT_DeclSpecSeq *DeclSpecs () const { return (CT_DeclSpecSeq*)sons[0]; }
 
2161
  /** Get the declarator list. */
1132
2162
  CT_DeclaratorList *Declarators () const { return (CT_DeclaratorList*)sons[1]; }
 
2163
  /** Replace a son.
 
2164
   *  \param old_son The son to replace.
 
2165
   *  \param new_son The new son. */
1133
2166
  void ReplaceSon (CTree *old_son, CTree *new_son) { 
1134
2167
    CTree::ReplaceSon (sons, 3, old_son, new_son);
1135
2168
  }
1136
2169
};
1137
2170
 
 
2171
/** \class CT_TemplateDecl CTree.h Puma/CTree.h
 
2172
 *  Tree node representing a template declaration. */
1138
2173
class CT_TemplateDecl : public CT_Decl, public CSemScope {
1139
2174
  CTree *sons[3]; // export, param_list, decl
1140
2175
 
1141
2176
public:
 
2177
  /** Constructor.
 
2178
   *  \param e Optional 'export' keyword. 
 
2179
   *  \param p The template parameter list.
 
2180
   *  \param d The class or function declaration. */
1142
2181
  CT_TemplateDecl (CTree *e, CTree *p, CTree *d) {
1143
 
    sons[0] = e; sons[1] = p; sons[2] = d;
 
2182
    AddSon (sons[0], e); AddSon (sons[1], p); AddSon (sons[2], d);
1144
2183
  }
 
2184
  /** Get the identifier for this node type. Can be compared with NodeName(). */
1145
2185
  static const char *NodeId ();
 
2186
  /** Get the name of the node. Can be compared with NodeId(). */
1146
2187
  const char *NodeName () const { return NodeId (); }
 
2188
  /** Get the number of sons. */
1147
2189
  int Sons () const { return CTree::Sons (sons, 3); }
 
2190
  /** Get the n-th son.
 
2191
   *  \param n The index of the son.
 
2192
   *  \return The n-th son or NULL. */
1148
2193
  CTree *Son (int n) const { return CTree::Son (sons, 3, n); }
 
2194
  /** Replace a son.
 
2195
   *  \param old_son The son to replace.
 
2196
   *  \param new_son The new son. */
1149
2197
  void ReplaceSon (CTree *old_son, CTree *new_son) { 
1150
2198
    CTree::ReplaceSon (sons, 3, old_son, new_son); 
1151
2199
  }
 
2200
  /** Get the 'export' keyword. */
1152
2201
  CTree *Export () const { return sons[0]; }
 
2202
  /** Get the template parameter list. */
1153
2203
  CT_TemplateParamList *Parameters () const { 
1154
2204
    return (CT_TemplateParamList*)sons[1]; 
1155
2205
  }
 
2206
  /** Get the class or function declaration. */
1156
2207
  CTree *Declaration () const { return sons[2]; }
 
2208
  /** Get the semantic scope object. */
 
2209
  CSemScope *SemScope () const { return (CSemScope*)this; }
1157
2210
};
1158
2211
 
 
2212
/** \class CT_TemplateParamDecl CTree.h Puma/CTree.h
 
2213
 *  Base class for all tree nodesrepresenting a template parameter declaration. */
1159
2214
class CT_TemplateParamDecl : public CT_Decl, public CSemObject {
1160
2215
protected:
 
2216
  /** Constructor. */
1161
2217
  CT_TemplateParamDecl () {}
1162
2218
  
1163
2219
public:
 
2220
  /** Get the template default argument. */
1164
2221
  virtual CT_ExprList *DefaultArgument () const = 0;
 
2222
  /** Get the semantic information object. */
1165
2223
  CSemObject *SemObject () const { return (CSemObject*)this; }
1166
2224
};
1167
2225
 
1170
2228
 
1171
2229
public:
1172
2230
  CT_NonTypeParamDecl (CTree *dsl, CTree *d, CTree *i = (CTree*)0) {
1173
 
    sons[0] = dsl; sons[1] = d; sons[2] = i;
 
2231
    AddSon (sons[0], dsl); AddSon (sons[1], d); AddSon (sons[2], i);
1174
2232
  }
 
2233
  /** Get the identifier for this node type. Can be compared with NodeName(). */
1175
2234
  static const char *NodeId ();
 
2235
  /** Get the name of the node. Can be compared with NodeId(). */
1176
2236
  const char *NodeName () const { return NodeId (); }
 
2237
  /** Get the number of sons. */
1177
2238
  int Sons () const { return CTree::Sons (sons, 3); }
 
2239
  /** Get the n-th son.
 
2240
   *  \param n The index of the son.
 
2241
   *  \return The n-th son or NULL. */
1178
2242
  CTree *Son (int n) const { return CTree::Son (sons, 3, n); }
1179
2243
  CT_DeclSpecSeq *DeclSpecs () const { return (CT_DeclSpecSeq*)sons[0]; }
1180
2244
  CTree *Declarator () const { return sons[1]; }
1181
2245
  CT_ExprList *DefaultArgument () const { return (CT_ExprList*)sons[2]; }
1182
2246
  CSemObject *SemObject () const { return (CSemObject*)this; }
1183
 
  void Initializer (CTree *i) { sons[2] = i; }
 
2247
  void Initializer (CTree *i) { AddSon (sons[2], i); }
 
2248
  /** Replace a son.
 
2249
   *  \param old_son The son to replace.
 
2250
   *  \param new_son The new son. */
1184
2251
  void ReplaceSon (CTree *old_son, CTree *new_son) { 
1185
2252
    CTree::ReplaceSon (sons, 3, old_son, new_son);
1186
2253
  }
1191
2258
 
1192
2259
public:
1193
2260
  CT_TypeParamDecl (CTree *t, CTree *k, CTree *id, CTree *i = (CTree*)0) { 
1194
 
    sons[0] = t; sons[1] = k; sons[2] = id; sons[3] = i;
 
2261
    AddSon (sons[0], t); AddSon (sons[1], k); 
 
2262
    AddSon (sons[2], id); AddSon (sons[3], i);
1195
2263
  }
 
2264
  /** Get the identifier for this node type. Can be compared with NodeName(). */
1196
2265
  static const char *NodeId ();
 
2266
  /** Get the name of the node. Can be compared with NodeId(). */
1197
2267
  const char *NodeName () const { return NodeId (); }
 
2268
  /** Get the number of sons. */
1198
2269
  int Sons () const { return CTree::Sons (sons, 4); }
 
2270
  /** Get the n-th son.
 
2271
   *  \param n The index of the son.
 
2272
   *  \return The n-th son or NULL. */
1199
2273
  CTree *Son (int n) const { return CTree::Son (sons, 4, n); }
1200
2274
  CT_TemplateParamList *Parameters () const { 
1201
2275
    return (CT_TemplateParamList*)sons[0]; 
1202
2276
  }
1203
2277
  CT_SimpleName *Name () const { return (CT_SimpleName*)sons[2]; }
1204
2278
  CT_ExprList *DefaultArgument () const { return (CT_ExprList*)sons[3]; }
1205
 
  void Initializer (CTree *i) { sons[3] = i; }
 
2279
  void Initializer (CTree *i) { AddSon (sons[3], i); }
 
2280
  /** Replace a son.
 
2281
   *  \param old_son The son to replace.
 
2282
   *  \param new_son The new son. */
1206
2283
  void ReplaceSon (CTree *old_son, CTree *new_son) { 
1207
2284
    CTree::ReplaceSon (sons, 4, old_son, new_son);
1208
2285
  }
1213
2290
 
1214
2291
public:
1215
2292
  CT_EnumDef (CTree *k, CTree *n) {
1216
 
    sons[0] = k; sons[1] = n; sons[2] = 0; 
 
2293
    AddSon (sons[0], k); AddSon (sons[1], n); AddSon (sons[2], 0); 
1217
2294
  }
 
2295
  /** Get the identifier for this node type. Can be compared with NodeName(). */
1218
2296
  static const char *NodeId ();
 
2297
  /** Get the name of the node. Can be compared with NodeId(). */
1219
2298
  const char *NodeName () const { return NodeId (); }
 
2299
  /** Get the number of sons. */
1220
2300
  int Sons () const { return CTree::Sons (sons, 3); }
 
2301
  /** Get the n-th son.
 
2302
   *  \param n The index of the son.
 
2303
   *  \return The n-th son or NULL. */
1221
2304
  CTree *Son (int n) const { return CTree::Son (sons, 3, n); }
1222
2305
  CT_SimpleName *Name () const { return (CT_SimpleName*)sons[1]; }
1223
 
  void Enumerators (CTree *el) { sons[2] = el; }
 
2306
  void Enumerators (CTree *el) { AddSon (sons[2], el); }
1224
2307
  CT_EnumeratorList *Enumerators () const { return (CT_EnumeratorList*)sons[2]; }
 
2308
  /** Replace a son.
 
2309
   *  \param old_son The son to replace.
 
2310
   *  \param new_son The new son. */
1225
2311
  void ReplaceSon (CTree *old_son, CTree *new_son) { 
1226
2312
    CTree::ReplaceSon (sons, 3, old_son, new_son);
1227
2313
  }
1232
2318
  CTree *sons[2]; // name, init
1233
2319
 
1234
2320
public:
1235
 
  CT_Enumerator (CTree *n) { sons[0] = n; sons[1] = 0; }
 
2321
  CT_Enumerator (CTree *n) { AddSon (sons[0], n); AddSon (sons[1], 0); }
 
2322
  /** Get the identifier for this node type. Can be compared with NodeName(). */
1236
2323
  static const char *NodeId ();
 
2324
  /** Get the name of the node. Can be compared with NodeId(). */
1237
2325
  const char *NodeName () const { return NodeId (); }
 
2326
  /** Get the number of sons. */
1238
2327
  int Sons () const { return CTree::Sons (sons, 2); }
 
2328
  /** Get the n-th son.
 
2329
   *  \param n The index of the son.
 
2330
   *  \return The n-th son or NULL. */
1239
2331
  CTree *Son (int n) const { return CTree::Son (sons, 2, n); }
1240
2332
  CT_SimpleName *Name () const { return (CT_SimpleName*)sons[0]; }
1241
 
  void Initializer (CTree *i) { sons[1] = i; }
 
2333
  void Initializer (CTree *i) { AddSon (sons[1], i); }
1242
2334
  CT_ExprList *Initializer () const { return (CT_ExprList*)sons[1]; }
 
2335
  /** Replace a son.
 
2336
   *  \param old_son The son to replace.
 
2337
   *  \param new_son The new son. */
1243
2338
  void ReplaceSon (CTree *old_son, CTree *new_son) { 
1244
2339
    CTree::ReplaceSon (sons, 2, old_son, new_son); 
1245
2340
  }
1252
2347
public:
1253
2348
  CT_FctDef (CTree *dss, CTree *d, CTree *t, CTree *ci, CTree *as, 
1254
2349
             CTree *b, CTree *hs) {
1255
 
    sons[0] = dss; sons[1] = d; sons[2] = t; sons[3] = ci; sons[4] = as; 
1256
 
    sons[5] = b; sons[6] = hs; 
 
2350
    AddSon (sons[0], dss); AddSon (sons[1], d); AddSon (sons[2], t); 
 
2351
    AddSon (sons[3], ci); AddSon (sons[4], as); AddSon (sons[5], b); 
 
2352
    AddSon (sons[6], hs); 
1257
2353
  }
 
2354
  /** Get the identifier for this node type. Can be compared with NodeName(). */
1258
2355
  static const char *NodeId ();
 
2356
  /** Get the name of the node. Can be compared with NodeId(). */
1259
2357
  const char *NodeName () const { return NodeId (); }
 
2358
  /** Get the number of sons. */
1260
2359
  int Sons () const { return CTree::Sons (sons, 7); }
 
2360
  /** Get the n-th son.
 
2361
   *  \param n The index of the son.
 
2362
   *  \return The n-th son or NULL. */
1261
2363
  CTree *Son (int n) const { return CTree::Son (sons, 7, n); }
1262
2364
  CT_DeclSpecSeq *DeclSpecs () const { return (CT_DeclSpecSeq*)sons[0]; }
1263
2365
  CTree *Declarator () const { return sons[1]; }
1267
2369
  CT_CmpdStmt *Body () const { return (CT_CmpdStmt*)sons[5]; }
1268
2370
  CT_HandlerSeq *Handlers () const { return (CT_HandlerSeq*)sons[6]; }
1269
2371
  CSemObject *SemObject () const { return (CSemObject*)this; }
1270
 
  void CtorInit (CTree *i) { sons[3] = i; }
1271
 
  void Body (CTree *b) { sons[5] = b; }
 
2372
  void CtorInit (CTree *i) { AddSon (sons[3], i); }
 
2373
  void Body (CTree *b) { AddSon (sons[5], b); }
1272
2374
  void FctTryBlock (CTree *t, CTree *c, CTree *b, CTree *h) { 
1273
 
    sons[2] = t; sons[3] = c; sons[5] = b; sons[6] = h;
 
2375
    AddSon (sons[2], t); AddSon (sons[3], c); 
 
2376
    AddSon (sons[5], b); AddSon (sons[6], h);
1274
2377
  }
 
2378
  /** Replace a son.
 
2379
   *  \param old_son The son to replace.
 
2380
   *  \param new_son The new son. */
1275
2381
  void ReplaceSon (CTree *old_son, CTree *new_son) { 
1276
2382
    CTree::ReplaceSon (sons, 7, old_son, new_son);
1277
2383
  }
1282
2388
 
1283
2389
public:
1284
2390
  CT_AsmDef (CTree *a, CTree *o, CTree *s, CTree *c, CTree *sc) {
1285
 
    sons[0] = a; sons[1] = o; sons[2] = s; sons[3] = c; sons[4] = sc; 
 
2391
    AddSon (sons[0], a); AddSon (sons[1], o); AddSon (sons[2], s); 
 
2392
    AddSon (sons[3], c); AddSon (sons[4], sc); 
1286
2393
  }
 
2394
  /** Get the identifier for this node type. Can be compared with NodeName(). */
1287
2395
  static const char *NodeId ();
 
2396
  /** Get the name of the node. Can be compared with NodeId(). */
1288
2397
  const char *NodeName () const { return NodeId (); }
 
2398
  /** Get the number of sons. */
1289
2399
  int Sons () const { return 5; }
 
2400
  /** Get the n-th son.
 
2401
   *  \param n The index of the son.
 
2402
   *  \return The n-th son or NULL. */
1290
2403
  CTree *Son (int n) const { return CTree::Son (sons, 5, n); }
1291
2404
  CT_String *Instructions () const { return (CT_String*)sons[2]; }
 
2405
  /** Replace a son.
 
2406
   *  \param old_son The son to replace.
 
2407
   *  \param new_son The new son. */
1292
2408
  void ReplaceSon (CTree *old_son, CTree *new_son) { 
1293
2409
    CTree::ReplaceSon (sons, 5, old_son, new_son);
1294
2410
  }
1299
2415
 
1300
2416
public:
1301
2417
  CT_Handler (CTree *c, CTree *e, CTree *s) {
1302
 
    sons[0] = c; sons[1] = e; sons[2] = s;
 
2418
    AddSon (sons[0], c); AddSon (sons[1], e); AddSon (sons[2], s);
1303
2419
  }
 
2420
  /** Get the identifier for this node type. Can be compared with NodeName(). */
1304
2421
  static const char *NodeId ();
 
2422
  /** Get the name of the node. Can be compared with NodeId(). */
1305
2423
  const char *NodeName () const { return NodeId (); }
 
2424
  /** Get the number of sons. */
1306
2425
  int Sons () const { return 3; }
 
2426
  /** Get the n-th son.
 
2427
   *  \param n The index of the son.
 
2428
   *  \return The n-th son or NULL. */
1307
2429
  CTree *Son (int n) const { return CTree::Son (sons, 3, n); }
1308
2430
  CT_ArgDeclList *Arguments () const { return (CT_ArgDeclList*)sons[1]; }
1309
2431
  CT_Statement *Statement () const { return (CT_Statement*)sons[2]; }
 
2432
  /** Replace a son.
 
2433
   *  \param old_son The son to replace.
 
2434
   *  \param new_son The new son. */
1310
2435
  void ReplaceSon (CTree *old_son, CTree *new_son) { 
1311
2436
    CTree::ReplaceSon (sons, 3, old_son, new_son);
1312
2437
  }
 
2438
  CSemScope *SemScope () const { return (CSemScope*)this; }
1313
2439
};
1314
2440
 
1315
2441
class CT_LinkageSpec : public CT_Decl {
1317
2443
 
1318
2444
public:
1319
2445
  CT_LinkageSpec (CTree *e, CTree *s, CTree *o, CTree *d, CTree *c) {
1320
 
    sons[0] = e; sons[1] = s; sons[2] = o; sons[3] = d; sons[4] = c;
 
2446
    AddSon (sons[0], e); AddSon (sons[1], s); AddSon (sons[2], o); 
 
2447
    AddSon (sons[3], d); AddSon (sons[4], c);
1321
2448
    if (isList ())
1322
2449
      ((CT_DeclList*)Decls ())->Linkage (this);
1323
2450
    else
1324
2451
      ((CT_Decl*)Decls ())->Linkage (this);
1325
2452
  }
 
2453
  /** Get the identifier for this node type. Can be compared with NodeName(). */
1326
2454
  static const char *NodeId ();
 
2455
  /** Get the name of the node. Can be compared with NodeId(). */
1327
2456
  const char *NodeName () const { return NodeId (); }
 
2457
  /** Get the number of sons. */
1328
2458
  int Sons () const { return CTree::Sons (sons, 5); }
 
2459
  /** Get the n-th son.
 
2460
   *  \param n The index of the son.
 
2461
   *  \return The n-th son or NULL. */
1329
2462
  CTree *Son (int n) const { return CTree::Son (sons, 5, n); }
1330
2463
  CT_String *Linkage () const { return (CT_String*)sons[1]; }
1331
2464
  CTree *Decls () const { return sons[3]; }
1332
2465
  bool isList () const {
1333
2466
    return Decls ()->NodeName () == CT_DeclList::NodeId ();
1334
2467
  }
 
2468
  /** Replace a son.
 
2469
   *  \param old_son The son to replace.
 
2470
   *  \param new_son The new son. */
1335
2471
  void ReplaceSon (CTree *old_son, CTree *new_son) { 
1336
2472
    CTree::ReplaceSon (sons, 5, old_son, new_son);
1337
2473
  }
1342
2478
 
1343
2479
public:
1344
2480
  CT_ArgDecl (CTree *dsl, CTree *d) {
1345
 
    sons[0] = dsl; sons[1] = d; sons[2] = 0; sons[3] = 0; 
 
2481
    AddSon (sons[0], dsl); AddSon (sons[1], d); 
 
2482
    AddSon (sons[2], 0); AddSon (sons[3], 0); 
1346
2483
  }
1347
2484
  CT_ArgDecl (CTree *ellipsis) {
1348
 
    sons[0] = 0; sons[1] = 0; sons[2] = 0; sons[3] = ellipsis; 
 
2485
    AddSon (sons[0], 0); AddSon (sons[1], 0); 
 
2486
    AddSon (sons[2], 0); AddSon (sons[3], ellipsis); 
1349
2487
  }
 
2488
  /** Get the identifier for this node type. Can be compared with NodeName(). */
1350
2489
  static const char *NodeId ();
 
2490
  /** Get the name of the node. Can be compared with NodeId(). */
1351
2491
  const char *NodeName () const { return NodeId (); }
 
2492
  /** Get the number of sons. */
1352
2493
  int Sons () const { return CTree::Sons (sons, 4); }
 
2494
  /** Get the n-th son.
 
2495
   *  \param n The index of the son.
 
2496
   *  \return The n-th son or NULL. */
1353
2497
  CTree *Son (int n) const { return CTree::Son (sons, 4, n); }
1354
2498
  CT_DeclSpecSeq *DeclSpecs () const { return (CT_DeclSpecSeq*)sons[0]; }
1355
2499
  CTree *Declarator () const { return sons[1]; }
1356
2500
  CT_ExprList *Initializer () const { return (CT_ExprList*)sons[2]; }
1357
2501
  CT_Token *Ellipsis () const { return (CT_Token*)sons[3]; }
1358
2502
  CSemObject *SemObject () const { return (CSemObject*)this; }
1359
 
  void Initializer (CTree *i) { sons[2] = i; }
 
2503
  void Initializer (CTree *i) { AddSon (sons[2], i); }
 
2504
  /** Replace a son.
 
2505
   *  \param old_son The son to replace.
 
2506
   *  \param new_son The new son. */
1360
2507
  void ReplaceSon (CTree *old_son, CTree *new_son) { 
1361
2508
    CTree::ReplaceSon (sons, 4, old_son, new_son);
1362
2509
  }
1366
2513
public:
1367
2514
  CT_ArgDeclList (int size = 2, int props = SEPARATORS | OPEN_CLOSE) : 
1368
2515
   CT_DeclList (size, 2) { AddProperties (props); }
 
2516
  /** Get the identifier for this node type. Can be compared with NodeName(). */
1369
2517
  static const char *NodeId ();
 
2518
  /** Get the name of the node. Can be compared with NodeId(). */
1370
2519
  const char *NodeName () const { return NodeId (); }
 
2520
  CSemScope *SemScope () const { return (CSemScope*)this; }
1371
2521
};
1372
2522
 
1373
2523
class CT_ArgDeclSeq : public CT_DeclList, public CSemScope {
1374
2524
public:
1375
2525
  CT_ArgDeclSeq (int size = 2) : CT_DeclList (size, 2) {}
 
2526
  /** Get the identifier for this node type. Can be compared with NodeName(). */
1376
2527
  static const char *NodeId ();
 
2528
  /** Get the name of the node. Can be compared with NodeId(). */
1377
2529
  const char *NodeName () const { return NodeId (); }
 
2530
  CSemScope *SemScope () const { return (CSemScope*)this; }
1378
2531
};
1379
2532
 
1380
2533
class CT_ArgNameList : public CT_ArgDeclList {
1381
2534
public:
1382
2535
  CT_ArgNameList () : CT_ArgDeclList () {}
 
2536
  /** Get the identifier for this node type. Can be compared with NodeName(). */
1383
2537
  static const char *NodeId ();
 
2538
  /** Get the name of the node. Can be compared with NodeId(). */
1384
2539
  const char *NodeName () const { return NodeId (); }
1385
2540
};
1386
2541
 
1389
2544
 
1390
2545
public:
1391
2546
  CT_NamespaceDef (CTree *n, CTree *nm) {
1392
 
    sons[0] = n; sons[1] = nm; sons[2] = 0; 
 
2547
    AddSon (sons[0], n); AddSon (sons[1], nm); AddSon (sons[2], 0); 
1393
2548
  }
1394
2549
  CT_NamespaceDef (CTree *n, CTree *nm, CTree *m) {
1395
 
    sons[0] = n; sons[1] = nm; sons[2] = m; 
 
2550
    AddSon (sons[0], n); AddSon (sons[1], nm); AddSon (sons[2], m); 
1396
2551
  }
 
2552
  /** Get the identifier for this node type. Can be compared with NodeName(). */
1397
2553
  static const char *NodeId ();
 
2554
  /** Get the name of the node. Can be compared with NodeId(). */
1398
2555
  const char *NodeName () const { return NodeId (); }
 
2556
  /** Get the number of sons. */
1399
2557
  int Sons () const { return CTree::Sons (sons, 3); }
 
2558
  /** Get the n-th son.
 
2559
   *  \param n The index of the son.
 
2560
   *  \return The n-th son or NULL. */
1400
2561
  CTree *Son (int n) const { return CTree::Son (sons, 3, n); }
1401
 
  void Members (CTree *m) { sons[2] = m; }
 
2562
  void Members (CTree *m) { AddSon (sons[2], m); }
1402
2563
  CT_MembList *Members () const { return (CT_MembList*)sons[2]; }
1403
2564
  CT_SimpleName *Name () const { return (CT_SimpleName*)sons[1]; }
1404
2565
  CSemObject *SemObject () const { return (CSemObject*)this; }
 
2566
  /** Replace a son.
 
2567
   *  \param old_son The son to replace.
 
2568
   *  \param new_son The new son. */
1405
2569
  void ReplaceSon (CTree *old_son, CTree *new_son) { 
1406
2570
    CTree::ReplaceSon (sons, 3, old_son, new_son);
1407
2571
  }
1412
2576
 
1413
2577
public:
1414
2578
  CT_NamespaceAliasDef (CTree *n, CTree *a, CTree *as, CTree *nm, CTree *s) {
1415
 
    sons[0] = n; sons[1] = a; sons[2] = as; sons[3] = nm; sons[4] = s; 
 
2579
    AddSon (sons[0], n); AddSon (sons[1], a); AddSon (sons[2], as); 
 
2580
    AddSon (sons[3], nm); AddSon (sons[4], s); 
1416
2581
  }
 
2582
  /** Get the identifier for this node type. Can be compared with NodeName(). */
1417
2583
  static const char *NodeId ();
 
2584
  /** Get the name of the node. Can be compared with NodeId(). */
1418
2585
  const char *NodeName () const { return NodeId (); }
 
2586
  /** Get the number of sons. */
1419
2587
  int Sons () const { return 5; }
 
2588
  /** Get the n-th son.
 
2589
   *  \param n The index of the son.
 
2590
   *  \return The n-th son or NULL. */
1420
2591
  CTree *Son (int n) const { return CTree::Son (sons, 5, n); }
1421
2592
  CT_SimpleName *Name () const { return (CT_SimpleName*)sons[3]; }
1422
2593
  CT_SimpleName *Alias () const { return (CT_SimpleName*)sons[1]; }
1423
2594
  CSemObject *SemObject () const { return (CSemObject*)this; }
 
2595
  /** Replace a son.
 
2596
   *  \param old_son The son to replace.
 
2597
   *  \param new_son The new son. */
1424
2598
  void ReplaceSon (CTree *old_son, CTree *new_son) { 
1425
2599
    CTree::ReplaceSon (sons, 5, old_son, new_son);
1426
2600
  }
1431
2605
 
1432
2606
public:
1433
2607
  CT_UsingDirective (CTree *u, CTree *ns, CTree *n, CTree *s) {
1434
 
    sons[0] = u; sons[1] = ns; sons[2] = n; sons[3] = s; 
 
2608
    AddSon (sons[0], u); AddSon (sons[1], ns); AddSon (sons[2], n); 
 
2609
    AddSon (sons[3], s); 
1435
2610
  }
 
2611
  /** Get the identifier for this node type. Can be compared with NodeName(). */
1436
2612
  static const char *NodeId ();
 
2613
  /** Get the name of the node. Can be compared with NodeId(). */
1437
2614
  const char *NodeName () const { return NodeId (); }
 
2615
  /** Get the number of sons. */
1438
2616
  int Sons () const { return 4; }
 
2617
  /** Get the n-th son.
 
2618
   *  \param n The index of the son.
 
2619
   *  \return The n-th son or NULL. */
1439
2620
  CTree *Son (int n) const { return CTree::Son (sons, 4, n); }
1440
2621
  CT_SimpleName *Name () const { return (CT_SimpleName*)sons[2]; }
 
2622
  /** Replace a son.
 
2623
   *  \param old_son The son to replace.
 
2624
   *  \param new_son The new son. */
1441
2625
  void ReplaceSon (CTree *old_son, CTree *new_son) { 
1442
2626
    CTree::ReplaceSon (sons, 4, old_son, new_son);
1443
2627
  }
1463
2647
};
1464
2648
 
1465
2649
class CT_InitDeclarator : public CT_Declarator, public CSemObject {
1466
 
  CTree *sons[2]; // declarator, init
 
2650
  CTree *sons[3]; // declarator, ext, init
1467
2651
  CTree *obj_decl;
1468
2652
 
1469
2653
public:
1470
 
  CT_InitDeclarator (CTree *d, CTree *i = (CTree*)0) {
1471
 
    sons[0] = d; sons[1] = i; obj_decl = 0; 
 
2654
  CT_InitDeclarator (CTree *d, CTree *e = 0, CTree *i = 0) {
 
2655
    AddSon (sons[0], d); AddSon (sons[1], e); AddSon (sons[2], i);
 
2656
    AddSon (obj_decl, 0); 
1472
2657
  }
 
2658
  /** Get the identifier for this node type. Can be compared with NodeName(). */
1473
2659
  static const char *NodeId ();
 
2660
  /** Get the name of the node. Can be compared with NodeId(). */
1474
2661
  const char *NodeName () const { return NodeId (); }
1475
 
  int Sons () const { return CTree::Sons (sons, 2); }
1476
 
  CTree *Son (int n) const { return CTree::Son (sons, 2, n); }
 
2662
  /** Get the number of sons. */
 
2663
  int Sons () const { return CTree::Sons (sons, 3); }
 
2664
  /** Get the n-th son.
 
2665
   *  \param n The index of the son.
 
2666
   *  \return The n-th son or NULL. */
 
2667
  CTree *Son (int n) const { return CTree::Son (sons, 3, n); }
1477
2668
  CTree *Declarator () const { return sons[0]; }
1478
 
  CT_ExprList *Initializer () const { return (CT_ExprList*)sons[1]; }
 
2669
  CTree *Extension () const { return sons[1]; }
 
2670
  CT_ExprList *Initializer () const { return (CT_ExprList*)sons[2]; }
1479
2671
  CSemObject *SemObject () const { return (CSemObject*)this; }
1480
2672
  CT_ObjDecl *ObjDecl () const { return (CT_ObjDecl*)obj_decl; }
1481
 
  void Initializer (CTree* i) { sons[1] = i; }
1482
 
  void ObjDecl (CTree *od) { obj_decl = od; }
 
2673
  void Initializer (CTree* i) { AddSon (sons[2], i); }
 
2674
  void Extension (CTree* i) { AddSon (sons[1], i); }
 
2675
  void ObjDecl (CTree *od) { AddSon (obj_decl, od); }
 
2676
  /** Replace a son.
 
2677
   *  \param old_son The son to replace.
 
2678
   *  \param new_son The new son. */
1483
2679
  void ReplaceSon (CTree *old_son, CTree *new_son) { 
1484
 
    CTree::ReplaceSon (sons, 2, old_son, new_son);
 
2680
    CTree::ReplaceSon (sons, 3, old_son, new_son);
1485
2681
  }
1486
2682
};
1487
2683
 
1490
2686
 
1491
2687
public:
1492
2688
  CT_BracedDeclarator (CTree *o, CTree *d, CTree *c) {
1493
 
    sons[0] = o; sons[1] = 0; sons[2] = d; sons[3] = c; 
 
2689
    AddSon (sons[0], o); AddSon (sons[1], 0); 
 
2690
    AddSon (sons[2], d); AddSon (sons[3], c); 
1494
2691
  }
1495
2692
  CT_BracedDeclarator (CTree *o, CTree *ws, CTree *d, CTree *c) {
1496
 
    sons[0] = o; sons[1] = ws; sons[2] = d; sons[3] = c; 
 
2693
    AddSon (sons[0], o); AddSon (sons[1], ws); 
 
2694
    AddSon (sons[2], d); AddSon (sons[3], c); 
1497
2695
  }
 
2696
  /** Get the identifier for this node type. Can be compared with NodeName(). */
1498
2697
  static const char *NodeId ();
 
2698
  /** Get the name of the node. Can be compared with NodeId(). */
1499
2699
  const char *NodeName () const { return NodeId (); }
 
2700
  /** Get the number of sons. */
1500
2701
  int Sons () const { return CTree::Sons (sons, 4); }
 
2702
  /** Get the n-th son.
 
2703
   *  \param n The index of the son.
 
2704
   *  \return The n-th son or NULL. */
1501
2705
  CTree *Son (int n) const { return CTree::Son (sons, 4, n); }
1502
2706
  CTree *Declarator () const { return sons[2]; }
 
2707
  /** Replace a son.
 
2708
   *  \param old_son The son to replace.
 
2709
   *  \param new_son The new son. */
1503
2710
  void ReplaceSon (CTree *old_son, CTree *new_son) { 
1504
2711
    CTree::ReplaceSon (sons, 4, old_son, new_son);
1505
2712
  }
1511
2718
 
1512
2719
public:
1513
2720
  CT_ArrayDelimiter (CTree *m, CTree *s, CTree *q, CTree *e, bool p = false) {
1514
 
    sons[0] = m; sons[1] = s; sons[2] = q; sons[3] = e; pos0 = p;
 
2721
    AddSon (sons[0], m); AddSon (sons[1], s); 
 
2722
    AddSon (sons[2], q); AddSon (sons[3], e); pos0 = p;
1515
2723
  }
 
2724
  /** Get the identifier for this node type. Can be compared with NodeName(). */
1516
2725
  static const char *NodeId ();
 
2726
  /** Get the name of the node. Can be compared with NodeId(). */
1517
2727
  const char *NodeName () const { return NodeId (); }
 
2728
  /** Get the number of sons. */
1518
2729
  int Sons () const { return CTree::Sons (sons, 4); }
 
2730
  /** Get the n-th son.
 
2731
   *  \param n The index of the son.
 
2732
   *  \return The n-th son or NULL. */
1519
2733
  CTree *Son (int n) const { return CTree::Son (sons, 4, n); }
1520
2734
  CT_Token *Star () const { return (CT_Token*)sons[0]; }
1521
2735
  CT_Token *Static () const { return (CT_Token*)sons[pos0?2:1]; }
1522
2736
  CT_DeclSpecSeq *Qualifier () const { return (CT_DeclSpecSeq*)sons[pos0?1:2]; }
1523
2737
  CTree *Expr () const { return sons[3]; }
 
2738
  /** Replace a son.
 
2739
   *  \param old_son The son to replace.
 
2740
   *  \param new_son The new son. */
1524
2741
  void ReplaceSon (CTree *old_son, CTree *new_son) { 
1525
2742
    CTree::ReplaceSon (sons, 4, old_son, new_son);
1526
2743
  }
1531
2748
 
1532
2749
public:
1533
2750
  CT_ArrayDeclarator (CTree *d, CTree *o, CTree *ad, CTree *c) {
1534
 
    sons[0] = d; sons[1] = o; sons[2] = ad; sons[3] = c; 
 
2751
    AddSon (sons[0], d); AddSon (sons[1], o); 
 
2752
    AddSon (sons[2], ad); AddSon (sons[3], c); 
1535
2753
  }
 
2754
  /** Get the identifier for this node type. Can be compared with NodeName(). */
1536
2755
  static const char *NodeId ();
 
2756
  /** Get the name of the node. Can be compared with NodeId(). */
1537
2757
  const char *NodeName () const { return NodeId (); }
 
2758
  /** Get the number of sons. */
1538
2759
  int Sons () const { return 4; }
 
2760
  /** Get the n-th son.
 
2761
   *  \param n The index of the son.
 
2762
   *  \return The n-th son or NULL. */
1539
2763
  CTree *Son (int n) const { return CTree::Son (sons, 4, n); }
1540
2764
  CTree *Declarator () const { return sons[0]; }
1541
2765
  CT_ArrayDelimiter *Delimiter () const 
1542
2766
   { return (CT_ArrayDelimiter*)sons[2]; }
 
2767
  /** Replace a son.
 
2768
   *  \param old_son The son to replace.
 
2769
   *  \param new_son The new son. */
1543
2770
  void ReplaceSon (CTree *old_son, CTree *new_son) { 
1544
2771
    CTree::ReplaceSon (sons, 4, old_son, new_son);
1545
2772
  }
1553
2780
 
1554
2781
public:
1555
2782
  CT_FctDeclarator (CTree *d, CTree *args, CTree *cv, CTree *es) {
1556
 
    sons[0] = d; sons[1] = args; sons[2] = cv; sons[3] = es; 
 
2783
    AddSon (sons[0], d); AddSon (sons[1], args); 
 
2784
    AddSon (sons[2], cv); AddSon (sons[3], es); 
1557
2785
  }
 
2786
  /** Get the identifier for this node type. Can be compared with NodeName(). */
1558
2787
  static const char *NodeId ();
 
2788
  /** Get the name of the node. Can be compared with NodeId(). */
1559
2789
  const char *NodeName () const { return NodeId (); }
 
2790
  /** Get the number of sons. */
1560
2791
  int Sons () const { return CTree::Sons (sons, 4); }
 
2792
  /** Get the n-th son.
 
2793
   *  \param n The index of the son.
 
2794
   *  \return The n-th son or NULL. */
1561
2795
  CTree *Son (int n) const { return CTree::Son (sons, 4, n); }
1562
2796
  CTree *Declarator () const { return sons[0]; }
1563
2797
  CT_ArgDeclList *Arguments () const { return (CT_ArgDeclList*)sons[1]; }
1564
2798
  CT_DeclSpecSeq *Qualifier () const { return (CT_DeclSpecSeq*)sons[2]; }
1565
2799
  CT_ExceptionSpec *ExceptionSpecs () const { return (CT_ExceptionSpec*)sons[3]; }
 
2800
  /** Replace a son.
 
2801
   *  \param old_son The son to replace.
 
2802
   *  \param new_son The new son. */
1566
2803
  void ReplaceSon (CTree *old_son, CTree *new_son) { 
1567
2804
    CTree::ReplaceSon (sons, 4, old_son, new_son);
1568
2805
  }
1572
2809
  CTree *sons[2]; // ref, declarator
1573
2810
 
1574
2811
public:
1575
 
  CT_RefDeclarator (CTree *r, CTree *d) { sons[0] = r; sons[1] = d; }
 
2812
  CT_RefDeclarator (CTree *r, CTree *d) { AddSon (sons[0], r); AddSon (sons[1], d); }
 
2813
  /** Get the identifier for this node type. Can be compared with NodeName(). */
1576
2814
  static const char *NodeId ();
 
2815
  /** Get the name of the node. Can be compared with NodeId(). */
1577
2816
  const char *NodeName () const { return NodeId (); }
 
2817
  /** Get the number of sons. */
1578
2818
  int Sons () const { return 2; }
 
2819
  /** Get the n-th son.
 
2820
   *  \param n The index of the son.
 
2821
   *  \return The n-th son or NULL. */
1579
2822
  CTree *Son (int n) const { return CTree::Son (sons, 2, n); }
1580
2823
  CTree *Declarator () const { return sons[1]; }
 
2824
  /** Replace a son.
 
2825
   *  \param old_son The son to replace.
 
2826
   *  \param new_son The new son. */
1581
2827
  void ReplaceSon (CTree *old_son, CTree *new_son) {
1582
2828
    CTree::ReplaceSon (sons, 2, old_son, new_son);
1583
2829
  }
1588
2834
 
1589
2835
public:
1590
2836
  CT_PtrDeclarator (CTree *p, CTree *c, CTree *d) {
1591
 
    sons[0] = p; sons[1] = c; sons[2] = d; 
 
2837
    AddSon (sons[0], p); AddSon (sons[1], c); AddSon (sons[2], d); 
1592
2838
  }
 
2839
  /** Get the identifier for this node type. Can be compared with NodeName(). */
1593
2840
  static const char *NodeId ();
 
2841
  /** Get the name of the node. Can be compared with NodeId(). */
1594
2842
  const char *NodeName () const { return NodeId (); }
 
2843
  /** Get the number of sons. */
1595
2844
  int Sons () const { return CTree::Sons (sons, 3); }
 
2845
  /** Get the n-th son.
 
2846
   *  \param n The index of the son.
 
2847
   *  \return The n-th son or NULL. */
1596
2848
  CTree *Son (int n) const { return CTree::Son (sons, 3, n); }
1597
2849
  CTree *Declarator () const { return sons[2]; }
1598
2850
  CT_DeclSpecSeq *Qualifier () const { return (CT_DeclSpecSeq*)sons[1]; }
 
2851
  /** Replace a son.
 
2852
   *  \param old_son The son to replace.
 
2853
   *  \param new_son The new son. */
1599
2854
  void ReplaceSon (CTree *old_son, CTree *new_son) { 
1600
2855
    CTree::ReplaceSon (sons, 3, old_son, new_son);
1601
2856
  }
1606
2861
 
1607
2862
public:
1608
2863
  CT_MembPtrDeclarator (CTree *c, CTree *cc, CTree *p, CTree *q, CTree *d) {
1609
 
    sons[0] = c; sons[1] = cc; sons[2] = p; sons[3] = q; sons[4] = d; 
 
2864
    AddSon (sons[0], c); AddSon (sons[1], cc); AddSon (sons[2], p); 
 
2865
    AddSon (sons[3], q); AddSon (sons[4], d); 
1610
2866
  }
 
2867
  /** Get the identifier for this node type. Can be compared with NodeName(). */
1611
2868
  static const char *NodeId ();
 
2869
  /** Get the name of the node. Can be compared with NodeId(). */
1612
2870
  const char *NodeName () const { return NodeId (); }
 
2871
  /** Get the number of sons. */
1613
2872
  int Sons () const { return CTree::Sons (sons, 5); }
 
2873
  /** Get the n-th son.
 
2874
   *  \param n The index of the son.
 
2875
   *  \return The n-th son or NULL. */
1614
2876
  CTree *Son (int n) const { return CTree::Son (sons, 5, n); }
1615
2877
  CT_SimpleName *Name () const { return (CT_SimpleName*)sons[0]; }
1616
2878
  CTree *Declarator () const { return sons[4]; }
1617
2879
  CT_DeclSpecSeq *Qualifier () const { return (CT_DeclSpecSeq*)sons[3]; }
 
2880
  /** Replace a son.
 
2881
   *  \param old_son The son to replace.
 
2882
   *  \param new_son The new son. */
1618
2883
  void ReplaceSon (CTree *old_son, CTree *new_son) { 
1619
2884
    CTree::ReplaceSon (sons, 5, old_son, new_son);
1620
2885
  }
1625
2890
 
1626
2891
public:
1627
2892
  CT_BitFieldDeclarator (CTree *d, CTree *c, CTree *e = 0) {
1628
 
    sons[0] = d; sons[1] = c; sons[2] = e; 
 
2893
    AddSon (sons[0], d); AddSon (sons[1], c); AddSon (sons[2], e); 
1629
2894
  }
 
2895
  /** Get the identifier for this node type. Can be compared with NodeName(). */
1630
2896
  static const char *NodeId ();
 
2897
  /** Get the name of the node. Can be compared with NodeId(). */
1631
2898
  const char *NodeName () const { return NodeId (); }
 
2899
  /** Get the number of sons. */
1632
2900
  int Sons () const { return CTree::Sons (sons, 3); }
 
2901
  /** Get the n-th son.
 
2902
   *  \param n The index of the son.
 
2903
   *  \return The n-th son or NULL. */
1633
2904
  CTree *Son (int n) const { return CTree::Son (sons, 3, n); }
1634
2905
  CTree *Declarator () const { return sons[0]; }
1635
2906
  CTree *Expr () const { return sons[2]; }
1636
 
  void FieldSize (CTree *s) { sons[2] = s; }
 
2907
  void FieldSize (CTree *s) { AddSon (sons[2], s); }
1637
2908
  CSemObject *SemObject () const { return (CSemObject*)this; }
 
2909
  /** Replace a son.
 
2910
   *  \param old_son The son to replace.
 
2911
   *  \param new_son The new son. */
1638
2912
  void ReplaceSon (CTree *old_son, CTree *new_son) { 
1639
2913
    CTree::ReplaceSon (sons, 3, old_son, new_son);
1640
2914
  }
1649
2923
class CT_Statement : public CTree { 
1650
2924
protected:
1651
2925
  CT_Statement () {}
 
2926
  virtual CT_Statement *IsStatement () { return this; }
1652
2927
};
1653
2928
 
1654
2929
class CT_LabelStmt : public CT_Statement {
1656
2931
 
1657
2932
public:
1658
2933
  CT_LabelStmt (CTree *id, CTree *c, CTree *stmt) {
1659
 
    sons[0] = id; sons[1] = c; sons[2] = stmt; 
 
2934
    AddSon (sons[0], id); AddSon (sons[1], c); AddSon (sons[2], stmt); 
1660
2935
  }
 
2936
  /** Get the identifier for this node type. Can be compared with NodeName(). */
1661
2937
  static const char *NodeId ();
 
2938
  /** Get the name of the node. Can be compared with NodeId(). */
1662
2939
  const char *NodeName () const { return NodeId (); }
 
2940
  /** Get the number of sons. */
1663
2941
  int Sons () const { return 3; }
 
2942
  /** Get the n-th son.
 
2943
   *  \param n The index of the son.
 
2944
   *  \return The n-th son or NULL. */
1664
2945
  CTree *Son (int n) const { return CTree::Son (sons, 3, n); }
1665
2946
  CT_Statement *Statement () const { return (CT_Statement*)sons[2]; }
1666
2947
  CT_SimpleName *Label () const { return (CT_SimpleName*)sons[0]; }
 
2948
  /** Replace a son.
 
2949
   *  \param old_son The son to replace.
 
2950
   *  \param new_son The new son. */
1667
2951
  void ReplaceSon (CTree *old_son, CTree *new_son) { 
1668
2952
    CTree::ReplaceSon (sons, 3, old_son, new_son);
1669
2953
  }
1674
2958
 
1675
2959
public:
1676
2960
  CT_DefaultStmt (CTree *kw, CTree *c, CTree *stmt) {
1677
 
    sons[0] = kw; sons[1] = c; sons[2] = stmt; 
 
2961
    AddSon (sons[0], kw); AddSon (sons[1], c); AddSon (sons[2], stmt); 
1678
2962
  }
 
2963
  /** Get the identifier for this node type. Can be compared with NodeName(). */
1679
2964
  static const char *NodeId ();
 
2965
  /** Get the name of the node. Can be compared with NodeId(). */
1680
2966
  const char *NodeName () const { return NodeId (); }
 
2967
  /** Get the number of sons. */
1681
2968
  int Sons () const { return 3; }
 
2969
  /** Get the n-th son.
 
2970
   *  \param n The index of the son.
 
2971
   *  \return The n-th son or NULL. */
1682
2972
  CTree *Son (int n) const { return CTree::Son (sons, 3, n); }
1683
2973
  CT_Statement *Statement () const { return (CT_Statement*)sons[2]; }
 
2974
  /** Replace a son.
 
2975
   *  \param old_son The son to replace.
 
2976
   *  \param new_son The new son. */
1684
2977
  void ReplaceSon (CTree *old_son, CTree *new_son) { 
1685
2978
    CTree::ReplaceSon (sons, 3, old_son, new_son);
1686
2979
  }
1691
2984
 
1692
2985
public:
1693
2986
  CT_TryStmt (CTree *t, CTree *s, CTree *h) {
1694
 
    sons[0] = t; sons[1] = s; sons[2] = h; 
 
2987
    AddSon (sons[0], t); AddSon (sons[1], s); AddSon (sons[2], h); 
1695
2988
  }
 
2989
  /** Get the identifier for this node type. Can be compared with NodeName(). */
1696
2990
  static const char *NodeId ();
 
2991
  /** Get the name of the node. Can be compared with NodeId(). */
1697
2992
  const char *NodeName () const { return NodeId (); }
 
2993
  /** Get the number of sons. */
1698
2994
  int Sons () const { return 3; }
 
2995
  /** Get the n-th son.
 
2996
   *  \param n The index of the son.
 
2997
   *  \return The n-th son or NULL. */
1699
2998
  CTree *Son (int n) const { return CTree::Son (sons, 3, n); }
1700
2999
  CT_Statement *Statement () const { return (CT_Statement*)sons[1]; }
1701
3000
  CT_HandlerSeq *Handlers () const { return (CT_HandlerSeq*)sons[2]; }
 
3001
  /** Replace a son.
 
3002
   *  \param old_son The son to replace.
 
3003
   *  \param new_son The new son. */
1702
3004
  void ReplaceSon (CTree *old_son, CTree *new_son) { 
1703
3005
    CTree::ReplaceSon (sons, 3, old_son, new_son);
1704
3006
  }
1709
3011
 
1710
3012
public:
1711
3013
  CT_CaseStmt (CTree *kw, CTree *expr, CTree *c, CTree *stmt) {
1712
 
    sons[0] = kw; sons[1] = expr; sons[2] = c; sons[3] = stmt; 
 
3014
    AddSon (sons[0], kw); AddSon (sons[1], expr); 
 
3015
    AddSon (sons[2], c); AddSon (sons[3], stmt); 
1713
3016
  }
 
3017
  /** Get the identifier for this node type. Can be compared with NodeName(). */
1714
3018
  static const char *NodeId ();
 
3019
  /** Get the name of the node. Can be compared with NodeId(). */
1715
3020
  const char *NodeName () const { return NodeId (); }
 
3021
  /** Get the number of sons. */
1716
3022
  int Sons () const { return 4; }
 
3023
  /** Get the n-th son.
 
3024
   *  \param n The index of the son.
 
3025
   *  \return The n-th son or NULL. */
1717
3026
  CTree *Son (int n) const { return CTree::Son (sons, 4, n); }
1718
3027
  CT_Statement *Statement () const { return (CT_Statement*)sons[3]; }
1719
3028
  CTree *Expr () const { return sons[1]; }
 
3029
  /** Replace a son.
 
3030
   *  \param old_son The son to replace.
 
3031
   *  \param new_son The new son. */
1720
3032
  void ReplaceSon (CTree *old_son, CTree *new_son) { 
1721
3033
    CTree::ReplaceSon (sons, 4, old_son, new_son);
1722
3034
  }
1726
3038
  CTree *sons[2]; // expr, semi_colon
1727
3039
 
1728
3040
public:
1729
 
  CT_ExprStmt (CTree *expr, CTree *sc) { sons[0] = expr; sons[1] = sc; }
 
3041
  CT_ExprStmt (CTree *expr, CTree *sc) { AddSon (sons[0], expr); AddSon (sons[1], sc); }
 
3042
  /** Get the identifier for this node type. Can be compared with NodeName(). */
1730
3043
  static const char *NodeId ();
 
3044
  /** Get the name of the node. Can be compared with NodeId(). */
1731
3045
  const char *NodeName () const { return NodeId (); }
 
3046
  /** Get the number of sons. */
1732
3047
  int Sons () const { return CTree::Sons (sons, 2); }
 
3048
  /** Get the n-th son.
 
3049
   *  \param n The index of the son.
 
3050
   *  \return The n-th son or NULL. */
1733
3051
  CTree *Son (int n) const { return CTree::Son (sons, 2, n); }
1734
3052
  CTree *Expr () const { return sons[0]; }
 
3053
  /** Replace a son.
 
3054
   *  \param old_son The son to replace.
 
3055
   *  \param new_son The new son. */
1735
3056
  void ReplaceSon (CTree *old_son, CTree *new_son) { 
1736
3057
    CTree::ReplaceSon (sons, 2, old_son, new_son);
1737
3058
  }
1741
3062
  CTree *_decl;
1742
3063
 
1743
3064
public:
1744
 
  CT_DeclStmt (CTree *decl) : _decl (decl) {}
 
3065
  CT_DeclStmt (CTree *decl) { AddSon (_decl, decl); }
 
3066
  /** Get the identifier for this node type. Can be compared with NodeName(). */
1745
3067
  static const char *NodeId ();
 
3068
  /** Get the name of the node. Can be compared with NodeId(). */
1746
3069
  const char *NodeName () const { return NodeId (); }
 
3070
  /** Get the number of sons. */
1747
3071
  int Sons () const { return 1; }
 
3072
  /** Get the n-th son.
 
3073
   *  \param n The index of the son.
 
3074
   *  \return The n-th son or NULL. */
1748
3075
  CTree *Son (int n) const { return n == 0 ? _decl : (CTree*)0; }
 
3076
  /** Replace a son.
 
3077
   *  \param old_son The son to replace.
 
3078
   *  \param new_son The new son. */
1749
3079
  void ReplaceSon (CTree *old_son, CTree *new_son) 
1750
 
   { if (old_son == _decl) _decl = new_son; }
 
3080
   { CTree::ReplaceSon (_decl, old_son, new_son); }
1751
3081
};
1752
3082
 
1753
3083
class CT_SwitchStmt : public CT_Statement, public CSemScope {
1755
3085
 
1756
3086
public:
1757
3087
  CT_SwitchStmt (CTree *kw, CTree *o, CTree *cond, CTree *c, CTree *stmt) {
1758
 
    sons[0] = kw; sons[1] = o; sons[2] = cond; sons[3] = c; sons[4] = stmt; 
 
3088
    AddSon (sons[0], kw); AddSon (sons[1], o); AddSon (sons[2], cond); 
 
3089
    AddSon (sons[3], c); AddSon (sons[4], stmt); 
1759
3090
  }
 
3091
  /** Get the identifier for this node type. Can be compared with NodeName(). */
1760
3092
  static const char *NodeId ();
 
3093
  /** Get the name of the node. Can be compared with NodeId(). */
1761
3094
  const char *NodeName () const { return NodeId (); }
 
3095
  /** Get the number of sons. */
1762
3096
  int Sons () const { return 5; }
 
3097
  /** Get the n-th son.
 
3098
   *  \param n The index of the son.
 
3099
   *  \return The n-th son or NULL. */
1763
3100
  CTree *Son (int n) const { return CTree::Son (sons, 5, n); }
1764
3101
  CT_Statement *Statement () const { return (CT_Statement*)sons[4]; }
1765
3102
  CTree *Condition () const { return sons[2]; }
 
3103
  /** Replace a son.
 
3104
   *  \param old_son The son to replace.
 
3105
   *  \param new_son The new son. */
1766
3106
  void ReplaceSon (CTree *old_son, CTree *new_son) { 
1767
3107
    CTree::ReplaceSon (sons, 5, old_son, new_son);
1768
3108
  }
 
3109
  CSemScope *SemScope () const { return (CSemScope*)this; }
1769
3110
};
1770
3111
 
1771
3112
class CT_IfStmt : public CT_Statement, public CSemScope {
1773
3114
 
1774
3115
public:
1775
3116
  CT_IfStmt (CTree *kw, CTree *o, CTree *cond, CTree *c, CTree *stmt) {
1776
 
    sons[0] = kw; sons[1] = o; sons[2] = cond; sons[3] = c; sons[4] = stmt; 
 
3117
    AddSon (sons[0], kw); AddSon (sons[1], o); AddSon (sons[2], cond); 
 
3118
    AddSon (sons[3], c); AddSon (sons[4], stmt); 
1777
3119
  }
 
3120
  /** Get the identifier for this node type. Can be compared with NodeName(). */
1778
3121
  static const char *NodeId ();
 
3122
  /** Get the name of the node. Can be compared with NodeId(). */
1779
3123
  const char *NodeName () const { return NodeId (); }
 
3124
  /** Get the number of sons. */
1780
3125
  int Sons () const { return 5; }
 
3126
  /** Get the n-th son.
 
3127
   *  \param n The index of the son.
 
3128
   *  \return The n-th son or NULL. */
1781
3129
  CTree *Son (int n) const { return CTree::Son (sons, 5, n); }
1782
3130
  CT_Statement *Statement () const { return (CT_Statement*)sons[4]; }
1783
3131
  CTree *Condition () const { return sons[2]; }
 
3132
  /** Replace a son.
 
3133
   *  \param old_son The son to replace.
 
3134
   *  \param new_son The new son. */
1784
3135
  void ReplaceSon (CTree *old_son, CTree *new_son) { 
1785
3136
    CTree::ReplaceSon (sons, 5, old_son, new_son);
1786
3137
  }
 
3138
  CSemScope *SemScope () const { return (CSemScope*)this; }
1787
3139
};
1788
3140
 
1789
3141
class CT_IfElseStmt : public CT_Statement, public CSemScope {
1792
3144
public:
1793
3145
  CT_IfElseStmt (CTree *i, CTree *o, CTree *cond, CTree *c, 
1794
3146
                 CTree *is, CTree *e, CTree *es) {
1795
 
    sons[0] = i; sons[1] = o; sons[2] = cond; sons[3] = c; sons[4] = is; 
1796
 
    sons[5] = e; sons[6] = es; 
 
3147
    AddSon (sons[0], i); AddSon (sons[1], o); AddSon (sons[2], cond); 
 
3148
    AddSon (sons[3], c); AddSon (sons[4], is); AddSon (sons[5], e); 
 
3149
    AddSon (sons[6], es); 
1797
3150
  }
 
3151
  /** Get the identifier for this node type. Can be compared with NodeName(). */
1798
3152
  static const char *NodeId ();
 
3153
  /** Get the name of the node. Can be compared with NodeId(). */
1799
3154
  const char *NodeName () const { return NodeId (); }
 
3155
  /** Get the number of sons. */
1800
3156
  int Sons () const { return 7; }
 
3157
  /** Get the n-th son.
 
3158
   *  \param n The index of the son.
 
3159
   *  \return The n-th son or NULL. */
1801
3160
  CTree *Son (int n) const { return CTree::Son (sons, 7, n); }
1802
3161
  CTree *Condition () const { return sons[2]; }
1803
3162
  CT_Statement *IfPart () const { return (CT_Statement*)sons[4]; }
1804
3163
  CT_Statement *ElsePart () const { return (CT_Statement*)sons[6]; }
 
3164
  /** Replace a son.
 
3165
   *  \param old_son The son to replace.
 
3166
   *  \param new_son The new son. */
1805
3167
  void ReplaceSon (CTree *old_son, CTree *new_son) { 
1806
3168
    CTree::ReplaceSon (sons, 7, old_son, new_son);
1807
3169
  }
 
3170
  CSemScope *SemScope () const { return (CSemScope*)this; }
1808
3171
};
1809
3172
 
1810
3173
class CT_BreakStmt : public CT_Statement {
1811
3174
  CTree *sons[2]; // key, semi_colon
1812
3175
 
1813
3176
public:
1814
 
  CT_BreakStmt (CTree *key, CTree *sc) { sons[0] = key; sons[1] = sc; }
 
3177
  CT_BreakStmt (CTree *key, CTree *sc) { AddSon (sons[0], key); AddSon (sons[1], sc); }
 
3178
  /** Get the identifier for this node type. Can be compared with NodeName(). */
1815
3179
  static const char *NodeId ();
 
3180
  /** Get the name of the node. Can be compared with NodeId(). */
1816
3181
  const char *NodeName () const { return NodeId (); }
 
3182
  /** Get the number of sons. */
1817
3183
  int Sons () const { return 2; }
 
3184
  /** Get the n-th son.
 
3185
   *  \param n The index of the son.
 
3186
   *  \return The n-th son or NULL. */
1818
3187
  CTree *Son (int n) const { return CTree::Son (sons, 2, n); }
 
3188
  /** Replace a son.
 
3189
   *  \param old_son The son to replace.
 
3190
   *  \param new_son The new son. */
1819
3191
  void ReplaceSon (CTree *old_son, CTree *new_son) { 
1820
3192
    CTree::ReplaceSon (sons, 2, old_son, new_son);
1821
3193
  }
1825
3197
  CTree *sons[2]; // key, semi_colon
1826
3198
 
1827
3199
public:
1828
 
  CT_ContinueStmt (CTree *key, CTree *sc) { sons[0] = key; sons[1] = sc; }
 
3200
  CT_ContinueStmt (CTree *key, CTree *sc) { AddSon (sons[0], key); AddSon (sons[1], sc); }
 
3201
  /** Get the identifier for this node type. Can be compared with NodeName(). */
1829
3202
  static const char *NodeId ();
 
3203
  /** Get the name of the node. Can be compared with NodeId(). */
1830
3204
  const char *NodeName () const { return NodeId (); }
 
3205
  /** Get the number of sons. */
1831
3206
  int Sons () const { return 2; }
 
3207
  /** Get the n-th son.
 
3208
   *  \param n The index of the son.
 
3209
   *  \return The n-th son or NULL. */
1832
3210
  CTree *Son (int n) const { return CTree::Son (sons, 2, n); }
 
3211
  /** Replace a son.
 
3212
   *  \param old_son The son to replace.
 
3213
   *  \param new_son The new son. */
1833
3214
  void ReplaceSon (CTree *old_son, CTree *new_son) { 
1834
3215
    CTree::ReplaceSon (sons, 2, old_son, new_son);
1835
3216
  }
1840
3221
 
1841
3222
public:
1842
3223
  CT_GotoStmt (CTree *key, CTree *l, CTree *sc) {
1843
 
    sons[0] = key; sons[1] = l; sons[2] = sc; 
 
3224
    AddSon (sons[0], key); AddSon (sons[1], l); AddSon (sons[2], sc); 
1844
3225
  }
 
3226
  /** Get the identifier for this node type. Can be compared with NodeName(). */
1845
3227
  static const char *NodeId ();
 
3228
  /** Get the name of the node. Can be compared with NodeId(). */
1846
3229
  const char *NodeName () const { return NodeId (); }
 
3230
  /** Get the number of sons. */
1847
3231
  int Sons () const { return 3; }
 
3232
  /** Get the n-th son.
 
3233
   *  \param n The index of the son.
 
3234
   *  \return The n-th son or NULL. */
1848
3235
  CTree *Son (int n) const { return CTree::Son (sons, 3, n); }
1849
3236
  CT_SimpleName *Label () const { return (CT_SimpleName*)sons[1]; }
 
3237
  /** Replace a son.
 
3238
   *  \param old_son The son to replace.
 
3239
   *  \param new_son The new son. */
1850
3240
  void ReplaceSon (CTree *old_son, CTree *new_son) { 
1851
3241
    CTree::ReplaceSon (sons, 3, old_son, new_son);
1852
3242
  }
1857
3247
 
1858
3248
public:
1859
3249
  CT_ReturnStmt (CTree *key, CTree *e, CTree *sc) {
1860
 
    sons[0] = key; sons[1] = e; sons[2] = sc; 
 
3250
    AddSon (sons[0], key); AddSon (sons[1], e); AddSon (sons[2], sc); 
1861
3251
  }
 
3252
  /** Get the identifier for this node type. Can be compared with NodeName(). */
1862
3253
  static const char *NodeId ();
 
3254
  /** Get the name of the node. Can be compared with NodeId(). */
1863
3255
  const char *NodeName () const { return NodeId (); }
 
3256
  /** Get the number of sons. */
1864
3257
  int Sons () const { return CTree::Sons (sons, 3); }
 
3258
  /** Get the n-th son.
 
3259
   *  \param n The index of the son.
 
3260
   *  \return The n-th son or NULL. */
1865
3261
  CTree *Son (int n) const { return CTree::Son (sons, 3, n); }
1866
3262
  CTree *Expr () const { return sons[1]; }
 
3263
  /** Replace a son.
 
3264
   *  \param old_son The son to replace.
 
3265
   *  \param new_son The new son. */
1867
3266
  void ReplaceSon (CTree *old_son, CTree *new_son) { 
1868
3267
    CTree::ReplaceSon (sons, 3, old_son, new_son);
1869
3268
  }
1874
3273
 
1875
3274
public:
1876
3275
  CT_WhileStmt (CTree *kw, CTree *o, CTree *cond, CTree *c, CTree *stmt) {
1877
 
    sons[0] = kw; sons[1] = o; sons[2] = cond; sons[3] = c; sons[4] = stmt; 
 
3276
    AddSon (sons[0], kw); AddSon (sons[1], o); AddSon (sons[2], cond); 
 
3277
    AddSon (sons[3], c); AddSon (sons[4], stmt); 
1878
3278
  }
 
3279
  /** Get the identifier for this node type. Can be compared with NodeName(). */
1879
3280
  static const char *NodeId ();
 
3281
  /** Get the name of the node. Can be compared with NodeId(). */
1880
3282
  const char *NodeName () const { return NodeId (); }
 
3283
  /** Get the number of sons. */
1881
3284
  int Sons () const { return 5; }
 
3285
  /** Get the n-th son.
 
3286
   *  \param n The index of the son.
 
3287
   *  \return The n-th son or NULL. */
1882
3288
  CTree *Son (int n) const { return CTree::Son (sons, 5, n); }
1883
3289
  CT_Statement *Statement () const { return (CT_Statement*)sons[4]; }
1884
3290
  CTree *Condition () const { return sons[2]; }
 
3291
  /** Replace a son.
 
3292
   *  \param old_son The son to replace.
 
3293
   *  \param new_son The new son. */
1885
3294
  void ReplaceSon (CTree *old_son, CTree *new_son) { 
1886
3295
    CTree::ReplaceSon (sons, 5, old_son, new_son);
1887
3296
  }
 
3297
  CSemScope *SemScope () const { return (CSemScope*)this; }
1888
3298
};
1889
3299
 
1890
3300
class CT_DoStmt : public CT_Statement {
1893
3303
public:
1894
3304
  CT_DoStmt (CTree *d, CTree *stmt, CTree *w, CTree *o, CTree *e, 
1895
3305
             CTree *c, CTree *sc) {
1896
 
    sons[0] = d; sons[1] = stmt; sons[2] = w; sons[3] = o; sons[4] = e; 
1897
 
    sons[5] = c; sons[6] = sc; 
 
3306
    AddSon (sons[0], d); AddSon (sons[1], stmt); AddSon (sons[2], w); 
 
3307
    AddSon (sons[3], o); AddSon (sons[4], e); AddSon (sons[5], c); 
 
3308
    AddSon (sons[6], sc); 
1898
3309
  }
 
3310
  /** Get the identifier for this node type. Can be compared with NodeName(). */
1899
3311
  static const char *NodeId ();
 
3312
  /** Get the name of the node. Can be compared with NodeId(). */
1900
3313
  const char *NodeName () const { return NodeId (); }
 
3314
  /** Get the number of sons. */
1901
3315
  int Sons () const { return 7; }
 
3316
  /** Get the n-th son.
 
3317
   *  \param n The index of the son.
 
3318
   *  \return The n-th son or NULL. */
1902
3319
  CTree *Son (int n) const { return CTree::Son (sons, 7, n); }
1903
3320
  CT_Statement *Statement () const { return (CT_Statement*)sons[1]; }
1904
3321
  CTree *Expr () const { return sons[4]; }
 
3322
  /** Replace a son.
 
3323
   *  \param old_son The son to replace.
 
3324
   *  \param new_son The new son. */
1905
3325
  void ReplaceSon (CTree *old_son, CTree *new_son) { 
1906
3326
    CTree::ReplaceSon (sons, 7, old_son, new_son);
1907
3327
  }
1913
3333
public:
1914
3334
  CT_ForStmt (CTree *k, CTree *o, CTree *i, CTree *co, CTree *sc,
1915
3335
              CTree *e, CTree *c, CTree *stmt) {
1916
 
    sons[0] = k; sons[1] = o; sons[2] = i; sons[3] = co; 
1917
 
    sons[4] = sc; sons[5] = e; sons[6] = c; sons[7] = stmt; 
 
3336
    AddSon (sons[0], k); AddSon (sons[1], o); AddSon (sons[2], i); 
 
3337
    AddSon (sons[3], co); AddSon (sons[4], sc); AddSon (sons[5], e); 
 
3338
    AddSon (sons[6], c); AddSon (sons[7], stmt); 
1918
3339
  }
 
3340
  /** Get the identifier for this node type. Can be compared with NodeName(). */
1919
3341
  static const char *NodeId ();
 
3342
  /** Get the name of the node. Can be compared with NodeId(). */
1920
3343
  const char *NodeName () const { return NodeId (); }
 
3344
  /** Get the number of sons. */
1921
3345
  int Sons () const { return CTree::Sons (sons, 8); }
 
3346
  /** Get the n-th son.
 
3347
   *  \param n The index of the son.
 
3348
   *  \return The n-th son or NULL. */
1922
3349
  CTree *Son (int n) const { return CTree::Son (sons, 8, n); }
1923
3350
  CTree *InitStmt () const { return sons[2]; }
1924
3351
  CTree *Condition () const { return sons[3]; }
1925
3352
  CTree *Expr () const { return sons[5]; }
1926
3353
  CT_Statement *Statement () const { return (CT_Statement*)sons[7]; }
 
3354
  /** Replace a son.
 
3355
   *  \param old_son The son to replace.
 
3356
   *  \param new_son The new son. */
1927
3357
  void ReplaceSon (CTree *old_son, CTree *new_son) { 
1928
3358
    CTree::ReplaceSon (sons, 8, old_son, new_son);
1929
3359
  }
 
3360
  CSemScope *SemScope () const { return (CSemScope*)this; }
1930
3361
};
1931
3362
 
1932
3363
class CT_Condition : public CT_Decl, public CSemObject {
1934
3365
 
1935
3366
public:
1936
3367
  CT_Condition (CTree *dsl, CTree *d) {
1937
 
    sons[0] = dsl; sons[1] = d; sons[2] = 0;
 
3368
    AddSon (sons[0], dsl); AddSon (sons[1], d); AddSon (sons[2], 0);
1938
3369
  }
 
3370
  /** Get the identifier for this node type. Can be compared with NodeName(). */
1939
3371
  static const char *NodeId ();
 
3372
  /** Get the name of the node. Can be compared with NodeId(). */
1940
3373
  const char *NodeName () const { return NodeId (); }
 
3374
  /** Get the number of sons. */
1941
3375
  int Sons () const { return CTree::Sons (sons, 3); }
 
3376
  /** Get the n-th son.
 
3377
   *  \param n The index of the son.
 
3378
   *  \return The n-th son or NULL. */
1942
3379
  CTree *Son (int n) const { return CTree::Son (sons, 3, n); }
1943
3380
  CT_DeclSpecSeq *DeclSpecs () const { return (CT_DeclSpecSeq*)sons[0]; }
1944
3381
  CTree *Declarator () const { return sons[1]; }
1945
3382
  CT_ExprList *Initializer () const { return (CT_ExprList*)sons[2]; }
1946
3383
  CSemObject *SemObject () const { return (CSemObject*)this; }
1947
 
  void Initializer (CTree *i) { sons[2] = i; }
 
3384
  void Initializer (CTree *i) { AddSon (sons[2], i); }
 
3385
  /** Replace a son.
 
3386
   *  \param old_son The son to replace.
 
3387
   *  \param new_son The new son. */
1948
3388
  void ReplaceSon (CTree *old_son, CTree *new_son) { 
1949
3389
    CTree::ReplaceSon (sons, 3, old_son, new_son);
1950
3390
  }
1962
3402
 
1963
3403
public:
1964
3404
  CT_ClassDef (CTree *k, CTree *n, CTree *b = (CTree*)0) {
1965
 
    sons[0] = k; sons[1] = n; sons[2] = b; sons[3] = 0; obj_decl = 0; 
 
3405
    AddSon (sons[0], k); AddSon (sons[1], n); AddSon (sons[2], b); 
 
3406
    AddSon (sons[3], 0); AddSon (obj_decl, 0); 
1966
3407
  }
 
3408
  /** Get the identifier for this node type. Can be compared with NodeName(). */
1967
3409
  static const char *NodeId ();
 
3410
  /** Get the name of the node. Can be compared with NodeId(). */
1968
3411
  const char *NodeName () const { return NodeId (); }
 
3412
  /** Get the number of sons. */
1969
3413
  int Sons () const { return CTree::Sons (sons, 4); }
 
3414
  /** Get the n-th son.
 
3415
   *  \param n The index of the son.
 
3416
   *  \return The n-th son or NULL. */
1970
3417
  CTree *Son (int n) const { return CTree::Son (sons, 4, n); }
1971
3418
  CT_SimpleName *Name () const { return (CT_SimpleName*)sons[1]; }
1972
3419
  CT_MembList *Members () const { return (CT_MembList*)sons[3]; }
1973
3420
  CT_BaseSpecList *BaseClasses () const { return (CT_BaseSpecList*)sons[2]; }
1974
3421
  CT_ObjDecl *ObjDecl () const { return (CT_ObjDecl*)obj_decl; }
1975
3422
  CSemObject *SemObject () const { return (CSemObject*)this; }
1976
 
  void Members (CTree *m) { sons[3] = m; }
1977
 
  void BaseClasses (CTree *bc) { sons[2] = bc; }
1978
 
  void ObjDecl (CTree *od) { obj_decl = od; }
 
3423
  void Members (CTree *m) { AddSon (sons[3], m); }
 
3424
  void BaseClasses (CTree *bc) { AddSon (sons[2], bc); }
 
3425
  void ObjDecl (CTree *od) { AddSon (obj_decl, od); }
 
3426
  /** Replace a son.
 
3427
   *  \param old_son The son to replace.
 
3428
   *  \param new_son The new son. */
1979
3429
  void ReplaceSon (CTree *old_son, CTree *new_son) {
1980
 
    // &(...) is used here to avoid strange warnings by mingw32-g++
1981
 
    CTree::ReplaceSon (&(sons[0]), 4, old_son, new_son);
 
3430
    CTree::ReplaceSon (sons, 4, old_son, new_son);
1982
3431
  }
1983
3432
};
1984
3433
      
1986
3435
public:
1987
3436
  CT_UnionDef (CTree *k, CTree *n, CTree *b = 0) : CT_ClassDef (k, n, b) {}
1988
3437
  static const char *NodeId ();
 
3438
  /** Get the name of the node. Can be compared with NodeId(). */
1989
3439
  const char *NodeName () const { return NodeId (); }
1990
3440
};
1991
3441
      
1993
3443
public:
1994
3444
  CT_MembList (int size = 10, int incr = 10) : 
1995
3445
    CT_DeclList (size, incr) {}
 
3446
  /** Get the identifier for this node type. Can be compared with NodeName(). */
1996
3447
  static const char *NodeId ();
 
3448
  /** Get the name of the node. Can be compared with NodeId(). */
1997
3449
  const char *NodeName () const { return NodeId (); }
 
3450
  CSemScope *SemScope () const { return (CSemScope*)this; }
1998
3451
};
1999
3452
 
2000
3453
class CT_MembInitList : public CT_List, public CSemScope {
2002
3455
  CT_MembInitList (int size = 2) : 
2003
3456
    CT_List (size, 2, CT_List::OPEN) {}
2004
3457
  static const char *NodeId ();
 
3458
  /** Get the name of the node. Can be compared with NodeId(). */
2005
3459
  const char *NodeName () const { return NodeId (); }
 
3460
  CSemScope *SemScope () const { return (CSemScope*)this; }
2006
3461
};
2007
3462
 
2008
3463
class CT_MembInit : public CT_Expression, public CSemObject {
2009
3464
  CTree *sons[2]; // name, init
2010
3465
 
2011
3466
public:
2012
 
  CT_MembInit (CTree *n, CTree *i) { sons[0] = n; sons[1] = i; }
 
3467
  CT_MembInit (CTree *n, CTree *i) { AddSon (sons[0], n); AddSon (sons[1], i); }
 
3468
  /** Get the identifier for this node type. Can be compared with NodeName(). */
2013
3469
  static const char *NodeId ();
 
3470
  /** Get the name of the node. Can be compared with NodeId(). */
2014
3471
  const char *NodeName () const { return NodeId (); }
 
3472
  /** Get the number of sons. */
2015
3473
  int Sons () const { return 2; }
 
3474
  /** Get the n-th son.
 
3475
   *  \param n The index of the son.
 
3476
   *  \return The n-th son or NULL. */
2016
3477
  CTree *Son (int n) const { return CTree::Son (sons, 2, n); }
 
3478
  /** Replace a son.
 
3479
   *  \param old_son The son to replace.
 
3480
   *  \param new_son The new son. */
2017
3481
  void ReplaceSon (CTree *old_son, CTree *new_son) { 
2018
3482
    CTree::ReplaceSon (sons, 2, old_son, new_son);
2019
3483
  }
2026
3490
public:
2027
3491
  CT_BaseSpecList (int size = 2) : 
2028
3492
    CT_List (size, 2, CT_List::OPEN|CT_List::SEPARATORS) {}
 
3493
  /** Get the identifier for this node type. Can be compared with NodeName(). */
2029
3494
  static const char *NodeId ();
 
3495
  /** Get the name of the node. Can be compared with NodeId(). */
2030
3496
  const char *NodeName () const { return NodeId (); }
2031
3497
};
2032
3498
 
2034
3500
  CTree *sons[2]; // access, colon
2035
3501
 
2036
3502
public:
2037
 
  CT_AccessSpec (CTree *a, CTree *c) { sons[0] = a; sons[1] = c; }
 
3503
  CT_AccessSpec (CTree *a, CTree *c) { AddSon (sons[0], a); AddSon (sons[1], c); }
 
3504
  /** Get the identifier for this node type. Can be compared with NodeName(). */
2038
3505
  static const char *NodeId ();
 
3506
  /** Get the name of the node. Can be compared with NodeId(). */
2039
3507
  const char *NodeName () const { return NodeId (); }
 
3508
  /** Get the number of sons. */
2040
3509
  int Sons () const { return 2; }
 
3510
  /** Get the n-th son.
 
3511
   *  \param n The index of the son.
 
3512
   *  \return The n-th son or NULL. */
2041
3513
  CTree *Son (int n) const { return CTree::Son (sons, 2, n); }
2042
3514
  int Access () const { return sons[0]->token ()->type (); }
 
3515
  /** Replace a son.
 
3516
   *  \param old_son The son to replace.
 
3517
   *  \param new_son The new son. */
2043
3518
  void ReplaceSon (CTree *old_son, CTree *new_son) { 
2044
3519
    CTree::ReplaceSon (sons, 2, old_son, new_son);
2045
3520
  }
2050
3525
 
2051
3526
public:
2052
3527
  CT_BaseSpec (CTree *v, CTree *a, CTree *n) {
2053
 
    sons[0] = v; sons[1] = a; sons[2] = n; 
 
3528
    AddSon (sons[0], v); AddSon (sons[1], a); AddSon (sons[2], n); 
2054
3529
  }
 
3530
  /** Get the identifier for this node type. Can be compared with NodeName(). */
2055
3531
  static const char *NodeId ();
 
3532
  /** Get the name of the node. Can be compared with NodeId(). */
2056
3533
  const char *NodeName () const { return NodeId (); }
 
3534
  /** Get the number of sons. */
2057
3535
  int Sons () const { return CTree::Sons (sons, 3); }
 
3536
  /** Get the n-th son.
 
3537
   *  \param n The index of the son.
 
3538
   *  \return The n-th son or NULL. */
2058
3539
  CTree *Son (int n) const { return CTree::Son (sons, 3, n); }
2059
3540
  int Access () const { return sons[1]->token ()->type (); }
2060
3541
  CTree *AccessSpec () const { return sons[1]; }
2061
3542
  CTree *Virtual () const { return sons[0]; }
2062
3543
  CT_SimpleName *Name () const { return (CT_SimpleName*)sons[2]; }
 
3544
  /** Replace a son.
 
3545
   *  \param old_son The son to replace.
 
3546
   *  \param new_son The new son. */
2063
3547
  void ReplaceSon (CTree *old_son, CTree *new_son) { 
2064
3548
    CTree::ReplaceSon (sons, 3, old_son, new_son);
2065
3549
  }
2069
3553
  CTree *sons[2]; // name, semi_colon
2070
3554
 
2071
3555
public:
2072
 
  CT_AccessDecl (CTree *n, CTree *s) { sons[0] = n; sons[1] = s; }
 
3556
  CT_AccessDecl (CTree *n, CTree *s) { AddSon (sons[0], n); AddSon (sons[1], s); }
 
3557
  /** Get the identifier for this node type. Can be compared with NodeName(). */
2073
3558
  static const char *NodeId ();
 
3559
  /** Get the name of the node. Can be compared with NodeId(). */
2074
3560
  const char *NodeName () const { return NodeId (); }
 
3561
  /** Get the number of sons. */
2075
3562
  int Sons () const { return 2; }
 
3563
  /** Get the n-th son.
 
3564
   *  \param n The index of the son.
 
3565
   *  \return The n-th son or NULL. */
2076
3566
  CTree *Son (int n) const { return CTree::Son (sons, 2, n); }
2077
3567
  CT_QualName *Member () const { return (CT_QualName*)sons[0]; }
 
3568
  /** Replace a son.
 
3569
   *  \param old_son The son to replace.
 
3570
   *  \param new_son The new son. */
2078
3571
  void ReplaceSon (CTree *old_son, CTree *new_son) { 
2079
3572
    CTree::ReplaceSon (sons, 2, old_son, new_son);
2080
3573
  }
2085
3578
 
2086
3579
public:
2087
3580
  CT_UsingDecl (CTree *u, CTree *n, CTree *s) : CT_AccessDecl (n, s) {
2088
 
    sons[0] = u; sons[1] = 0; 
 
3581
    AddSon (sons[0], u); AddSon (sons[1], 0); 
2089
3582
  }
2090
3583
  CT_UsingDecl (CTree *u, CTree *t, CTree *n, CTree *s) : CT_AccessDecl (n, s) {
2091
 
    sons[0] = u; sons[1] = t; 
 
3584
    AddSon (sons[0], u); AddSon (sons[1], t); 
2092
3585
  }
 
3586
  /** Get the identifier for this node type. Can be compared with NodeName(). */
2093
3587
  static const char *NodeId ();
 
3588
  /** Get the name of the node. Can be compared with NodeId(). */
2094
3589
  const char *NodeName () const { return NodeId (); }
 
3590
  /** Get the number of sons. */
2095
3591
  int Sons () const { return CTree::Sons (sons, 2) + CT_AccessDecl::Sons (); }
 
3592
  /** Get the n-th son.
 
3593
   *  \param n The index of the son.
 
3594
   *  \return The n-th son or NULL. */
2096
3595
  CTree *Son (int n) const {
2097
3596
    int num = CTree::Sons (sons, 2);
2098
3597
    CTree *result = CTree::Son (sons, 2, n);
2099
3598
    return result ? result : CT_AccessDecl::Son (n-num);
2100
3599
  }
2101
3600
  CTree *Typename () const { return sons[1]; }
 
3601
  /** Replace a son.
 
3602
   *  \param old_son The son to replace.
 
3603
   *  \param new_son The new son. */
2102
3604
  void ReplaceSon (CTree *old_son, CTree *new_son) { 
2103
3605
    CTree::ReplaceSon (sons, 2, old_son, new_son);
2104
3606
    CT_AccessDecl::ReplaceSon (old_son, new_son);
2115
3617
  CTree *sons[2]; // keyword, extension
2116
3618
 
2117
3619
public:
2118
 
  CT_Any (CTree *k, CTree *e = (CTree*)0) { sons[0] = k; sons[1] = e; }
 
3620
  CT_Any (CTree *k, CTree *e = (CTree*)0) { AddSon (sons[0], k); AddSon (sons[1], e); }
 
3621
  /** Get the identifier for this node type. Can be compared with NodeName(). */
2119
3622
  static const char *NodeId ();
 
3623
  /** Get the name of the node. Can be compared with NodeId(). */
2120
3624
  const char *NodeName () const { return NodeId (); }
 
3625
  /** Get the number of sons. */
2121
3626
  int Sons () const { return CTree::Sons (sons, 2); }
 
3627
  /** Get the n-th son.
 
3628
   *  \param n The index of the son.
 
3629
   *  \return The n-th son or NULL. */
2122
3630
  CTree *Son (int n) const { return CTree::Son (sons, 2, n); }
 
3631
  /** Replace a son.
 
3632
   *  \param old_son The son to replace.
 
3633
   *  \param new_son The new son. */
2123
3634
  void ReplaceSon (CTree *old_son, CTree *new_son) { 
2124
3635
    CTree::ReplaceSon (sons, 2, old_son, new_son);
2125
3636
  }
2130
3641
class CT_AnyList : public CT_Any {
2131
3642
public:
2132
3643
  CT_AnyList (CTree *k, CTree *e = (CTree*)0) : CT_Any (k, e) {}
 
3644
  /** Get the identifier for this node type. Can be compared with NodeName(). */
2133
3645
  static const char *NodeId ();
 
3646
  /** Get the name of the node. Can be compared with NodeId(). */
2134
3647
  const char *NodeName () const { return NodeId (); }
2135
3648
};
2136
3649
 
2139
3652
 
2140
3653
public:
2141
3654
  CT_AnyExtension (CTree *o, CTree *n, CTree *co, CTree *c, CTree *cr) {
2142
 
    sons[0] = o; sons[1] = n; sons[2] = co; sons[3] = c; sons[4] = cr; 
 
3655
    AddSon (sons[0], o); AddSon (sons[1], n); AddSon (sons[2], co); 
 
3656
    AddSon (sons[3], c); AddSon (sons[4], cr); 
2143
3657
  }
 
3658
  /** Get the identifier for this node type. Can be compared with NodeName(). */
2144
3659
  static const char *NodeId ();
 
3660
  /** Get the name of the node. Can be compared with NodeId(). */
2145
3661
  const char *NodeName () const { return NodeId (); }
 
3662
  /** Get the number of sons. */
2146
3663
  int Sons () const { return CTree::Sons (sons, 5); }
 
3664
  /** Get the n-th son.
 
3665
   *  \param n The index of the son.
 
3666
   *  \return The n-th son or NULL. */
2147
3667
  CTree *Son (int n) const { return CTree::Son (sons, 5, n); }
 
3668
  /** Replace a son.
 
3669
   *  \param old_son The son to replace.
 
3670
   *  \param new_son The new son. */
2148
3671
  void ReplaceSon (CTree *old_son, CTree *new_son) { 
2149
3672
    CTree::ReplaceSon (sons, 5, old_son, new_son);
2150
3673
  }
2162
3685
 
2163
3686
public:
2164
3687
  CT_AnyCondition (CTree *a1, CTree *a2 = (CTree*)0, CTree *a3 = (CTree*)0) {
2165
 
    sons[0] = a1; sons[1] = a2; sons[2] = a3; 
 
3688
    AddSon (sons[0], a1); AddSon (sons[1], a2); AddSon (sons[2], a3); 
2166
3689
  }
 
3690
  /** Get the identifier for this node type. Can be compared with NodeName(). */
2167
3691
  static const char *NodeId ();
 
3692
  /** Get the name of the node. Can be compared with NodeId(). */
2168
3693
  const char *NodeName () const { return NodeId (); }
 
3694
  /** Get the number of sons. */
2169
3695
  int Sons () const { return CTree::Sons (sons, 3); }
 
3696
  /** Get the n-th son.
 
3697
   *  \param n The index of the son.
 
3698
   *  \return The n-th son or NULL. */
2170
3699
  CTree *Son (int n) const { return CTree::Son (sons, 3, n); }
 
3700
  /** Replace a son.
 
3701
   *  \param old_son The son to replace.
 
3702
   *  \param new_son The new son. */
2171
3703
  void ReplaceSon (CTree *old_son, CTree *new_son) { 
2172
3704
    CTree::ReplaceSon (sons, 3, old_son, new_son);
2173
3705
  }