sym.c (765B)
1 #include <u.h> 2 #include <errno.h> 3 #include <libc.h> 4 #include <bio.h> 5 #include <mach.h> 6 #include <stabs.h> 7 #include <ctype.h> 8 #include "dat.h" 9 10 Sym *symbols; 11 Sym **lsym; 12 13 void 14 addsymx(char *fn, char *name, Type *type) 15 { 16 Sym *s; 17 18 s = emalloc(sizeof *s); 19 s->fn = fn; 20 s->name = name; 21 s->type = type; 22 if(lsym == nil) 23 lsym = &symbols; 24 *lsym = s; 25 lsym = &s->next; 26 } 27 28 void 29 dumpsyms(Biobuf *b) 30 { 31 Sym *s; 32 Type *t; 33 34 for(s=symbols; s; s=s->next){ 35 t = s->type; 36 t = defer(t); 37 if(t->ty == Pointer){ 38 t = t->sub; 39 if(t && t->equiv) 40 t = t->equiv; 41 } 42 if(t == nil || t->ty != Aggr) 43 continue; 44 Bprint(b, "complex %B %B%s%B;\n", nameof(t, 1), 45 s->fn ? fixname(s->fn) : "", s->fn ? ":" : "", fixname(s->name)); 46 } 47 48 symbols = nil; 49 lsym = &symbols; 50 }