~ubuntu-branches/ubuntu/quantal/aspectc++/quantal

« back to all changes in this revision

Viewing changes to Puma/src/infos/CTypeInfo.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:
39
39
#include "Puma/CTree.h"
40
40
#include <iostream>
41
41
#include <sstream>
 
42
#include <string.h>
42
43
using namespace std;
43
44
 
44
45
namespace Puma {
76
77
CTypeInfo *CTypeInfo::CTYPE_SIZE_T = &CTYPE_UNSIGNED_INT;  // default type
77
78
CTypeInfo *CTypeInfo::CTYPE_PTRDIFF_T = &CTYPE_INT;        // default type
78
79
 
 
80
bool CTypeInfo::equalTemplateParams (CTemplateParamInfo *p1, CTemplateParamInfo *p2) const {
 
81
  if (p1->isTemplate () != p2->isTemplate ())
 
82
    return false;
 
83
  if (p1->isTypeParam () != p2->isTypeParam ())
 
84
    return false;
 
85
  if (p1->ValueType () && p2->ValueType () && *p1->ValueType () != *p2->ValueType ())
 
86
    return false;
 
87
    
 
88
  if (p1->isTemplate ()) {
 
89
    CTemplateInfo *t1 = p1->TemplateTemplate ();
 
90
    CTemplateInfo *t2 = p1->TemplateTemplate ();
 
91
    if (! t1 || ! t2 || (t1->Parameters () != t2->Parameters ()))
 
92
      return false;
 
93
    for (unsigned i = 0; i < t1->Parameters (); i++) {
 
94
      p1 = t1->Parameter (i);
 
95
      p2 = t2->Parameter (i);
 
96
      if (*p1->TypeInfo () != *p2->TypeInfo ())
 
97
        return false;
 
98
    }
 
99
  }
 
100
  return true;
 
101
}
 
102
 
79
103
bool CTypeInfo::operator ==(const CTypeInfo &type) const {
80
104
  if (! (_Id == type._Id)) {
81
105
    return false;
84
108
  } else if (TypeTemplateParam ()) {
85
109
    CTemplateParamInfo *p1 = TypeTemplateParam ()->TemplateParamInfo ();
86
110
    CTemplateParamInfo *p2 = type.TypeTemplateParam ()->TemplateParamInfo ();
87
 
    if (p1 && p2 &&
88
 
        (p1->isTemplate () ? p2->isTemplate () :
89
 
         p1->isTypeParam () ? p2->isTypeParam () && ! p2->isTemplate () :
90
 
         ! p1->isTypeParam () && ! p2->isTypeParam ()))
91
 
      return true;
92
 
    return false;
93
 
//    if (*TypeTemplateParam ()->TemplateParamInfo () != 
94
 
//        *type.TypeTemplateParam ()->TemplateParamInfo ())
95
 
//      return false;
96
 
//    return true;
 
111
    return (p1 && p2 && equalTemplateParams (p1, p2));
97
112
  } else if (TypeClass ()) {
98
113
    CClassInfo *c1 = TypeClass ()->ClassInfo ();
99
114
    CClassInfo *c2 = type.TypeClass ()->ClassInfo ();
182
197
// check if a typedef is defined in a generated template argument scope
183
198
bool isInTemplateArgScope (CObjectInfo *obj) {
184
199
  bool result = (obj->Scope ()->isNamespace () &&
185
 
    obj->Scope ()->isAnonymous () && strstr (obj->Scope ()->Name (), "<"));
 
200
    ((obj->Scope ()->isAnonymous () && strstr (obj->Scope ()->Name (), "<")) ||
 
201
    strstr (obj->Scope ()->Name (), "__puma_")));
186
202
  return result;
187
203
}
188
204
    
210
226
      qualifiers << "volatile";
211
227
    if (BaseType ()->TypePointer () || BaseType ()->TypeAddress ()) {
212
228
      if (t) qualifiers << " " << t;
213
 
      qualifiers << std::ends;
214
229
      BaseType ()->TypeText (state, out, qualifiers.str ().c_str ());
215
230
    }
216
231
    else {
217
 
      qualifiers << std::ends;
218
232
      out << qualifiers.str ().c_str () << " ";
219
233
      BaseType ()->TypeText (state, out, t);
220
234
    }
224
238
    std::ostringstream inner;
225
239
    if (TypeMemberPointer ()) {
226
240
      if (TypeMemberPointer ()->Record ()) {
227
 
        //        inner << " ";
228
 
        printScope (state, inner, TypeMemberPointer ()->Record ());
229
 
        printName (state, inner, TypeMemberPointer ()->Record ());
230
 
        inner << "::*";
 
241
        CTypeFunction *fctptr = BaseType ()->TypeFunction ();
 
242
        if (!fctptr || !fctptr->Record () || !fctptr->FunctionInfo () ||
 
243
             fctptr->FunctionInfo ()->isStaticMethod ()) {
 
244
          printScope (state, inner, TypeMemberPointer ()->Record ());
 
245
          printName (state, inner, TypeMemberPointer ()->Record ());
 
246
          inner << "::*";
 
247
        } else
 
248
          inner << "*";
231
249
      } else 
232
250
        inner << " <null>::*";
233
251
    } else if (TypePointer ()) inner << "*";
234
252
    else if (TypeAddress ()) inner << "&";
235
253
    if (t) inner << " " << t;
236
 
    inner << std::ends;
237
254
    BaseType ()->TypeText (state | PRINT_PRE, out, inner.str ().c_str ());
238
255
    return;
239
256
  } else if (TypeFunction ()) {
262
279
      name_and_args << " const";
263
280
    if (this_type->isVolatile ())
264
281
      name_and_args << " volatile";
265
 
    name_and_args << std::ends;
266
282
 
267
283
    // now write the generated embedded into its base type    
268
284
    if (BaseType ()->is_undefined ())
285
301
    else if (Dimension ())
286
302
      name_and_dim << Dimension ();
287
303
    name_and_dim << "]";
288
 
    name_and_dim << std::ends;
289
304
    BaseType ()->TypeText (state, out, name_and_dim.str ().c_str ());
290
305
    return;
291
306
  } else if (TypeClass ()) {
292
307
    // print CLASSES
 
308
    if (state & PRINT_ELA) {
 
309
      CRecord* record = TypeClass ()->Record ();
 
310
      if (record && record->ClassInfo ()->isStruct ()) {
 
311
        out << "struct ";
 
312
      } else {
 
313
        out << "class ";
 
314
      }
 
315
    }
293
316
    printScope (state, out, TypeClass ()->Record ());
294
317
    printName (state, out, TypeClass ()->Record ());
295
318
  } else if (TypeUnion ()) {
296
319
    // print UNIONS
 
320
    if (state & PRINT_ELA) {
 
321
      out << "union ";
 
322
    }
297
323
    printScope (state, out, TypeUnion ()->Record ());
298
324
    printName (state, out, TypeUnion ()->Record ());
299
325
  } else if (TypeEnum ()) {
300
326
    // print ENUMS
 
327
    if (state & PRINT_ELA) {
 
328
      out << "enum ";
 
329
    }
301
330
    printScope (state, out, TypeEnum ()->EnumInfo ());
302
331
    printName (state, out, TypeEnum ()->EnumInfo ());
303
332
  } else if (TypeTemplateParam ()) {
319
348
      info = tpl->ObjectInfo ();
320
349
    }
321
350
  }
