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

« back to all changes in this revision

Viewing changes to Puma/gen-release/step1/src/CScopeInfo.cc

  • Committer: Bazaar Package Importer
  • Author(s): Reinhard Tartler
  • Date: 2005-12-23 10:49:40 UTC
  • Revision ID: james.westby@ubuntu.com-20051223104940-ig4klhoi991zs7km
Tags: upstream-0.99+1.0pre2
ImportĀ upstreamĀ versionĀ 0.99+1.0pre2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// This file is part of PUMA.
 
2
// Copyright (C) 1999-2003  The PUMA developer team.
 
3
//                                                                
 
4
// This program is free software;  you can redistribute it and/or 
 
5
// modify it under the terms of the GNU General Public License as 
 
6
// published by the Free Software Foundation; either version 2 of 
 
7
// the License, or (at your option) any later version.            
 
8
//                                                                
 
9
// This program is distributed in the hope that it will be useful,
 
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of 
 
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the  
 
12
// GNU General Public License for more details.                   
 
13
//                                                                
 
14
// You should have received a copy of the GNU General Public      
 
15
// License along with this program; if not, write to the Free     
 
16
// Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, 
 
17
// MA  02111-1307  USA                                            
 
18
 
 
19
#include "Puma/CScopeInfo.h"
 
20
#include "Puma/CFunctionInfo.h"
 
21
#include "Puma/CNamespaceInfo.h"
 
22
#include "Puma/CClassInfo.h"
 
23
#include "Puma/CUnionInfo.h"
 
24
#include "Puma/CFctInstance.h"
 
25
#include "Puma/CClassInstance.h"
 
26
#include "Puma/CUnionInstance.h"
 
27
#include "Puma/CLocalScope.h"
 
28
#include "Puma/CTemplateInfo.h"
 
