3 static unsigned dotc_stream
;
5 static inline char storage(struct symbol
*sym
)
8 unsigned m
= sym
->ctype
.modifiers
;
10 if (m
& MOD_INLINE
|| t
== SYM_STRUCT
|| t
== SYM_UNION
/*|| t == SYM_ENUM*/)
11 return sym
->pos
.stream
== dotc_stream
? 's' : 'g';
13 return (m
& MOD_STATIC
) ? 's' : (m
& MOD_NONLOCAL
) ? 'g' : 'l';
16 static inline const char *show_mode(unsigned mode
)
23 #define U(u_r) "-rwm"[(mode / u_r) & 3]
32 static void print_usage(struct position
*pos
, struct symbol
*sym
, unsigned mode
)
34 static unsigned curr_stream
= -1;
36 if (curr_stream
!= pos
->stream
) {
37 curr_stream
= pos
->stream
;
38 printf("\nFILE: %s\n\n", stream_name(curr_stream
));
41 printf("%4d:%-3d %c %-5.3s",
42 pos
->line
, pos
->pos
, storage(sym
), show_mode(mode
));
45 static void r_symbol(unsigned mode
, struct position
*pos
, struct symbol
*sym
)
47 print_usage(pos
, sym
, mode
);
50 sym
->ident
= MK_IDENT("__asm__");
52 printf("%-32.*s %s\n",
53 sym
->ident
->len
, sym
->ident
->name
,
54 show_typename(sym
->ctype
.base_type
));
57 static void r_member(unsigned mode
, struct position
*pos
, struct symbol
*sym
, struct symbol
*mem
)
59 struct ident
*ni
, *si
, *mi
;
61 print_usage(pos
, sym
, mode
);
64 si
= sym
->ident
?: ni
;
65 /* mem == NULL means entire struct accessed */
66 mi
= mem
? (mem
->ident
?: ni
) : MK_IDENT("*");
68 printf("%.*s.%-*.*s %s\n",
70 32-1 - si
->len
, mi
->len
, mi
->name
,
71 show_typename(mem
? mem
->ctype
.base_type
: sym
));
74 static void r_symdef(struct symbol
*sym
)
76 r_symbol(-1, &sym
->pos
, sym
);
79 int main(int argc
, char **argv
)
81 static struct reporter reporter
= {
86 struct string_list
*filelist
= NULL
;
89 sparse_initialize(argc
, argv
, &filelist
);
91 FOR_EACH_PTR_NOTAG(filelist
, file
) {
92 dotc_stream
= input_stream_nr
;
93 dissect(__sparse(file
), &reporter
);
94 } END_FOR_EACH_PTR_NOTAG(file
);