322
 
  CScopeInfo *scope = info->Scope ();
 
351
  CScopeInfo *scope = info->QualifiedScope ();
 
352
  if (! scope) scope = info->AssignedScope ();
 
353
  if (! scope) scope = info->Scope ();
323
354
  while (scope && scope->TemplateInfo ()) {
324
355
    scope = scope->Parent ();
325
356
  }
437
468
    copy = new CTypeArray (base, (CTypeQualified*)copy);
438
469
    copy->TypeArray ()->Dimension (type->Dimension ());
439
470
    copy->TypeArray ()->DepDim (type->TypeArray ()->DepDim ());
 
471
    copy->TypeArray ()->hasDimension (type->TypeArray ()->hasDimension ());
440
472
  } else if (type->TypeQualified ()) {
441
473
    copy = new CTypeQualified (base, type->isConst (), type->isVolatile (),
442
474
                                     type->isRestrict ());
594
626
// complete type (at this source position)?
595
627
bool CTypeInfo::isComplete (unsigned long pos) const {
596
628
  if (isUndefined () || isVoid () ||
597
 
      (isArray () && ! isVarArray () && ! VirtualType()->Dimension ()) || 
 
629
      (isArray () && ! isVarArray () && ! VirtualType ()->TypeArray ()->hasDimension ()) || 
598
630
      (isRecord () && ! VirtualType ()->TypeRecord ()->isComplete (pos)) ||
599
631
      (isEnum () && ! VirtualType ()->TypeEnum ()->isComplete (pos))) 
600
632
    return false;
746
778
  // HACK? Needed for template template parameters
747
779
  //if (isTemplate ())
748
780
  //  return true;
749
 
  if (TypeClass () && TypeClass ()->ClassInfo () && 
750
 
      TypeClass ()->ClassInfo ()->hasDepBaseClass ())
 
781
  if (TypeClass () && 
 
782
      TypeClass ()->ClassInfo () && 
 
783
      TypeClass ()->ClassInfo ()->hasDepBaseClass () &&
 
784
      ! TypeClass ()->ClassInfo ()->isTemplate ())
751
785
    return true;
752
786
  return BaseType () && this != BaseType () && 
753
787
         BaseType ()->isDependent (consider_unknown_t);
929
963
  return _Class ? _Class->TemplateParamInfo () : (CTemplateParamInfo*)0; 
930
964
}
931
965
 
 
966
CTypeInfo *CTypeEnum::UnderlyingType () const { 
 
967
  return _Enum ? _Enum->UnderlyingType() : &CTYPE_INT; 
 
968
}
 
969
 
932
970
 
933
971
} // namespace Puma