29
 
 
30
namespace Puma {
 
31
 
 
32
 
 
33
CScopeInfo::~CScopeInfo () {
 
34
//  for (unsigned i = 0; i < Children (); i++) {
 
35
//    CScopeInfo *s = Child (i);
 
36
//    if (s->TemplateInfo ())
 
37
//      s->TemplateInfo ()->removeLinks ();
 
38
//    s->Parent ((CScopeInfo*)0);
 
39
//    if (! _DeleteMembersOnly) {
 
40
//      if (s->LocalScope ()) delete s->LocalScope ();
 
41
//      else if (s->FctInstance ()) delete s->FctInstance ();
 
42
//      else if (s->ClassInstance ()) delete s->ClassInstance ();
 
43
//      else if (s->UnionInstance ()) delete s->UnionInstance ();
 
44
//      else if (s->FunctionInfo ()) delete s->FunctionInfo ();
 
45
//      else if (s->ClassInfo ()) delete s->ClassInfo ();
 
46
//      else if (s->UnionInfo ()) delete s->UnionInfo ();
 
47
//      else if (s->TemplateInfo ()) delete s->TemplateInfo (); 
 
48
//      else if (s->NamespaceInfo () && ! s->FileInfo ()) 
 
49
//        delete s->NamespaceInfo ();
 
50
//    }
 
51
//  }
 
52
//  if (Parent () && Parent () != this)
 
53
//    Parent ()->removeChild (this); 
 
54
}
 
55
 
 
56
bool CScopeInfo::isMethod () const { 
 
57
  return FunctionInfo () && FunctionInfo ()->Record (); 
 
58
}
 
59
 
 
60
bool CScopeInfo::isClassTemplate () const { 
 
61
  return TemplateInfo () && (TemplateInfo ()->isClass () ||
 
62
                             TemplateInfo ()->isAttribute ()); 
 
63
}
 
64
 
 
65
bool CScopeInfo::isFctTemplate () const { 
 
66
  return TemplateInfo () && TemplateInfo ()->isFunction (); 
 
67
}
 
68
 
 
69
void CScopeInfo::Parent (const CScopeInfo *info) { 
 
70
  if (_Parent != info) {
 
71
    if (info != 0) {
 
72
      ((CScopeInfo*)info)->addChild (this);
 
73
    }
 
74
    _Parent = (CScopeInfo*)info;
 
75
  }
 
76
}
 
77
 
 
78
void CScopeInfo::addChild (CScopeInfo *info) { 
 
79
//  for (unsigned i = Children (); i > 0; i--) 
 
80
//    if (Child (i-1) == info) 
 
81
//      return;
 
82
  _Children.append (info); 
 
83
}
 
84
 
 
85
void CScopeInfo::removeChild (const CScopeInfo *info) { 
 
86
  for (unsigned i = Children (); i > 0; i--) 
 
87
    if (Child (i-1) == info) {
 
88
      _Children.remove (i-1); 
 
89
      break;
 
90
    }
 
91
}
 
92
 
 
93
CLocalScope *CScopeInfo::newLocalScope () {
 
94
  CLocalScope *info = new CLocalScope;
 
95
  info->ClassDB (ClassDB ());
 
96
  info->Parent (this);
 
97
  return info;
 
98
}
 
99
 
 
100
CNamespaceInfo *CScopeInfo::newNamespace () {
 
101
  CNamespaceInfo *info = new CNamespaceInfo;
 
102
  info->Parent (this);
 
103
  info->ClassDB (ClassDB ());
 
104
  if (Structure ())
 
105
    Structure ()->addNamespace (info);
 
106
  return info;
 
107
}
 
108
 
 
109
CTemplateInfo *CScopeInfo::newTemplate () {
 
110
  CTemplateInfo *info = new CTemplateInfo;
 
111
  info->ClassDB (ClassDB ());
 
112
  info->Parent (this);
 
113
  return info;
 
114
}
 
115
 
 
116
CFunctionInfo *CScopeInfo::newFunction (bool inst) {
 
117
  CFunctionInfo *info;
 
118
  if (inst)
 
119
    info = new CFctInstance;
 
120
  else
 
121
    info = new CFunctionInfo;
 
122
  info->Parent (this);
 
123
  info->ClassDB (ClassDB ());
 
124
  if (Structure ())
 
125
    Structure ()->addFunction (info);
 
126
  return info;
 
127
}
 
128
 
 
129
CClassInfo *CScopeInfo::newClass (bool inst) {
 
130
  CClassInfo *info;
 
131
  if (inst)
 
132
    info = new CClassInstance;
 
133
  else
 
134
    info = new CClassInfo;
 
135
  info->Parent (this);
 
136
  info->ClassDB (ClassDB ());
 
137
  if (Structure ())
 
138
    Structure ()->addType (info);
 
139
  return info;
 
140
}
 
141
 
 
142
CUnionInfo *CScopeInfo::newUnion (bool inst) {
 
143
  CUnionInfo *info;
 
144
  if (inst)
 
145
    info = new CUnionInstance;
 
146
  else
 
147
    info = new CUnionInfo;
 
148
  info->Parent (this);
 
149
  info->ClassDB (ClassDB ());
 
150
  if (Structure ())
 
151
    Structure ()->addType (info);
 
152
  return info;
 
153
}
 
154
 
 
155
void CScopeInfo::deleteLocalScope (const CLocalScope *info) {
 
156
  for (unsigned i = Children (); i > 0; i--) 
 
157
    if (Child (i-1) == (CScopeInfo*)info) {
 
158
      delete (CLocalScope*)_Children[i-1];
 
159
      _Children.remove (i-1); 
 
160
      break;
 
161
    }
 
162
}
 
163
 
 
164
void CScopeInfo::deleteNamespace (const CNamespaceInfo *info) {
 
165
  for (unsigned i = Children (); i > 0; i--) 
 
166
    if (Child (i-1) == (CScopeInfo*)info) {
 
167
      delete (CNamespaceInfo*)_Children[i-1];
 
168
      _Children.remove (i-1); 
 
169
      break;
 
170
    }
 
171
}
 
172
 
 
173
void CScopeInfo::deleteTemplate (const CTemplateInfo *info) {
 
174
  for (unsigned i = Children (); i > 0; i--) 
 
175
    if (Child (i-1) == (CScopeInfo*)info) {
 
176
      delete (CTemplateInfo*)_Children[i-1];
 
177
      _Children.remove (i-1); 
 
178
      break;
 
179
    }
 
180
}
 
181
 
 
182
void CScopeInfo::deleteFunction (const CFunctionInfo *info) {
 
183
  for (unsigned i = Children (); i > 0; i--) 
 
184
    if (Child (i-1) == (CScopeInfo*)info) {
 
185
      delete (CFunctionInfo*)_Children[i-1];
 
186
      _Children.remove (i-1); 
 
187
      break;
 
188
    }
 
189
}
 
190
 
 
191
void CScopeInfo::deleteClass (const CClassInfo *info) {
 
192
  for (unsigned i = Children (); i > 0; i--) 
 
193
    if (Child (i-1) == (CScopeInfo*)info) {
 
194
      delete (CClassInfo*)_Children[i-1];
 
195
      _Children.remove (i-1); 
 
196
      break;
 
197
    }
 
198
}
 
199
 
 
200
void CScopeInfo::deleteUnion (const CUnionInfo *info) {
 
201
  for (unsigned i = Children (); i > 0; i--) 
 
202
    if (Child (i-1) == (CScopeInfo*)info) {
 
203
      delete (CUnionInfo*)_Children[i-1];
 
204
      _Children.remove (i-1); 
 
205
      break;
 
206
    }
 
207
}
 
208
 
 
209
 
 
210
} // namespace Puma