int Dsymbol::oneMembers(Dsymbols *members, Dsymbol **ps) { //printf("Dsymbol::oneMembers() %d\n", members ? members->dim : 0); Dsymbol *s = NULL; if (members) { for (size_t i = 0; i < members->dim; i++) { Dsymbol *sx = (*members)[i]; int x = sx->oneMember(ps); //printf("\t[%d] kind %s = %d, s = %p\n", i, sx->kind(), x, *ps); if (!x) { //printf("\tfalse 1\n"); assert(*ps == NULL); return FALSE; } if (*ps) { if (s) // more than one symbol { *ps = NULL; //printf("\tfalse 2\n"); return FALSE; } s = *ps; } } } *ps = s; // s is the one symbol, NULL if none //printf("\ttrue\n"); return TRUE; }
bool Dsymbol::oneMembers(Dsymbols *members, Dsymbol **ps, Identifier *ident) { //printf("Dsymbol::oneMembers() %d\n", members ? members->dim : 0); Dsymbol *s = NULL; if (members) { for (size_t i = 0; i < members->dim; i++) { Dsymbol *sx = (*members)[i]; bool x = sx->oneMember(ps, ident); //printf("\t[%d] kind %s = %d, s = %p\n", i, sx->kind(), x, *ps); if (!x) { //printf("\tfalse 1\n"); assert(*ps == NULL); return false; } if (*ps) { assert(ident); if (!(*ps)->ident || !(*ps)->ident->equals(ident)) continue; if (!s) s = *ps; else if (s->isOverloadable() && (*ps)->isOverloadable()) { // keep head of overload set FuncDeclaration *f1 = s->isFuncDeclaration(); FuncDeclaration *f2 = (*ps)->isFuncDeclaration(); if (f1 && f2) { assert(!f1->isFuncAliasDeclaration()); assert(!f2->isFuncAliasDeclaration()); for (; f1 != f2; f1 = f1->overnext0) { if (f1->overnext0 == NULL) { f1->overnext0 = f2; break; } } } } else // more than one symbol { *ps = NULL; //printf("\tfalse 2\n"); return false; } } } } *ps = s; // s is the one symbol, NULL if none //printf("\ttrue\n"); return true; }
int Dsymbol::oneMembers(Dsymbols *members, Dsymbol **ps, Identifier *ident) { //printf("Dsymbol::oneMembers() %d\n", members ? members->dim : 0); Dsymbol *s = NULL; if (members) { for (size_t i = 0; i < members->dim; i++) { Dsymbol *sx = (*members)[i]; int x = sx->oneMember(ps, ident); //printf("\t[%d] kind %s = %d, s = %p\n", i, sx->kind(), x, *ps); if (!x) { //printf("\tfalse 1\n"); assert(*ps == NULL); return FALSE; } if (*ps) { if (ident) { if (!(*ps)->ident || !(*ps)->ident->equals(ident)) continue; } if (!s) s = *ps; else if (s->isOverloadable() && (*ps)->isOverloadable()) ; // keep head of overload set else // more than one symbol { *ps = NULL; //printf("\tfalse 2\n"); return FALSE; } } } } *ps = s; // s is the one symbol, NULL if none //printf("\ttrue\n"); return TRUE; }