annotate src/lwasm.c @ 26:d2e86babd958

Added error tracking infrastructure
author lost
date Fri, 02 Jan 2009 02:38:02 +0000
parents 05d4115b4860
children f736579569b4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
1 /*
4
34568fab6058 Fixed package to include all required files; also added copyright preamble to all source files
lost
parents: 0
diff changeset
2 lwasm.c
34568fab6058 Fixed package to include all required files; also added copyright preamble to all source files
lost
parents: 0
diff changeset
3 Copyright © 2008 William Astle
34568fab6058 Fixed package to include all required files; also added copyright preamble to all source files
lost
parents: 0
diff changeset
4
34568fab6058 Fixed package to include all required files; also added copyright preamble to all source files
lost
parents: 0
diff changeset
5 This file is part of LWASM.
34568fab6058 Fixed package to include all required files; also added copyright preamble to all source files
lost
parents: 0
diff changeset
6
34568fab6058 Fixed package to include all required files; also added copyright preamble to all source files
lost
parents: 0
diff changeset
7 LWASM is free software: you can redistribute it and/or modify it under the
34568fab6058 Fixed package to include all required files; also added copyright preamble to all source files
lost
parents: 0
diff changeset
8 terms of the GNU General Public License as published by the Free Software
34568fab6058 Fixed package to include all required files; also added copyright preamble to all source files
lost
parents: 0
diff changeset
9 Foundation, either version 3 of the License, or (at your option) any later
34568fab6058 Fixed package to include all required files; also added copyright preamble to all source files
lost
parents: 0
diff changeset
10 version.
34568fab6058 Fixed package to include all required files; also added copyright preamble to all source files
lost
parents: 0
diff changeset
11
34568fab6058 Fixed package to include all required files; also added copyright preamble to all source files
lost
parents: 0
diff changeset
12 This program is distributed in the hope that it will be useful, but WITHOUT
34568fab6058 Fixed package to include all required files; also added copyright preamble to all source files
lost
parents: 0
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
34568fab6058 Fixed package to include all required files; also added copyright preamble to all source files
lost
parents: 0
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
34568fab6058 Fixed package to include all required files; also added copyright preamble to all source files
lost
parents: 0
diff changeset
15 more details.
34568fab6058 Fixed package to include all required files; also added copyright preamble to all source files
lost
parents: 0
diff changeset
16
34568fab6058 Fixed package to include all required files; also added copyright preamble to all source files
lost
parents: 0
diff changeset
17 You should have received a copy of the GNU General Public License along with
34568fab6058 Fixed package to include all required files; also added copyright preamble to all source files
lost
parents: 0
diff changeset
18 this program. If not, see <http://www.gnu.org/licenses/>.
34568fab6058 Fixed package to include all required files; also added copyright preamble to all source files
lost
parents: 0
diff changeset
19
26
d2e86babd958 Added error tracking infrastructure
lost
parents: 13
diff changeset
20
d2e86babd958 Added error tracking infrastructure
lost
parents: 13
diff changeset
21 Contains random functions used by the assembler
4
34568fab6058 Fixed package to include all required files; also added copyright preamble to all source files
lost
parents: 0
diff changeset
22 */
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
23
26
d2e86babd958 Added error tracking infrastructure
lost
parents: 13
diff changeset
24 #define __lwasm_c_seen__
d2e86babd958 Added error tracking infrastructure
lost
parents: 13
diff changeset
25
d2e86babd958 Added error tracking infrastructure
lost
parents: 13
diff changeset
26 #include <stdarg.h>
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
27 #include <stdlib.h>
26
d2e86babd958 Added error tracking infrastructure
lost
parents: 13
diff changeset
28 #include <stdio.h>
d2e86babd958 Added error tracking infrastructure
lost
parents: 13
diff changeset
29
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
30 #include "lwasm.h"
26
d2e86babd958 Added error tracking infrastructure
lost
parents: 13
diff changeset
31 #include "util.h"
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
32
26
d2e86babd958 Added error tracking infrastructure
lost
parents: 13
diff changeset
33 int register_error(asmstate_t *as, lwasm_line_t *l, int pass, const char *fmt, ...)
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
34 {
26
d2e86babd958 Added error tracking infrastructure
lost
parents: 13
diff changeset
35 lwasm_error_t *e;
d2e86babd958 Added error tracking infrastructure
lost
parents: 13
diff changeset
36 va_list args;
d2e86babd958 Added error tracking infrastructure
lost
parents: 13
diff changeset
37 char errbuff[1024];
d2e86babd958 Added error tracking infrastructure
lost
parents: 13
diff changeset
38 int r;
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
39
26
d2e86babd958 Added error tracking infrastructure
lost
parents: 13
diff changeset
40 if (as -> passnum != pass)
d2e86babd958 Added error tracking infrastructure
lost
parents: 13
diff changeset
41 return;
d2e86babd958 Added error tracking infrastructure
lost
parents: 13
diff changeset
42
d2e86babd958 Added error tracking infrastructure
lost
parents: 13
diff changeset
43 va_start(args, fmt);
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
44
26
d2e86babd958 Added error tracking infrastructure
lost
parents: 13
diff changeset
45 e = lwasm_alloc(sizeof(lwasm_error_t));
d2e86babd958 Added error tracking infrastructure
lost
parents: 13
diff changeset
46
d2e86babd958 Added error tracking infrastructure
lost
parents: 13
diff changeset
47 e -> next = l -> err;
d2e86babd958 Added error tracking infrastructure
lost
parents: 13
diff changeset
48 l -> err = e;
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
49
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
50 as -> errorcount++;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
51
26
d2e86babd958 Added error tracking infrastructure
lost
parents: 13
diff changeset
52 r = vsnprintf(errbuff, 1024, fmt, args);
d2e86babd958 Added error tracking infrastructure
lost
parents: 13
diff changeset
53 e -> mess = lwasm_strdup(errbuff);
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
54
26
d2e86babd958 Added error tracking infrastructure
lost
parents: 13
diff changeset
55 va_end(args);
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
56
26
d2e86babd958 Added error tracking infrastructure
lost
parents: 13
diff changeset
57 return r;
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
58 }