162
162
return _sons.lookup (n);
165
void CT_List::AddSon (CTree *s) {
167
_son2idx[s] = _sons.length ();
173
void CT_List::PrefixSon (CTree *s) {
175
SonToIndexMap::iterator idx = _son2idx.begin();
176
for (; idx != _son2idx.end(); ++idx) idx->second++;
183
void CT_List::InsertSon (int idx, CTree *s) {
184
int len = _sons.length();
185
if (s && idx <= len) {
187
_sons.insert (idx, s);
188
for (int i = idx+1; i < len; ++i) _son2idx[_sons[i]] = i;
193
void CT_List::ReplaceSon (int idx, CTree *s) {
194
if (s && idx < Sons ()) {
195
_son2idx.erase(_sons[idx]);
197
SetParent (_sons[idx], 0);
203
void CT_List::RemoveSon (int idx) {
204
int len = _sons.length();
206
_son2idx.erase(_sons[idx]);
207
for (int i = idx+1; i < len; ++i) _son2idx[_sons[i]]--;
208
SetParent (_sons[idx], 0);
165
213
void CT_List::InsertSon (CTree *before_son, CTree *new_son) {
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);
214
SonToIndexMap::iterator iidx = _son2idx.find(before_son);
215
if (iidx != _son2idx.end()) {
216
int idx = iidx->second;
218
SetParent (new_son, this);
219
_son2idx[new_son] = idx;
221
_sons.insert(idx, new_son);
222
int len = _sons.length();
223
for (int i = idx+1; i < len; ++i) _son2idx[_sons[i]]++;
176
227
void CT_List::ReplaceSon (CTree *old_son, CTree *new_son) {
178
for (int i = 0; i < sons; i++) {
179
if (Son (i) == old_son) {
181
if (new_son) SetParent (new_son, this);
228
SonToIndexMap::iterator iidx = _son2idx.find(old_son);
229
if (iidx != _son2idx.end()) {
230
int idx = iidx->second;
231
_son2idx.erase(iidx);
233
_son2idx[new_son] = idx;
234
SetParent (new_son, this);
236
_sons[idx] = new_son;
187
240
void CT_List::RemoveSon (CTree *son) {
189
for (int i = 0; i < sons; i++) {
190
if (Son (i) == son) {
241
SonToIndexMap::iterator iidx = _son2idx.find(son);
242
if (iidx != _son2idx.end()) {
243
int idx = iidx->second;
244
_son2idx.erase(iidx);
247
int len = _sons.length();
248
for (int i = idx; i < len; ++i) _son2idx[_sons[i]]--;
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"; }