1 /* symtab.c Routines to maintain and manipulate a symbol table
3 * The Netwide Assembler is copyright (C) 1996 Simon Tatham and
4 * Julian Hall. All rights reserved. The software is
5 * redistributable under the licence given in the file "Licence"
6 * distributed in the NASM archive.
13 /* TODO: Implement a hash table, not this stupid implementation which
14 is too slow to be of practical use */
16 /* Private data types */
18 typedef struct tagSymtab
{
20 struct tagSymtab
* next
;
23 typedef symtabList
* _symtab
;
27 void *p
= malloc(sizeof(_symtab
));
29 fprintf(stderr
,"symtab: out of memory\n");
37 void symtabDone(void *symtab
)
39 /* DO SOMETHING HERE! */
42 void symtabInsert(void *symtab
,symtabEnt
*ent
)
44 symtabList
*l
= malloc(sizeof(symtabList
));
47 fprintf(stderr
,"symtab: out of memory\n");
52 l
->next
= *(_symtab
*)symtab
;
53 *(_symtab
*)symtab
= l
;
56 symtabEnt
*symtabFind(void *symtab
,char *name
)
58 symtabList
*l
= *(_symtab
*)symtab
;
61 if (!strcmp(l
->ent
.name
,name
)) {
69 void symtabDump(void *symtab
,FILE *of
)
71 symtabList
*l
= *(_symtab
*)symtab
;
74 fprintf(of
,"%32s %s:%08lx (%ld)\n",l
->ent
.name
,
75 l
->ent
.segment
? "data" : "code" ,
76 l
->ent
.offset
, l
->ent
.flags
);