17
17
// MA 02111-1307 USA
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"
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);
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);
2908
2910
// let overload resolution know the qualification
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 ();
3381
cout << node->NodeName ()
3382
<< " is no CT_Call node, but builtin operator!" << endl;
3382
SEM_WARNING(node, "internal error, " << node->NodeName () << " is no CT_Call node, but builtin operator");
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");
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);
3397
3397
} // namespace Puma