Mercurial > hg-old > index.cgi
comparison lwasm/symbol.c @ 405:7bcc50e828ff
Fixed up symbol table list to be more clear
author | lost@l-w.ca |
---|---|
date | Fri, 23 Jul 2010 18:58:20 -0600 |
parents | 027d7fbcdcfc |
children | 502fbc37ff4e |
comparison
equal
deleted
inserted
replaced
404:0324fd09c7ac | 405:7bcc50e828ff |
---|---|
166 s = s2; | 166 s = s2; |
167 | 167 |
168 return s; | 168 return s; |
169 } | 169 } |
170 | 170 |
171 struct listinfo | |
172 { | |
173 sectiontab_t *sect; | |
174 asmstate_t *as; | |
175 int complex; | |
176 }; | |
177 | |
178 int list_symbols_test(lw_expr_t e, void *p) | |
179 { | |
180 struct listinfo *li = p; | |
181 | |
182 if (li -> complex) | |
183 return 0; | |
184 | |
185 if (lw_expr_istype(e, lw_expr_type_special)) | |
186 { | |
187 if (lw_expr_specint(e) == lwasm_expr_secbase) | |
188 { | |
189 if (li -> sect) | |
190 { | |
191 li -> complex = 1; | |
192 } | |
193 else | |
194 { | |
195 li -> sect = lw_expr_specptr(e); | |
196 } | |
197 } | |
198 } | |
199 return 0; | |
200 } | |
201 | |
171 void list_symbols(asmstate_t *as, FILE *of) | 202 void list_symbols(asmstate_t *as, FILE *of) |
172 { | 203 { |
173 struct symtabe *s; | 204 struct symtabe *s; |
174 | 205 lw_expr_t te; |
206 struct listinfo li; | |
207 | |
208 li.as = as; | |
209 | |
175 fprintf(of, "\nSymbol Table:\n"); | 210 fprintf(of, "\nSymbol Table:\n"); |
176 | 211 |
177 for (s = as -> symtab.head; s; s = s -> next) | 212 for (s = as -> symtab.head; s; s = s -> next) |
178 { | 213 { |
214 lwasm_reduce_expr(as, s -> value); | |
179 fputc('[', of); | 215 fputc('[', of); |
180 if (s -> flags & symbol_flag_set) | 216 if (s -> flags & symbol_flag_set) |
181 fputc('S', of); | 217 fputc('S', of); |
182 else | 218 else |
183 fputc(' ', of); | 219 fputc(' ', of); |
184 if (lw_expr_istype(s -> value, lw_expr_type_int)) | 220 if (as -> output_format == OUTPUT_OBJ) |
221 { | |
222 if (lw_expr_istype(s -> value, lw_expr_type_int)) | |
223 fputc('c', of); | |
224 else | |
225 fputc('s', of); | |
226 } | |
227 if (s -> context < 0) | |
185 fputc('G', of); | 228 fputc('G', of); |
186 else | 229 else |
187 fputc(' ', of); | 230 fputc('L', of); |
231 | |
188 fputc(']', of); | 232 fputc(']', of); |
189 fputc(' ', of); | 233 fputc(' ', of); |
190 fprintf(of, "%-32s ", s -> symbol); | 234 fprintf(of, "%-32s ", s -> symbol); |
191 if (lw_expr_istype(s -> value, lw_expr_type_int)) | 235 |
192 fprintf(of, "%04X\n", lw_expr_intval(s -> value)); | 236 te = lw_expr_copy(s -> value); |
237 li.complex = 0; | |
238 li.sect = NULL; | |
239 lw_expr_testterms(te, list_symbols_test, &li); | |
240 if (li.sect) | |
241 { | |
242 as -> exportcheck = 1; | |
243 as -> csect = li.sect; | |
244 lwasm_reduce_expr(as, te); | |
245 as -> exportcheck = 0; | |
246 } | |
247 | |
248 if (lw_expr_istype(te, lw_expr_type_int)) | |
249 { | |
250 fprintf(of, "%04X", lw_expr_intval(te)); | |
251 if (li.sect) | |
252 { | |
253 fprintf(of, " (%s)", li.sect -> name); | |
254 } | |
255 fprintf(of, "\n"); | |
256 } | |
193 else | 257 else |
194 fprintf(of, "%s\n", lw_expr_print(s -> value)); | 258 { |
195 } | 259 fprintf(of, "<<incomplete>>\n"); |
196 } | 260 // fprintf(of, "%s\n", lw_expr_print(s -> value)); |
261 } | |
262 lw_expr_destroy(te); | |
263 } | |
264 } |