49
49
CClassDatabase::~CClassDatabase () {
50
50
for (int i = 0; i < _Files.length (); i++)
51
51
delete (CFileInfo*)_Files[i];
52
// delete functions infos of built-in operators
53
multimap<int,CFunctionInfo*>::iterator iter;
54
for (iter = _builtin_ops.begin (); iter != _builtin_ops.end (); ++iter)
54
58
void CClassDatabase::Insert (CObjectInfo *info) {
102
106
return; // Unknown!
109
CFunctionInfo *CClassDatabase::BuiltinOperator (const char *name, int tok,
110
CTypeInfo *rtype, CTypeInfo *t0, CTypeInfo *t1) {
115
// first check if this built-in operator already exists ...
116
multimap<int,CFunctionInfo*>::iterator iter, lower, upper;
117
lower = _builtin_ops.lower_bound (tok);
118
upper = _builtin_ops.upper_bound (tok);
119
// check all exisiting operators with the right token type
120
for (iter = lower; iter != upper; ++iter) {
122
args = info->TypeInfo ()->ArgTypes ();
123
// same number of arguments?
124
if (args->Entries () == (unsigned)((t0?1:0) + (t1?1:0))) {
125
// same parameter type list
126
if ((t0 ? *t0 == *args->Entry (0) : true) &&
127
(t1 ? *t1 == *args->Entry (1) : true)) {
128
if (t0) CTypeInfo::Destroy (t0);
129
if (t1) CTypeInfo::Destroy (t1);
130
if (rtype) CTypeInfo::Destroy (rtype);
131
return info; // operator already exists
136
// the operator object has to be created ...
139
rtype = &CTYPE_UNDEFINED;
141
// parameter type list
142
args = new CTypeList ((t0?1:0)+(t1?1:0));
143
if (t0) args->AddEntry (t0);
144
if (t1) args->AddEntry (t1);
146
// operator function type
147
type = new CTypeFunction (rtype, args, true);
150
info = new CFunctionInfo;
152
info->isOperator (true);
153
info->ObjectInfo ()->TypeInfo (type);
154
type->VirtualType ()->TypeFunction ()->FunctionInfo (info);
156
// create function parameters
157
if (t0) CreateParameter (info, t0);
158
if (t1) CreateParameter (info, t1);
160
// insert the object as a regular object into the class database
163
// insert the object into the map
164
_builtin_ops.insert (multimap<int,CFunctionInfo*>::value_type (tok, info));
169
void CClassDatabase::CreateParameter (CFunctionInfo *fi, CTypeInfo *type) const {
171
info = fi->newArgument ();
172
info->Name ("<noname>");
173
info->Storage (CStorage::CLASS_AUTOMATIC);
174
info->TypeInfo (type->Duplicate ());
105
177
CObjectInfo *CClassDatabase::ObjectInfo (Token *token) const {
106
178
unsigned infos = ObjectInfos ();
107
179
for (unsigned i = 0; i < infos; i++) {
336
408
else if (info->ClassInfo ())
337
409
out << (info->ClassInfo ()->isStruct () ? "struct " : "class ");
338
410
out << ": " << info->Name () << "\t";
339
if (info->TypedefInfo ()) {
411
if (info->EnumInfo ()) {
412
out << " (underlying type: ";
413
info->EnumInfo ()->TypeInfo ()->UnderlyingType ()->TypeText (out);
415
} else if (info->TypedefInfo ()) {
340
416
out << " (type: ";
341
417
info->TypeInfo ()->TypeText (out);