static BASETYPE get_basetype( VARSPACE * v ) { TYPEDEF t ; BASETYPE type = TYPE_UNDEFINED, newtype ; int n ; for ( n = 0 ; n < v->count ; n++ ) { t = v->vars[n].type ; while ( typedef_is_array( t ) ) { t = typedef_reduce( t ) ; } if ( typedef_is_struct( t ) ) { newtype = get_basetype( typedef_members( t ) ) ; } else { newtype = typedef_base( t ) ; } if ( type != TYPE_UNDEFINED && type != newtype ) { return TYPE_UNDEFINED ; } type = newtype ; } return type ; }
void varspace_dump( VARSPACE * n, int indent ) { int i, t, to ; char buffer[128] ; for ( i = 0 ; i < n->count ; i++ ) { if ( i < n->count - 1 ) to = n->vars[i+1].offset - 1 ; else to = n->last_offset - 1 ; printf( "[%04d:%04d]\t", n->vars[i].offset, to ) ; for ( t = 0 ; t < indent ; t++ ) printf( " + " ) ; typedef_describe( buffer, n->vars[i].type ) ; printf( "%s %s", buffer, identifier_name( n->vars[i].code ) ) ; /* Describe arrays of structs */ if ( typedef_is_array( n->vars[i].type ) ) { TYPEDEF r = typedef_reduce( n->vars[i].type ); while ( typedef_is_array( r ) ) r = typedef_reduce( r ); if ( typedef_is_struct( r ) ) { printf( ":\n" ) ; varspace_dump( typedef_members( r ), indent + 1 ) ; } else printf( "\n" ); } /* Describe structs */ else if ( typedef_is_struct( n->vars[i].type ) ) { printf( ":\n" ) ; varspace_dump( typedef_members( n->vars[i].type ), indent + 1 ) ; } else printf( "\n" ) ; } }