aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/acidtypes/sym.c
blob: 9aaaa487ce620f152682bd62c4aa8765f647d26d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <u.h>
#include <errno.h>
#include <libc.h>
#include <bio.h>
#include <mach.h>
#include <stabs.h>
#include <ctype.h>
#include "dat.h"

Sym *symbols;
Sym **lsym;

void
addsymx(char *fn, char *name, Type *type)
{
	Sym *s;

	s = emalloc(sizeof *s);
	s->fn = fn;
	s->name = name;
	s->type = type;
	if(lsym == nil)
		lsym = &symbols;
	*lsym = s;
	lsym = &s->next;
}

void
dumpsyms(Biobuf *b)
{
	Sym *s;
	Type *t;

	for(s=symbols; s; s=s->next){
		t = s->type;
		t = defer(t);
		if(t->ty == Pointer){
			t = t->sub;
			if(t && t->equiv)
				t = t->equiv;
		}
		if(t == nil || t->ty != Aggr)
			continue;
		Bprint(b, "complex %B %B%s%B;\n", nameof(t, 1),
			s->fn ? fixname(s->fn) : "", s->fn ? ":" : "", fixname(s->name));
	}

	symbols = nil;
	lsym = &symbols;
}