~ubuntu-branches/ubuntu/wily/aspectc++/wily

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Reinhard Tartler
  • Date: 2009-06-15 10:17:02 UTC
  • mfrom: (1.2.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20090615101702-qsr30iptwbxylmo2
Tags: 1.0pre4~svn.20090615-1
* New upstream release.
* don't ignore errors in the postrm script
* avoid spurious creation of empty dir ./usr/sbin/
* improve short descriptions of libpuma-doc and libpuma-dev
* bump Standards-Version to 3.8.1
* bump debhelper compat level to level 7 (latest in stable)

Show diffs side-by-side

added added

removed removed

Lines of Context:
162
162
  return _sons.lookup (n);
163
163
}
164
164
 
 
165
void CT_List::AddSon (CTree *s) { 
 
166
  if (s) { 
 
167
    _son2idx[s] = _sons.length ();
 
168
    _sons.append (s); 
 
169
    SetParent (s, this); 
 
170
  } 
 
171
}
 
172
 
 
173
void CT_List::PrefixSon (CTree *s) { 
 
174
  if (s) { 
 
175
    SonToIndexMap::iterator idx = _son2idx.begin();
 
176
    for (; idx != _son2idx.end(); ++idx) idx->second++;
 
177
    _son2idx[s] = 0;
 
178
    _sons.prepend (s);
 
179
    SetParent (s, this); 
 
180
  } 
 
181
}
 
182
 
 
183
void CT_List::InsertSon (int idx, CTree *s) { 
 
184
  int len = _sons.length();
 
185
  if (s && idx <= len) { 
 
186
    _son2idx[s] = idx;
 
187
    _sons.insert (idx, s); 
 
188
    for (int i = idx+1; i < len; ++i) _son2idx[_sons[i]] = i;
 
189
    SetParent (s, this); 
 
190
  } 
 
191
}
 
192
 
 
193
void CT_List::ReplaceSon (int idx, CTree *s) { 
 
194
  if (s && idx < Sons ()) { 
 
195
    _son2idx.erase(_sons[idx]);
 
196
    _son2idx[s] = idx;
 
197
    SetParent (_sons[idx], 0); 
 
198
    _sons[idx] = s; 
 
199
    SetParent (s, this); 
 
200
  } 
 
201
}
 
202
 
 
203
void CT_List::RemoveSon (int idx) { 
 
204
  int len = _sons.length();
 
205
  if (idx < len) { 
 
206
    _son2idx.erase(_sons[idx]);
 
207
    for (int i = idx+1; i < len; ++i) _son2idx[_sons[i]]--;
 
208
    SetParent (_sons[idx], 0); 
 
209
    _sons.remove (idx);
 
210
  } 
 
211
}
 
212
 
165
213
void CT_List::InsertSon (CTree *before_son, CTree *new_son) {
166
 
  int sons = Sons ();
167
 
  for (int i = 0; i < sons; i++) {
168
 
    if (Son (i) == before_son) {
169
 
      _sons.insert (i, new_son);
170
 
      if (new_son) SetParent (new_son, this);
171
 
      break;
 
214
  SonToIndexMap::iterator iidx = _son2idx.find(before_son);
 
215
  if (iidx != _son2idx.end()) {
 
216
    int idx = iidx->second; 
 
217
    if (new_son) {
 
218
      SetParent (new_son, this); 
 
219
      _son2idx[new_son] = idx;
172
220
    }
 
221
    _sons.insert(idx, new_son);
 
222
    int len = _sons.length();
 
223
    for (int i = idx+1; i < len; ++i) _son2idx[_sons[i]]++;
173
224
  }
174
225
}
175
226
 
176
227
void CT_List::ReplaceSon (CTree *old_son, CTree *new_son) {
177
 
  int sons = Sons ();
178
 
  for (int i = 0; i < sons; i++) {
179
 
    if (Son (i) == old_son) {
180
 
      _sons[i] = new_son;
181
 
      if (new_son) SetParent (new_son, this);
182
 
      break;
 
228
  SonToIndexMap::iterator iidx = _son2idx.find(old_son);
 
229
  if (iidx != _son2idx.end()) {
 
230
    int idx = iidx->second; 
 
231
    _son2idx.erase(iidx);
 
232
    if (new_son) {
 
233
      _son2idx[new_son] = idx;
 
234
      SetParent (new_son, this);
183
235
    }
 
236
    _sons[idx] = new_son;
184
237
  }
185
238
}
186
239
 
187
240
void CT_List::RemoveSon (CTree *son) {
188
 
  int sons = Sons ();
189
 
  for (int i = 0; i < sons; i++) {
190
 
    if (Son (i) == son) {
191
 
      _sons.remove (i);
192
 
      break;
193
 
    }
 
241
  SonToIndexMap::iterator iidx = _son2idx.find(son);
 
242
  if (iidx != _son2idx.end()) {
 
243
    int idx = iidx->second; 
 
244
    _son2idx.erase(iidx);
 
245
    SetParent (son, 0); 
 
246
    _sons.remove(idx);
 
247
    int len = _sons.length();
 
248
    for (int i = idx; i < len; ++i) _son2idx[_sons[i]]--;
194
249
  }
195
250
}
196
251
 
216
271
    case TOK_CHAR     : _type = PDS_CHAR    ; break;
217
272
    case TOK_WCHAR_T  : _type = PDS_WCHAR_T ; break;
218
273
    case TOK_BOOL     : _type = PDS_BOOL    ; break;
219
 
    case TOK_C_BOOL   : _type = PDS_INT     ; break;
 
274
    case TOK_C_BOOL   : _type = PDS_C_BOOL  ; break;
220
275
    case TOK_SHORT    : _type = PDS_SHORT   ; break;
221
276
    case TOK_INT      : _type = PDS_INT     ; break;
222
277
    case TOK_LONG     : _type = PDS_LONG    ; break;
225
280
    case TOK_FLOAT    : _type = PDS_FLOAT   ; break;
226
281
    case TOK_DOUBLE   : _type = PDS_DOUBLE  ; break;
227
282
    case TOK_VOID     : _type = PDS_VOID    ; break;
 
283
    // GNU C++ specific storage class specifier
 
284
    case TOK_THREAD   : _type = PDS_THREAD  ; break;
228
285
    // AspectC++ specific type specifier
229
286
    case TOK_UNKNOWN_T: _type = PDS_UNKNOWN_T; break;
230
287
    // Win specific declaration specifiers 
399
456
const char *CT_ImplicitCast::NodeId () { return "ImplicitCast"; }
400
457
const char *CT_TypeidExpr::NodeId () { return "TypeidExpr"; }
401
458
const char *CT_SizeofExpr::NodeId () { return "SizeofExpr"; }
 
459
const char *CT_AlignofExpr::NodeId () { return "AlignofExpr"; }
 
460
const char *CT_TypeTraitExpr::NodeId () { return "TypeTraitExpr"; }
 
461
const char *CT_OffsetofExpr::NodeId () { return "OffsetofExpr"; }
402
462
const char *CT_IndexDesignator::NodeId () { return "IndexDesignator"; }
403
463
const char *CT_MembDesignator::NodeId () { return "MembDesignator"; }
404
464
const char *CT_DesignatorSeq::NodeId () { return "DesignatorSeq"; }