parse/type.c
/*
 * Checks if a type contains any type
 * parameers at all (ie, if it generic).
 */
Checks if a type contains any type
parameers at all .
Checks if a type contains any type parameers at all .
int hasparamsrec(Type *t, Bitset *visited)
{
    size_t i;
    if (bshas(visited, t->tid))
        return 0;
    bsput(visited, t->tid);
    switch (t->type) {
        case Typaram:
        case Tygeneric:
            return 1;
        case Tyname:
            for (i = 0; i < t->narg; i++)
                if (hasparamsrec(t->arg[i], visited))
                    return 1;
            return hasparamsrec(t->sub[0], visited);
        case Tyunres:
            for (i = 0; i < t->narg; i++)
                if (hasparamsrec(t->arg[i], visited))
                    return 1;
            break;
        case Tystruct:
            for (i = 0; i < t->nmemb; i++)
                if (hasparamsrec(t->sdecls[i]->decl.type, visited))
                    return 1;
            break;
        case Tyunion:
            for (i = 0; i < t->nmemb; i++)
                if (t->udecls[i]->etype && hasparamsrec(t->udecls[i]->etype, visited))
                    return 1;
            break;
        default:
            for (i = 0; i < t->nsub; i++)
                if (hasparamsrec(t->sub[i], visited))
                    return 1;
            break;
    }
    return 0;
}
int hasparamsrec ( Type * t , Bitset * visited ) { size_t i ; if ( bshas ( visited , t -> tid ) ) return 0 ; bsput ( visited , t -> tid ) ; switch ( t -> type ) { case Typaram : case Tygeneric : return 1 ; case Tyname : for ( i = 0 ; i < t -> narg ; i ++ ) if ( hasparamsrec ( t -> arg [ i ] , visited ) ) return 1 ; return hasparamsrec ( t -> sub [ 0 ] , visited ) ; case Tyunres : for ( i = 0 ; i < t -> narg ; i ++ ) if ( hasparamsrec ( t -> arg [ i ] , visited ) ) return 1 ; break ; case Tystruct : for ( i = 0 ; i < t -> nmemb ; i ++ ) if ( hasparamsrec ( t -> sdecls [ i ] -> decl . type , visited ) ) return 1 ; break ; case Tyunion : for ( i = 0 ; i < t -> nmemb ; i ++ ) if ( t -> udecls [ i ] -> etype && hasparamsrec ( t -> udecls [ i ] -> etype , visited ) ) return 1 ; break ; default : for ( i = 0 ; i < t -> nsub ; i ++ ) if ( hasparamsrec ( t -> sub [ i ] , visited ) ) return 1 ; break ; } return 0 ; }
Checks if a type contains any type
 parameers at all (ie, if it generic).
Checks if a type contains any type parameers at all ( ie if it generic ) .