comparison lwasm/symbol.c @ 390:027d7fbcdcfc

Basic symbol table output; needs work for non-constant symbols
author lost@l-w.ca
date Wed, 14 Jul 2010 22:46:56 -0600
parents fbb7bfed8076
children 7bcc50e828ff
comparison
equal deleted inserted replaced
389:fbb7bfed8076 390:027d7fbcdcfc
19 this program. If not, see <http://www.gnu.org/licenses/>. 19 this program. If not, see <http://www.gnu.org/licenses/>.
20 */ 20 */
21 21
22 #include <config.h> 22 #include <config.h>
23 23
24 #include <stdio.h>
24 #include <stdlib.h> 25 #include <stdlib.h>
25 #include <string.h> 26 #include <string.h>
26 27
27 #include <lw_alloc.h> 28 #include <lw_alloc.h>
28 #include <lw_expr.h> 29 #include <lw_expr.h>
164 if (!s && s2) 165 if (!s && s2)
165 s = s2; 166 s = s2;
166 167
167 return s; 168 return s;
168 } 169 }
170
171 void list_symbols(asmstate_t *as, FILE *of)
172 {
173 struct symtabe *s;
174
175 fprintf(of, "\nSymbol Table:\n");
176
177 for (s = as -> symtab.head; s; s = s -> next)
178 {
179 fputc('[', of);
180 if (s -> flags & symbol_flag_set)
181 fputc('S', of);
182 else
183 fputc(' ', of);
184 if (lw_expr_istype(s -> value, lw_expr_type_int))
185 fputc('G', of);
186 else
187 fputc(' ', of);
188 fputc(']', of);
189 fputc(' ', of);
190 fprintf(of, "%-32s ", s -> symbol);
191 if (lw_expr_istype(s -> value, lw_expr_type_int))
192 fprintf(of, "%04X\n", lw_expr_intval(s -> value));
193 else
194 fprintf(of, "%s\n", lw_expr_print(s -> value));
195 }
196 }