int StructTypeDecl::findIndex(const char* name_) const { for (unsigned i=0; i<numMembers(); i++) { Decl* D = members[i]; if (strcmp(D->getName(), name_) == 0) return i; } return -1; }
const C2::Decl* C2Sema::findUse(const char* name) const { for (unsigned int i=0; i<ast.getNumDecls(); i++) { Decl* d = ast.getDecl(i); if (d->getName() == name) return d; } return 0; }
Decl* StructTypeDecl::find(const char* name_) const { // normal members for (unsigned i=0; i<numMembers(); i++) { Decl* D = members[i]; if (strcmp(D->getName(), name_) == 0) return D; if (D->hasEmptyName()) { // empty string assert(isa<StructTypeDecl>(D)); StructTypeDecl* sub = cast<StructTypeDecl>(D); D = sub->find(name_); if (D) return D; } } return findFunction(name_); }
ScopeResult Scope::findSymbol(const std::string& symbol) const { // search this scope ScopeResult result; for (DeclsConstIter iter = decls.begin(); iter != decls.end(); ++iter) { Decl* D = *iter; if (D->getName() == symbol) { result.decl = D; // TODO fill other result fields return result; } } // search parent or globals if (parent) return parent->findSymbol(symbol); else return globals->findSymbol(symbol); }