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

« back to all changes in this revision

Viewing changes to Puma/src/parser/ccparser/CCSemExpr.cc

  • 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:
17
17
// MA  02111-1307  USA                                            
18
18
 
19
19
#include "Puma/CTree.h"
20
 
#include "Puma/CClassDatabase.h"
 
20
#include "Puma/CSemDatabase.h"
21
21
#include "Puma/CFileInfo.h"
22
22
#include "Puma/CCSemExpr.h"
23
23
#include "Puma/CStructure.h"
50
50
#include <ctype.h>         /* isdigit(); isxdigit() */
51
51
#include <stdio.h>         /* sprintf() */
52
52
#include <string.h>
 
53
 
53
54
using namespace std;
54
55
 
55
56
namespace Puma {
278
279
      id == CT_UnaryExpr::NodeId ()) {
279
280
    return findObject (node->Son (1));
280
281
  } else if (id == CT_ImplicitCast::NodeId () ||
281
 
             id == CT_PostfixExpr::NodeId ()) {
 
282
             id == CT_PostfixExpr::NodeId () ||
 
283
             id == CT_IndexExpr::NodeId ()) {
282
284
    return findObject (node->Son (0));
283
285
  } else if (id == CT_CastExpr::NodeId ()) {
284
286
    return findObject (node->Son (3));
2272
2274
  bool found_type_info = false;
2273
2275
  CCNameLookup nl (err);
2274
2276
  // search namespace std
2275
 
  nl.lookupNamespace ("std", current_scope->ClassDB ()->FileInfo (0));
 
2277
  nl.lookupNamespace ("std", current_scope->SemDB ()->FileInfo (0));
2276
2278
  if (nl.Objects () == 1) {
2277
2279
    CNamespaceInfo *std = (CNamespaceInfo*)nl.Object (0);
2278
2280
    nl.reset ();
2902
2904
  }
2903
2905
 
2904
2906
  // create and add built-in candidates
2905
 
  CClassDatabase *db = current_scope->ClassDB ();
 
2907
  CSemDatabase *db = current_scope->SemDB ();
2906
2908
  ovl.createBuiltinOperators (db, opname, oper, arg0, arg1);
2907
2909
 
2908
2910
  // let overload resolution know the qualification
3211
3213
 const char *name, CCOverloading &ovl) {
3212
3214
  CTemplateInstance *inst;
3213
3215
  CObjectInfo *info;
3214
 
  CTree *arg;
 
3216
  CTree *arg = 0;
3215
3217
 
3216
3218
  // more than one candidate left
3217
3219
  if (ovl.isAmbiguous () && ! ovl.isDependent ()) {
3257
3259
          sig << " = ";
3258
3260
          if (darg->Type ())
3259
3261
            darg->Type ()->TypeText (sig);
3260
 
          else if (arg->Value ())
 
3262
          else if (arg && arg->Value ())
3261
3263
            darg->Value ()->print (sig);
3262
3264
        }
3263
3265
        sig << "]";
3373
3375
 
3374
3376
// transform the expression into a call expression with a built-in operator
3375
3377
// as the target function
3376
 
void CCSemExpr::builtinOpExpr (CTree *node, CTree *base,
3377
 
  const char *op, int oper, CTypeInfo *result,
 
3378
void CCSemExpr::builtinOpExpr (CTree *node, CTree *base, const char *op, int oper, CTypeInfo *result,
3378
3379
  CTypeInfo *t1, CTypeInfo *t2) const {
3379
3380
  CT_Call *call = node->IsCall ();
3380
 
  if (!call) {
3381
 
    cout << node->NodeName ()
3382
 
         << " is no CT_Call node, but builtin operator!" << endl;
 
3381
  if (! call) {
 
3382
    SEM_WARNING(node, "internal error, " << node->NodeName () << " is no CT_Call node, but builtin operator");
3383
3383
  }
3384
 
  else if (result == &CTYPE_UNDEFINED || t1 == &CTYPE_UNDEFINED ||
3385
 
    t2 == &CTYPE_UNDEFINED) {
3386
 
    cout << "undefined type: " << node->token ()->location () << endl;
 
3384
  else if (result == &CTYPE_UNDEFINED || t1 == &CTYPE_UNDEFINED || t2 == &CTYPE_UNDEFINED) {
 
3385
    SEM_ERROR(node, "undefined type");
3387
3386
  }
3388
3387
  else {
3389
3388
    char name[1000];
3390
3389
    sprintf (name, "operator %s", op);
3391
 
    CFunctionInfo *fi = current_scope->ClassDB ()->BuiltinOperator (name, oper,
 
3390
    CFunctionInfo *fi = current_scope->SemDB ()->BuiltinOperator (name, oper,
3392
3391
      result->Duplicate (), t1->Duplicate (), t2 ? t2->Duplicate () : 0);
3393
3392
    call->Object (fi);
3394
3393
  }
3395
3394
}
3396
3395
 
 
3396
 
3397
3397
} // namespace Puma