~ubuntu-branches/ubuntu/jaunty/aspectc++/jaunty

« back to all changes in this revision

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

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

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
#ifndef __CSemDatabase_h__
 
20
#define __CSemDatabase_h__
 
21
 
 
22
/** \file 
 
23
 *  Semantic information database. */
 
24
 
 
25
#include "Puma/CScopeInfo.h"
 
26
#include "Puma/CProject.h"
 
27
#include <iostream>
 
28
#include <map>
 
29
using namespace std;
 
30
 
 
31
namespace Puma {
 
32
 
 
33
 
 
34
class CObjectInfo;
 
35
class CClassInfo;
 
36
class CUnionInfo;
 
37
class CEnumInfo;
 
38
class CTypedefInfo;
 
39
class CTemplateParamInfo;
 
40
class CTypeInfo;
 
41
class CFileInfo;
 
42
class Token;
 
43
 
 
44
/** \class CSemDatabase CSemDatabase.h Puma/CSemDatabase.h
 
45
 *  Semantic information database. Contains all semantic objects
 
46
 *  created during the semantic analysis for one translation
 
47
 *  unit. */
 
48
class CSemDatabase {
 
49
  Array<CObjectInfo*> _Classes;    // index of classes
 
50
  Array<CObjectInfo*> _Unions;     // index of unions
 
51
  Array<CObjectInfo*> _Enums;      // index of enums
 
52
  Array<CObjectInfo*> _Typedefs;   // index of typedefs
 
53
  Array<CObjectInfo*> _Functions;  // index of functions
 
54
  Array<CObjectInfo*> _Files;      // index of files
 
55
 
 
56
  CProject *_Project; // associated project
 
57
  
 
58
  multimap<int,CFunctionInfo*> _builtin_ops; // map for built-in operator lookup
 
59
 
 
60
public:
 
61
  /** Constructor. 
 
62
   *  \param prj The project information.
 
63
   *  \param size Initial size of the database (not yet used!). */
 
64
  CSemDatabase (CProject &prj, int size = 997);
 
65
  /** Destructor. Destroys all semantic information objects in
 
66
   *  the database. */
 
67
  virtual ~CSemDatabase ();
 
68
 
 
69
  /** Get the number of semantic objects. */
 
70
  unsigned ObjectInfos () const;
 
71
  /** Get the number of semantic objects for classes. */
 
72
  unsigned ClassInfos () const;
 
73
  /** Get the number of semantic objects for unions. */
 
74
  unsigned UnionInfos () const;
 
75
  /** Get the number of semantic objects for enumerations. */
 
76
  unsigned EnumInfos () const;
 
77
  /** Get the number of semantic objects for typedefs. */
 
78
  unsigned TypedefInfos () const;
 
79
  /** Get the number of semantic objects for functions. */
 
80
  unsigned FunctionInfos () const;
 
81
  /** Get the number of semantic objects for translation units (file scope). */
 
82
  unsigned FileInfos () const;
 
83
 
 
84
  /** Get the n-th semantic object.
 
85
   *  \param n The index of the object.
 
86
   *  \return The object or NULL if \e n is invalid. */
 
87
  CObjectInfo *ObjectInfo (unsigned n) const;
 
88
  /** Get the n-th semantic object for classes.
 
89
   *  \param n The index of the object.
 
90
   *  \return The object or NULL if \e n is invalid. */
 
91
  CClassInfo *ClassInfo (unsigned n) const;
 
92
  /** Get the n-th semantic object for unions.
 
93
   *  \param n The index of the object.
 
94
   *  \return The object or NULL if \e n is invalid. */
 
95
  CUnionInfo *UnionInfo (unsigned n) const;
 
96
  /** Get the n-th semantic object for enumerations.
 
97
   *  \param n The index of the object.
 
98
   *  \return The object or NULL if \e n is invalid. */
 
99
  CEnumInfo *EnumInfo (unsigned n) const;
 
100
  /** Get the n-th semantic object for typedefs.
 
101
   *  \param n The index of the object.
 
102
   *  \return The object or NULL if \e n is invalid. */
 
103
  CTypedefInfo *TypedefInfo (unsigned n) const;
 
104
  /** Get the n-th semantic object for functions.
 
105
   *  \param n The index of the object.
 
106
   *  \return The object or NULL if \e n is invalid. */
 
107
  CFunctionInfo *FunctionInfo (unsigned n) const;
 
108
  /** Get the n-th semantic object for translation units (file scope).
 
109
   *  \param n The index of the object.
 
110
   *  \return The object or NULL if \e n is invalid. */
 
111
  CFileInfo *FileInfo (unsigned n) const;
 
112
 
 
113
  /** Get the semantic object for the entity at the given
 
114
   *  source code position (token). 
 
115
   *  \param pos The token of the entity. 
 
116
   *  \return The semantic object or NULL. */
 
117
  CObjectInfo *ObjectInfo (Token *pos) const; 
 
118
  /** Get the semantic object for the entity at the given
 
119
   *  source code position (token). 
 
120
   *  \param pos The token of the entity. 
 
121
   *  \return The semantic object or NULL. */
 
122
  CObjectInfo *ObjectInfo (CT_Token *pos) const; 
 
123
 
 
124
public:
 
125
  /** Insert a new semantic object into the database.
 
126
   *  \param info The semantic object. */
 
127
  void Insert (CObjectInfo *info);
 
128
  /** Remove the given semantic object from the database.
 
129
   *  \param info The semantic object. */
 
130
  void Remove (CObjectInfo *info);
 
131
  /** Get the semantic object for the given built-in operator.
 
132
   *  \param name The operator name/symbol.
 
133
   *  \param tok The operator token type.
 
134
   *  \param rtype The result type of the operator.
 
135
   *  \param t0 Type of the first operand.
 
136
   *  \param t1 Type of the second operand, or NULL if only one operand. */
 
137
  CFunctionInfo *BuiltinOperator (const char *name, int tok, CTypeInfo *rtype, CTypeInfo *t0, CTypeInfo *t1);
 
138
  /** Dump the contents of the database. The dump is indented as
 
139
   *  tree corresponding to the nesting of the semantic objects.
 
140
   *  \param out The output stream.
 
141
   *  \param depth The maximum indentation depth (0 means infinite). */
 
142
  void Dump (ostream &out, int depth = 0) const;
 
143
 
 
144
  /** Get the project information. */
 
145
  CProject *Project () const;
 
146
 
 
147
private:
 
148
  void CreateParameter (CFunctionInfo *fi, CTypeInfo *type) const;
 
149
 
 
150
  void Dump (ostream &, CStructure *, int, int) const;
 
151
  void DumpType (ostream &, CObjectInfo *, int) const;
 
152
  void DumpUsing (ostream &, CUsingInfo *, int) const;
 
153
  void DumpFunction (ostream &, CFunctionInfo *, int, int) const;
 
154
  void DumpAttribute (ostream &, CAttributeInfo *, int) const;
 
155
  void DumpNamespace (ostream &, CNamespaceInfo *, int) const;
 
156
  void DumpQualities (ostream &, CObjectInfo *) const;
 
157
  void DumpScopeName (ostream &, CStructure *) const;
 
158
  void DumpLocalScope (ostream &, CObjectInfo *, int) const;
 
159
  void DumpTemplateParam (ostream &, CTemplateParamInfo *, int) const;
 
160
  void indent (ostream &, int) const;
 
161
};
 
162
 
 
163
inline CSemDatabase::CSemDatabase (CProject &p, int size) :
 
164
  _Project (&p)
 
165
 {}
 
166
 
 
167
inline unsigned CSemDatabase::ObjectInfos () const
 
168
 { return ClassInfos () + UnionInfos () + EnumInfos () + 
 
169
          TypedefInfos () + FunctionInfos () + FileInfos (); }
 
170
inline unsigned CSemDatabase::ClassInfos () const
 
171
 { return _Classes.length (); }
 
172
inline unsigned CSemDatabase::UnionInfos () const
 
173
 { return _Unions.length (); }
 
174
inline unsigned CSemDatabase::EnumInfos () const
 
175
 { return _Enums.length (); }
 
176
inline unsigned CSemDatabase::TypedefInfos () const
 
177
 { return _Typedefs.length (); }
 
178
inline unsigned CSemDatabase::FunctionInfos () const
 
179
 { return _Functions.length (); }
 
180
inline unsigned CSemDatabase::FileInfos () const
 
181
 { return _Files.length (); }
 
182
 
 
183
inline CClassInfo *CSemDatabase::ClassInfo (unsigned i) const
 
184
 { return (CClassInfo*)_Classes.lookup (i); }
 
185
inline CUnionInfo *CSemDatabase::UnionInfo (unsigned i) const
 
186
 { return (CUnionInfo*)_Unions.lookup (i); }
 
187
inline CEnumInfo *CSemDatabase::EnumInfo (unsigned i) const
 
188
 { return (CEnumInfo*)_Enums.lookup (i); }
 
189
inline CTypedefInfo *CSemDatabase::TypedefInfo (unsigned i) const
 
190
 { return (CTypedefInfo*)_Typedefs.lookup (i); }
 
191
inline CFunctionInfo *CSemDatabase::FunctionInfo (unsigned i) const
 
192
 { return (CFunctionInfo*)_Functions.lookup (i); }
 
193
inline CFileInfo *CSemDatabase::FileInfo (unsigned i) const
 
194
 { return (CFileInfo*)_Files.lookup (i); }
 
195
 
 
196
inline CProject *CSemDatabase::Project () const
 
197
 { return _Project; }
 
198
 
 
199
 
 
200
} // namespace Puma
 
201
 
 
202
#endif /* __CSemDatabase_h__ */