# HG changeset patch # User lost@l-w.ca # Date 1279933100 21600 # Node ID 7bcc50e828ff5e3416471ed5463d88735f5cdf68 # Parent 0324fd09c7ac4f7b7a214583dfa0c12231cd7635 Fixed up symbol table list to be more clear diff -r 0324fd09c7ac -r 7bcc50e828ff lwasm/symbol.c --- a/lwasm/symbol.c Fri Jul 23 18:31:33 2010 -0600 +++ b/lwasm/symbol.c Fri Jul 23 18:58:20 2010 -0600 @@ -168,29 +168,97 @@ return s; } +struct listinfo +{ + sectiontab_t *sect; + asmstate_t *as; + int complex; +}; + +int list_symbols_test(lw_expr_t e, void *p) +{ + struct listinfo *li = p; + + if (li -> complex) + return 0; + + if (lw_expr_istype(e, lw_expr_type_special)) + { + if (lw_expr_specint(e) == lwasm_expr_secbase) + { + if (li -> sect) + { + li -> complex = 1; + } + else + { + li -> sect = lw_expr_specptr(e); + } + } + } + return 0; +} + void list_symbols(asmstate_t *as, FILE *of) { struct symtabe *s; - + lw_expr_t te; + struct listinfo li; + + li.as = as; + fprintf(of, "\nSymbol Table:\n"); for (s = as -> symtab.head; s; s = s -> next) { + lwasm_reduce_expr(as, s -> value); fputc('[', of); if (s -> flags & symbol_flag_set) fputc('S', of); else fputc(' ', of); - if (lw_expr_istype(s -> value, lw_expr_type_int)) + if (as -> output_format == OUTPUT_OBJ) + { + if (lw_expr_istype(s -> value, lw_expr_type_int)) + fputc('c', of); + else + fputc('s', of); + } + if (s -> context < 0) fputc('G', of); else - fputc(' ', of); + fputc('L', 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)); + + te = lw_expr_copy(s -> value); + li.complex = 0; + li.sect = NULL; + lw_expr_testterms(te, list_symbols_test, &li); + if (li.sect) + { + as -> exportcheck = 1; + as -> csect = li.sect; + lwasm_reduce_expr(as, te); + as -> exportcheck = 0; + } + + if (lw_expr_istype(te, lw_expr_type_int)) + { + fprintf(of, "%04X", lw_expr_intval(te)); + if (li.sect) + { + fprintf(of, " (%s)", li.sect -> name); + } + fprintf(of, "\n"); + } else - fprintf(of, "%s\n", lw_expr_print(s -> value)); + { + fprintf(of, "<>\n"); +// fprintf(of, "%s\n", lw_expr_print(s -> value)); + } + lw_expr_destroy(te); } }