Mercurial > hg > index.cgi
annotate lwbasic/attic/symtab.c @ 262:7de7b14ebaee
Add support for os9 module edition byte
Add support for the symbol "edition" in the __os9 section which defines the
module edition byte which follows immedately after the module name in the
module. It defaults to not setting one.
author | William Astle <lost@l-w.ca> |
---|---|
date | Mon, 04 Feb 2013 21:03:59 -0700 |
parents | cca933d32298 |
children |
rev | line source |
---|---|
29 | 1 /* |
2 symtab.c | |
3 | |
4 Copyright © 2011 William Astle | |
5 | |
6 This file is part of LWTOOLS. | |
7 | |
8 LWTOOLS is free software: you can redistribute it and/or modify it under the | |
9 terms of the GNU General Public License as published by the Free Software | |
10 Foundation, either version 3 of the License, or (at your option) any later | |
11 version. | |
12 | |
13 This program is distributed in the hope that it will be useful, but WITHOUT | |
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | |
16 more details. | |
17 | |
18 You should have received a copy of the GNU General Public License along with | |
19 this program. If not, see <http://www.gnu.org/licenses/>. | |
20 */ | |
21 | |
22 /* | |
23 Symbol table handling | |
24 */ | |
25 | |
26 #include <stdlib.h> | |
27 #include <string.h> | |
28 | |
29 #include <lw_alloc.h> | |
30 #include <lw_string.h> | |
31 | |
32 #define __symtab_c_seen__ | |
33 #include "symtab.h" | |
34 | |
35 symtab_t *symtab_init(void) | |
36 { | |
37 symtab_t *st; | |
38 | |
39 st = lw_alloc(sizeof(symtab_t)); | |
40 st -> head = NULL; | |
41 return st; | |
42 } | |
43 | |
44 void symtab_destroy(symtab_t *st) | |
45 { | |
46 symtab_entry_t *se; | |
47 | |
48 while (st -> head) | |
49 { | |
50 se = st -> head; | |
51 st -> head = se -> next; | |
52 lw_free(se -> name); | |
32
49d608aecc4d
Framework for handling local stack frame and/or variables
lost@l-w.ca
parents:
29
diff
changeset
|
53 lw_free(se -> privdata); |
29 | 54 lw_free(se); |
55 } | |
56 lw_free(st); | |
57 } | |
58 | |
59 symtab_entry_t *symtab_find(symtab_t *st, char *name) | |
60 { | |
61 symtab_entry_t *se; | |
62 | |
63 for (se = st -> head; se; se = se -> next) | |
64 { | |
65 if (strcmp(se -> name, name) == 0) | |
66 return se; | |
67 } | |
68 return NULL; | |
69 } | |
70 | |
32
49d608aecc4d
Framework for handling local stack frame and/or variables
lost@l-w.ca
parents:
29
diff
changeset
|
71 void symtab_register(symtab_t *st, char *name, int addr, int symtype, void *privdata) |
29 | 72 { |
73 symtab_entry_t *se; | |
74 | |
75 se = lw_alloc(sizeof(symtab_entry_t)); | |
76 se -> name = lw_strdup(name); | |
77 se -> addr = addr; | |
78 se -> symtype = symtype; | |
32
49d608aecc4d
Framework for handling local stack frame and/or variables
lost@l-w.ca
parents:
29
diff
changeset
|
79 se -> privdata = privdata; |
29 | 80 se -> next = st -> head; |
81 st -> head = se; | |
82 } |