AST_Type * be_typedef::_astBase(AST_Type * ttype) { AST_Type * ret = ttype; if (ret) { AST_Typedef * atd; while ((atd = (AST_Typedef*)ret->narrow((long) & AST_Typedef::type_id))) { ret = atd->base_type(); } } return ret; }
/* * Helper function for lookup_by_name. Iterates doing local lookups of * subsequent components of a scoped name */ static AST_Decl * iter_lookup_by_name_local(AST_Decl *d, UTL_ScopedName *e, idl_bool treat_as_ref) { Identifier *s; AST_Typedef *td; UTL_IdListActiveIterator *i; UTL_Scope *sc; i = new UTL_IdListActiveIterator(e); for (i->next(); !(i->is_done()); ) { s = i->item(); /* * Update iterator before loop. This is needed for the check for * typedef, since we only want to look at the base type if there * actually are more components of the name to resolve. */ i->next(); /* * Next component in name was not found */ if (d == NULL) { return NULL; } /* * If this is a typedef and we're not done, we should get the * base type to get the scope it defines (if any) */ if (!(i->is_done())) { while (d != NULL && d->node_type() == AST_Decl::NT_typedef) { td = AST_Typedef::narrow_from_decl(d); if (td == NULL) return NULL; d = td->base_type(); } if (d == NULL) return NULL; } /* * Try to convert the AST_Decl to a UTL_Scope */ sc = DeclAsScope(d); if (sc == NULL) return NULL; /* * Look up the next element */ d = sc->lookup_by_name_local (s); } /* * OK, done with the loop */ return d; }