annotate lwasm/unicorns.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
children 211fc8038b8d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
222
03f7192fcd20 Add --unicorns option for IDE integration
William Astle <lost@l-w.ca>
parents:
diff changeset
1 /*
03f7192fcd20 Add --unicorns option for IDE integration
William Astle <lost@l-w.ca>
parents:
diff changeset
2 unicorns.c
03f7192fcd20 Add --unicorns option for IDE integration
William Astle <lost@l-w.ca>
parents:
diff changeset
3
03f7192fcd20 Add --unicorns option for IDE integration
William Astle <lost@l-w.ca>
parents:
diff changeset
4 Copyright © 2012 William Astle
03f7192fcd20 Add --unicorns option for IDE integration
William Astle <lost@l-w.ca>
parents:
diff changeset
5
03f7192fcd20 Add --unicorns option for IDE integration
William Astle <lost@l-w.ca>
parents:
diff changeset
6 This file is part of LWTOOLS.
03f7192fcd20 Add --unicorns option for IDE integration
William Astle <lost@l-w.ca>
parents:
diff changeset
7
03f7192fcd20 Add --unicorns option for IDE integration
William Astle <lost@l-w.ca>
parents:
diff changeset
8 LWTOOLS is free software: you can redistribute it and/or modify it under the
03f7192fcd20 Add --unicorns option for IDE integration
William Astle <lost@l-w.ca>
parents:
diff changeset
9 terms of the GNU General Public License as published by the Free Software
03f7192fcd20 Add --unicorns option for IDE integration
William Astle <lost@l-w.ca>
parents:
diff changeset
10 Foundation, either version 3 of the License, or (at your option) any later
03f7192fcd20 Add --unicorns option for IDE integration
William Astle <lost@l-w.ca>
parents:
diff changeset
11 version.
03f7192fcd20 Add --unicorns option for IDE integration
William Astle <lost@l-w.ca>
parents:
diff changeset
12
03f7192fcd20 Add --unicorns option for IDE integration
William Astle <lost@l-w.ca>
parents:
diff changeset
13 This program is distributed in the hope that it will be useful, but WITHOUT
03f7192fcd20 Add --unicorns option for IDE integration
William Astle <lost@l-w.ca>
parents:
diff changeset
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
03f7192fcd20 Add --unicorns option for IDE integration
William Astle <lost@l-w.ca>
parents:
diff changeset
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
03f7192fcd20 Add --unicorns option for IDE integration
William Astle <lost@l-w.ca>
parents:
diff changeset
16 more details.
03f7192fcd20 Add --unicorns option for IDE integration
William Astle <lost@l-w.ca>
parents:
diff changeset
17
03f7192fcd20 Add --unicorns option for IDE integration
William Astle <lost@l-w.ca>
parents:
diff changeset
18 You should have received a copy of the GNU General Public License along with
03f7192fcd20 Add --unicorns option for IDE integration
William Astle <lost@l-w.ca>
parents:
diff changeset
19 this program. If not, see <http://www.gnu.org/licenses/>.
03f7192fcd20 Add --unicorns option for IDE integration
William Astle <lost@l-w.ca>
parents:
diff changeset
20 */
03f7192fcd20 Add --unicorns option for IDE integration
William Astle <lost@l-w.ca>
parents:
diff changeset
21
03f7192fcd20 Add --unicorns option for IDE integration
William Astle <lost@l-w.ca>
parents:
diff changeset
22 /*
03f7192fcd20 Add --unicorns option for IDE integration
William Astle <lost@l-w.ca>
parents:
diff changeset
23 This adds output to lwasm that is suitable for IDEs and other tools
03f7192fcd20 Add --unicorns option for IDE integration
William Astle <lost@l-w.ca>
parents:
diff changeset
24 that are interesting in the doings of the assembler.
03f7192fcd20 Add --unicorns option for IDE integration
William Astle <lost@l-w.ca>
parents:
diff changeset
25 */
03f7192fcd20 Add --unicorns option for IDE integration
William Astle <lost@l-w.ca>
parents:
diff changeset
26
03f7192fcd20 Add --unicorns option for IDE integration
William Astle <lost@l-w.ca>
parents:
diff changeset
27 #include <stdio.h>
03f7192fcd20 Add --unicorns option for IDE integration
William Astle <lost@l-w.ca>
parents:
diff changeset
28 #include <string.h>
03f7192fcd20 Add --unicorns option for IDE integration
William Astle <lost@l-w.ca>
parents:
diff changeset
29
03f7192fcd20 Add --unicorns option for IDE integration
William Astle <lost@l-w.ca>
parents:
diff changeset
30 #include "lwasm.h"
03f7192fcd20 Add --unicorns option for IDE integration
William Astle <lost@l-w.ca>
parents:
diff changeset
31 #include "lw_alloc.h"
03f7192fcd20 Add --unicorns option for IDE integration
William Astle <lost@l-w.ca>
parents:
diff changeset
32
03f7192fcd20 Add --unicorns option for IDE integration
William Astle <lost@l-w.ca>
parents:
diff changeset
33 void lwasm_do_unicorns(asmstate_t *as)
03f7192fcd20 Add --unicorns option for IDE integration
William Astle <lost@l-w.ca>
parents:
diff changeset
34 {
03f7192fcd20 Add --unicorns option for IDE integration
William Astle <lost@l-w.ca>
parents:
diff changeset
35 char *n;
03f7192fcd20 Add --unicorns option for IDE integration
William Astle <lost@l-w.ca>
parents:
diff changeset
36 macrotab_t *me;
03f7192fcd20 Add --unicorns option for IDE integration
William Astle <lost@l-w.ca>
parents:
diff changeset
37
03f7192fcd20 Add --unicorns option for IDE integration
William Astle <lost@l-w.ca>
parents:
diff changeset
38 /* output file list */
03f7192fcd20 Add --unicorns option for IDE integration
William Astle <lost@l-w.ca>
parents:
diff changeset
39 while ((n = lw_stack_pop(as -> includelist)))
03f7192fcd20 Add --unicorns option for IDE integration
William Astle <lost@l-w.ca>
parents:
diff changeset
40 {
03f7192fcd20 Add --unicorns option for IDE integration
William Astle <lost@l-w.ca>
parents:
diff changeset
41 fprintf(stdout, "RESOURCE: file:%s\n", n);
03f7192fcd20 Add --unicorns option for IDE integration
William Astle <lost@l-w.ca>
parents:
diff changeset
42 lw_free(n);
03f7192fcd20 Add --unicorns option for IDE integration
William Astle <lost@l-w.ca>
parents:
diff changeset
43 }
03f7192fcd20 Add --unicorns option for IDE integration
William Astle <lost@l-w.ca>
parents:
diff changeset
44
03f7192fcd20 Add --unicorns option for IDE integration
William Astle <lost@l-w.ca>
parents:
diff changeset
45 /* output macro list */
03f7192fcd20 Add --unicorns option for IDE integration
William Astle <lost@l-w.ca>
parents:
diff changeset
46 for (me = as -> macros; me; me = me -> next)
03f7192fcd20 Add --unicorns option for IDE integration
William Astle <lost@l-w.ca>
parents:
diff changeset
47 {
03f7192fcd20 Add --unicorns option for IDE integration
William Astle <lost@l-w.ca>
parents:
diff changeset
48 fprintf(stdout, "RESOURCE: macro:%s,%d,%s\n", me -> name, me -> definedat -> lineno, me -> definedat -> linespec);
03f7192fcd20 Add --unicorns option for IDE integration
William Astle <lost@l-w.ca>
parents:
diff changeset
49 }
03f7192fcd20 Add --unicorns option for IDE integration
William Astle <lost@l-w.ca>
parents:
diff changeset
50 }