Mercurial > hg-old > index.cgi
diff 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 |
line wrap: on
line diff
--- a/lwasm/symbol.c Wed Jul 14 22:33:55 2010 -0600 +++ b/lwasm/symbol.c Wed Jul 14 22:46:56 2010 -0600 @@ -21,6 +21,7 @@ #include <config.h> +#include <stdio.h> #include <stdlib.h> #include <string.h> @@ -166,3 +167,30 @@ return s; } + +void list_symbols(asmstate_t *as, FILE *of) +{ + struct symtabe *s; + + fprintf(of, "\nSymbol Table:\n"); + + for (s = as -> symtab.head; s; s = s -> next) + { + fputc('[', of); + if (s -> flags & symbol_flag_set) + fputc('S', of); + else + fputc(' ', of); + if (lw_expr_istype(s -> value, lw_expr_type_int)) + fputc('G', of); + else + fputc(' ', of); + fputc(']', of); + fputc(' ', of); + fprintf(of, "%-32s ", s -> symbol); + if (lw_expr_istype(s -> value, lw_expr_type_int)) + fprintf(of, "%04X\n", lw_expr_intval(s -> value)); + else + fprintf(of, "%s\n", lw_expr_print(s -> value)); + } +}