~ubuntu-branches/ubuntu/maverick/aspectc++/maverick

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Reinhard Tartler
  • Date: 2008-04-10 17:40:52 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20080410174052-xdnsm7oi8hauyyf1
Tags: 1.0pre4~svn.20080409+dfsg-3
Fix another missing include, this time in Ag++/StdSystem.cc

Show diffs side-by-side

added added

removed removed

Lines of Context:
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)
 
55
    delete iter->second;
52
56
}
53
57
 
54
58
void CClassDatabase::Insert (CObjectInfo *info) {
101
105
  } else 
102
106
    return; // Unknown!
103
107
}
104
 
  
 
108
 
 
109
CFunctionInfo *CClassDatabase::BuiltinOperator (const char *name, int tok,
 
110
  CTypeInfo *rtype, CTypeInfo *t0, CTypeInfo *t1) {
 
111
  CFunctionInfo *info;
 
112
  CTypeList *args;
 
113
  CTypeInfo *type;
 
114
    
 
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) {
 
121
    info = iter->second;
 
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
 
132
      }
 
133
    }
 
134
  }
 
135
  
 
136
  // the operator object has to be created ...
 
137
    // return type
 
138
  if (! rtype)
 
139
    rtype = &CTYPE_UNDEFINED;
 
140
 
 
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);
 
145
  
 
146
  // operator function type
 
147
  type = new CTypeFunction (rtype, args, true);
 
148
 
 
149
  // operator function
 
150
  info = new CFunctionInfo;
 
151
  info->Name (name);
 
152
  info->isOperator (true);
 
153
  info->ObjectInfo ()->TypeInfo (type);
 
154
  type->VirtualType ()->TypeFunction ()->FunctionInfo (info);
 
155
 
 
156
  // create function parameters
 
157
  if (t0) CreateParameter (info, t0);
 
158
  if (t1) CreateParameter (info, t1);
 
159
  
 
160
  // insert the object as a regular object into the class database
 
161
  Insert (info);
 
162
  
 
163
  // insert the object into the map
 
164
  _builtin_ops.insert (multimap<int,CFunctionInfo*>::value_type (tok, info));
 
165
  
 
166
  return info;
 
167
}
 
168
 
 
169
void CClassDatabase::CreateParameter (CFunctionInfo *fi, CTypeInfo *type) const {
 
170
  CArgumentInfo *info;
 
171
  info = fi->newArgument ();
 
172
  info->Name ("<noname>");
 
173
  info->Storage (CStorage::CLASS_AUTOMATIC);
 
174
  info->TypeInfo (type->Duplicate ());
 
175
}
 
176
 
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);
 
414
    out << ") ";
 
415
  } else if (info->TypedefInfo ()) {
340
416
    out << " (type: ";
341
417
    info->TypeInfo ()->TypeText (out);
342
418
    out << ") ";