commit a555eb8ab253072c0276423c1e8488a3d202c246
parent b52b7e96f0bf69f84ee33f6648d9a16fc1fc08bb
Author: m21c <ho*******@gmail.com>
Date: Fri, 27 Jun 2025 18:50:44 +0200
added error/warn counters
Diffstat:
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/compiler.c b/compiler.c
@@ -1085,6 +1085,7 @@ initstrmap(StringMap *map)
assert(map->vals);
}
+#if 0
static void
disposestrmap(StringMap *map)
{
@@ -1096,6 +1097,7 @@ disposestrmap(StringMap *map)
free(map->vals);
free(map->keys);
}
+#endif
static void
putstringkey(StringMap *map, int key, int hash)
@@ -1181,6 +1183,9 @@ getstringkey(StringMap *map, const char *str, int n)
// @section error reporting {{{
+int warningcount = 0;
+int errorcount = 0;
+
static int
warn(SrcLoc *loc, const char *fmt, ...)
{
@@ -1198,11 +1203,15 @@ warn(SrcLoc *loc, const char *fmt, ...)
n += fprintf(stderr, "\n");
va_end(ap);
+ ++warningcount;
return n;
}
+#define error(loc, ...) error_(loc, __FUNCTION__, __FILE__, __LINE__, __VA_ARGS__)
+
static int
-error(SrcLoc *loc, const char *fmt, ...)
+error_(SrcLoc *loc, const char *func, const char *file, int line_,
+ const char *fmt, ...)
{
va_list ap;
int n;
@@ -1215,9 +1224,10 @@ error(SrcLoc *loc, const char *fmt, ...)
n = fprintf(stderr, "%s:%u:%u: error: ",
filename, line, column + 1);
n += vfprintf(stderr, fmt, ap);
- n += fprintf(stderr, "\n");
+ n += fprintf(stderr, " \x1b[30m[in %s() at %s:%u]\x1b[0m\n", func, file, line_);
va_end(ap);
+ ++errorcount;
return n;
}