annotate lwbasic/symtab.h @ 151:3b58d76ea032

Fix up some minor thinkos in handling the module layout and header
author lost@l-w.ca
date Fri, 26 Aug 2011 23:44:44 -0600
parents 49d608aecc4d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
29
bc96cd02fbf4 Added basic symbol table structure
lost@l-w.ca
parents:
diff changeset
1 /*
bc96cd02fbf4 Added basic symbol table structure
lost@l-w.ca
parents:
diff changeset
2 symtab.h
bc96cd02fbf4 Added basic symbol table structure
lost@l-w.ca
parents:
diff changeset
3
bc96cd02fbf4 Added basic symbol table structure
lost@l-w.ca
parents:
diff changeset
4 Copyright © 2011 William Astle
bc96cd02fbf4 Added basic symbol table structure
lost@l-w.ca
parents:
diff changeset
5
bc96cd02fbf4 Added basic symbol table structure
lost@l-w.ca
parents:
diff changeset
6 This file is part of LWTOOLS.
bc96cd02fbf4 Added basic symbol table structure
lost@l-w.ca
parents:
diff changeset
7
bc96cd02fbf4 Added basic symbol table structure
lost@l-w.ca
parents:
diff changeset
8 LWTOOLS is free software: you can redistribute it and/or modify it under the
bc96cd02fbf4 Added basic symbol table structure
lost@l-w.ca
parents:
diff changeset
9 terms of the GNU General Public License as published by the Free Software
bc96cd02fbf4 Added basic symbol table structure
lost@l-w.ca
parents:
diff changeset
10 Foundation, either version 3 of the License, or (at your option) any later
bc96cd02fbf4 Added basic symbol table structure
lost@l-w.ca
parents:
diff changeset
11 version.
bc96cd02fbf4 Added basic symbol table structure
lost@l-w.ca
parents:
diff changeset
12
bc96cd02fbf4 Added basic symbol table structure
lost@l-w.ca
parents:
diff changeset
13 This program is distributed in the hope that it will be useful, but WITHOUT
bc96cd02fbf4 Added basic symbol table structure
lost@l-w.ca
parents:
diff changeset
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
bc96cd02fbf4 Added basic symbol table structure
lost@l-w.ca
parents:
diff changeset
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
bc96cd02fbf4 Added basic symbol table structure
lost@l-w.ca
parents:
diff changeset
16 more details.
bc96cd02fbf4 Added basic symbol table structure
lost@l-w.ca
parents:
diff changeset
17
bc96cd02fbf4 Added basic symbol table structure
lost@l-w.ca
parents:
diff changeset
18 You should have received a copy of the GNU General Public License along with
bc96cd02fbf4 Added basic symbol table structure
lost@l-w.ca
parents:
diff changeset
19 this program. If not, see <http://www.gnu.org/licenses/>.
bc96cd02fbf4 Added basic symbol table structure
lost@l-w.ca
parents:
diff changeset
20 */
bc96cd02fbf4 Added basic symbol table structure
lost@l-w.ca
parents:
diff changeset
21
bc96cd02fbf4 Added basic symbol table structure
lost@l-w.ca
parents:
diff changeset
22 /*
bc96cd02fbf4 Added basic symbol table structure
lost@l-w.ca
parents:
diff changeset
23 Symbol table handling
bc96cd02fbf4 Added basic symbol table structure
lost@l-w.ca
parents:
diff changeset
24 */
bc96cd02fbf4 Added basic symbol table structure
lost@l-w.ca
parents:
diff changeset
25
bc96cd02fbf4 Added basic symbol table structure
lost@l-w.ca
parents:
diff changeset
26 #ifndef __symtab_h_seen__
bc96cd02fbf4 Added basic symbol table structure
lost@l-w.ca
parents:
diff changeset
27 #define __symtab_h_seen__
bc96cd02fbf4 Added basic symbol table structure
lost@l-w.ca
parents:
diff changeset
28
bc96cd02fbf4 Added basic symbol table structure
lost@l-w.ca
parents:
diff changeset
29 #ifndef __symtab_c_seen__
bc96cd02fbf4 Added basic symbol table structure
lost@l-w.ca
parents:
diff changeset
30 #define __E extern
bc96cd02fbf4 Added basic symbol table structure
lost@l-w.ca
parents:
diff changeset
31 #else
bc96cd02fbf4 Added basic symbol table structure
lost@l-w.ca
parents:
diff changeset
32 #define __E
bc96cd02fbf4 Added basic symbol table structure
lost@l-w.ca
parents:
diff changeset
33 #endif
bc96cd02fbf4 Added basic symbol table structure
lost@l-w.ca
parents:
diff changeset
34
bc96cd02fbf4 Added basic symbol table structure
lost@l-w.ca
parents:
diff changeset
35 /*
bc96cd02fbf4 Added basic symbol table structure
lost@l-w.ca
parents:
diff changeset
36 the meaning of "addr" and "symtype" is defined by the particular context
bc96cd02fbf4 Added basic symbol table structure
lost@l-w.ca
parents:
diff changeset
37 in which the symbol table is used
bc96cd02fbf4 Added basic symbol table structure
lost@l-w.ca
parents:
diff changeset
38 */
bc96cd02fbf4 Added basic symbol table structure
lost@l-w.ca
parents:
diff changeset
39 typedef struct symtab_entry_s symtab_entry_t;
bc96cd02fbf4 Added basic symbol table structure
lost@l-w.ca
parents:
diff changeset
40 struct symtab_entry_s
bc96cd02fbf4 Added basic symbol table structure
lost@l-w.ca
parents:
diff changeset
41 {
bc96cd02fbf4 Added basic symbol table structure
lost@l-w.ca
parents:
diff changeset
42 char *name; /* name of the symbol */
bc96cd02fbf4 Added basic symbol table structure
lost@l-w.ca
parents:
diff changeset
43 int addr; /* address of symbol */
bc96cd02fbf4 Added basic symbol table structure
lost@l-w.ca
parents:
diff changeset
44 int symtype; /* type of symbol */
32
49d608aecc4d Framework for handling local stack frame and/or variables
lost@l-w.ca
parents: 29
diff changeset
45 void *privdata; /* random data associated with symbol */
29
bc96cd02fbf4 Added basic symbol table structure
lost@l-w.ca
parents:
diff changeset
46 symtab_entry_t *next; /* next in the list */
bc96cd02fbf4 Added basic symbol table structure
lost@l-w.ca
parents:
diff changeset
47 };
bc96cd02fbf4 Added basic symbol table structure
lost@l-w.ca
parents:
diff changeset
48
bc96cd02fbf4 Added basic symbol table structure
lost@l-w.ca
parents:
diff changeset
49 typedef struct symtab_s
bc96cd02fbf4 Added basic symbol table structure
lost@l-w.ca
parents:
diff changeset
50 {
bc96cd02fbf4 Added basic symbol table structure
lost@l-w.ca
parents:
diff changeset
51 symtab_entry_t *head;
bc96cd02fbf4 Added basic symbol table structure
lost@l-w.ca
parents:
diff changeset
52 } symtab_t;
bc96cd02fbf4 Added basic symbol table structure
lost@l-w.ca
parents:
diff changeset
53
bc96cd02fbf4 Added basic symbol table structure
lost@l-w.ca
parents:
diff changeset
54 __E symtab_t *symtab_init(void);
bc96cd02fbf4 Added basic symbol table structure
lost@l-w.ca
parents:
diff changeset
55 __E void symtab_destroy(symtab_t *st);
bc96cd02fbf4 Added basic symbol table structure
lost@l-w.ca
parents:
diff changeset
56 __E symtab_entry_t *symtab_find(symtab_t *st, char *name);
32
49d608aecc4d Framework for handling local stack frame and/or variables
lost@l-w.ca
parents: 29
diff changeset
57 __E void symtab_register(symtab_t *st, char *name, int addr, int symtype, void *data);
29
bc96cd02fbf4 Added basic symbol table structure
lost@l-w.ca
parents:
diff changeset
58
bc96cd02fbf4 Added basic symbol table structure
lost@l-w.ca
parents:
diff changeset
59 #undef __E
bc96cd02fbf4 Added basic symbol table structure
lost@l-w.ca
parents:
diff changeset
60
bc96cd02fbf4 Added basic symbol table structure
lost@l-w.ca
parents:
diff changeset
61 #endif /* __symtab_h_seen__ */