Mercurial > hg > index.cgi
comparison lwasm/main.c @ 222:03f7192fcd20
Add --unicorns option for IDE integration
This version of unicorns adds RESOURCE: lines to the output which specify
files and macros discovered during the assembly process.
author | William Astle <lost@l-w.ca> |
---|---|
date | Sun, 15 Jul 2012 10:50:46 -0600 |
parents | afd50d6b4113 |
children | 3864d96ee8c7 |
comparison
equal
deleted
inserted
replaced
221:2b784a28428e | 222:03f7192fcd20 |
---|---|
29 #include <lw_expr.h> | 29 #include <lw_expr.h> |
30 #include <lw_cmdline.h> | 30 #include <lw_cmdline.h> |
31 | 31 |
32 #include "lwasm.h" | 32 #include "lwasm.h" |
33 #include "input.h" | 33 #include "input.h" |
34 | |
35 extern void lwasm_do_unicorns(asmstate_t *as); | |
34 | 36 |
35 extern int parse_pragma_string(asmstate_t *as, char *str, int ignoreerr); | 37 extern int parse_pragma_string(asmstate_t *as, char *str, int ignoreerr); |
36 | 38 |
37 /* command line option handling */ | 39 /* command line option handling */ |
38 #define PROGVER "lwasm from " PACKAGE_STRING | 40 #define PROGVER "lwasm from " PACKAGE_STRING |
54 { "6809", '9', 0, 0, "Set assembler to 6809 only mode" }, | 56 { "6809", '9', 0, 0, "Set assembler to 6809 only mode" }, |
55 { "6309", '3', 0, 0, "Set assembler to 6309 mode (default)" }, | 57 { "6309", '3', 0, 0, "Set assembler to 6309 mode (default)" }, |
56 { "includedir", 'I', "PATH", 0, "Add entry to include path" }, | 58 { "includedir", 'I', "PATH", 0, "Add entry to include path" }, |
57 { "define", 'D', "SYM[=VAL]", 0, "Automatically define SYM to be VAL (or 1)"}, | 59 { "define", 'D', "SYM[=VAL]", 0, "Automatically define SYM to be VAL (or 1)"}, |
58 { "preprocess", 'P', 0, 0, "Preprocess macros and conditionals and output revised source to stdout" }, | 60 { "preprocess", 'P', 0, 0, "Preprocess macros and conditionals and output revised source to stdout" }, |
61 { "unicorns", 0x4242, 0, 0, "Add sooper sekrit sauce"}, | |
59 { 0 } | 62 { 0 } |
60 }; | 63 }; |
61 | 64 |
62 | 65 |
63 static int parse_opts(int key, char *arg, void *state) | 66 static int parse_opts(int key, char *arg, void *state) |
134 as -> flags |= FLAG_DEPEND; | 137 as -> flags |= FLAG_DEPEND; |
135 break; | 138 break; |
136 | 139 |
137 case 0x102: | 140 case 0x102: |
138 as -> flags |= FLAG_DEPEND | FLAG_DEPENDNOERR; | 141 as -> flags |= FLAG_DEPEND | FLAG_DEPENDNOERR; |
142 break; | |
143 | |
144 case 0x4242: | |
145 as -> flags |= FLAG_UNICORNS; | |
139 break; | 146 break; |
140 | 147 |
141 case 'f': | 148 case 'f': |
142 if (!strcasecmp(arg, "decb")) | 149 if (!strcasecmp(arg, "decb")) |
143 as -> output_format = OUTPUT_DECB; | 150 as -> output_format = OUTPUT_DECB; |
282 { | 289 { |
283 // don't show errors during dependency scanning but | 290 // don't show errors during dependency scanning but |
284 // stop processing immediately | 291 // stop processing immediately |
285 break; | 292 break; |
286 } | 293 } |
294 lwasm_do_unicorns(&asmstate); | |
287 lwasm_show_errors(&asmstate); | 295 lwasm_show_errors(&asmstate); |
288 exit(1); | 296 exit(1); |
289 } | 297 } |
290 } | 298 } |
291 | 299 |
292 if (asmstate.flags & FLAG_DEPEND) | 300 if (asmstate.flags & FLAG_DEPEND) |
293 { | 301 { |
294 // output dependencies (other than "includebin") | 302 if ((asmstate.flags & FLAG_UNICORNS) == 0) |
295 char *n; | 303 { |
296 | 304 // output dependencies (other than "includebin") |
297 while ((n = lw_stack_pop(asmstate.includelist))) | 305 char *n; |
298 { | 306 |
299 fprintf(stdout, "%s\n", n); | 307 while ((n = lw_stack_pop(asmstate.includelist))) |
300 lw_free(n); | 308 { |
309 fprintf(stdout, "%s\n", n); | |
310 lw_free(n); | |
311 } | |
301 } | 312 } |
302 } | 313 } |
303 else | 314 else |
304 { | 315 { |
305 debug_message(&asmstate, 50, "Doing output"); | 316 debug_message(&asmstate, 50, "Doing output"); |
306 do_output(&asmstate); | 317 do_output(&asmstate); |
307 } | 318 } |
308 | 319 |
309 debug_message(&asmstate, 50, "Done assembly"); | 320 debug_message(&asmstate, 50, "Done assembly"); |
310 | 321 |
311 do_list(&asmstate); | 322 if (asmstate.flags & FLAG_UNICORNS) |
312 | 323 { |
324 lwasm_do_unicorns(&asmstate); | |
325 } | |
326 else | |
327 { | |
328 do_list(&asmstate); | |
329 } | |
313 exit(0); | 330 exit(0); |
314 } | 331 } |