示例#1
0
/*******************
 compareOrigTypes

 Specialized function to catch if two enumerations, two selects, or two aggrs
 of either, are of the same type.  The issue is that e.g. select B may be a
 rename of sel A (i.e., TYPE B = A;).  Such renamed types are implemented by
 fedex_plus with typedefs, so that they are in fact the same type.  TYPEget_-
 ctype() is used for most type comparisons and does not consider renamed types
 equivalent.  This function is called in instances when they should be consi-
 dered equivalent.  One such case is the generation of duplicate lists.
 *******************/
static int
compareOrigTypes( Type a, Type b ) {
    Type t, u;

    if( ( TYPEis_select( a ) && TYPEis_select( b ) )
            || ( TYPEis_enumeration( a ) && TYPEis_enumeration( b ) ) ) {
        t = a;
        u = b;
    } else if( TYPEis_aggregate( a ) && TYPEis_aggregate( b ) ) {
        t = TYPEget_base_type( a );
        u = TYPEget_base_type( b );
        if( !( ( TYPEis_select( t ) && TYPEis_select( u ) )
                || ( TYPEis_enumeration( t ) && TYPEis_enumeration( u ) ) ) ) {
            return FALSE;
            /* Only go further with 1D aggregates of sels or enums.  Note that
            // for 2D aggrs and higher we do not continue.  These are all recog-
            // nized to be the same type ("GenericAggregate") by TYPEget_ctype(),
            // and do not have to be handled specially here. */
        }
    } else {
        return FALSE;
    }

    if( TYPEget_head( t ) ) {
        t = TYPEget_ancestor( t );
    }
    if( TYPEget_head( u ) ) {
        u = TYPEget_ancestor( u );
    }
    return ( !strcmp( TYPEget_name( t ), TYPEget_name( u ) ) );
}
示例#2
0
const char *
AccessType( Type t ) {
    Class_Of_Type class;
    static char nm [BUFSIZ];
    strncpy( nm, TypeName( t ), BUFSIZ - 4 );
    if( TYPEis_entity( t ) ) {
        strcat( nm, "_ptr" );
        return nm;
    } else if( TYPEis_select( t ) || TYPEis_aggregate( t ) ) {
        strcat( nm, "_ptr" );
        return nm;
    }
    class = TYPEget_type( t );
    if( class == enumeration_ ) {
        strncpy( nm, TypeName( t ), BUFSIZ - 2 );
        strcat( nm, "_var" );
        return nm;
    }
    if( class == logical_ ) {
        strncpy( nm, "Logical", BUFSIZ - 2 );
    }

    /*    case TYPE_BOOLEAN:    */
    if( class == boolean_ ) {
        strncpy( nm, "Boolean", BUFSIZ - 2 );
    }
    return nm;
}