From f7a669d342c96451a3e0be84e2e51af8631f90ec Mon Sep 17 00:00:00 2001 From: gingerBill Date: Sat, 9 Jul 2016 00:31:57 +0100 Subject: Initial release version * Code cleanup * Fix some TODOs * Reduce heap allocation use and replace with arena allocation --- src/generator.cpp | 36 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 21 deletions(-) (limited to 'src/generator.cpp') diff --git a/src/generator.cpp b/src/generator.cpp index bd081f184..d85453a75 100644 --- a/src/generator.cpp +++ b/src/generator.cpp @@ -13,31 +13,25 @@ struct Generator { #define print_generator_error(p, token, fmt, ...) print_generator_error_(p, __FUNCTION__, token, fmt, ##__VA_ARGS__) void print_generator_error_(Generator *g, char *function, Token token, char *fmt, ...) { - va_list va; // NOTE(bill): Duplicate error, skip it - if (g->error_prev_line == token.line && g->error_prev_column == token.column) { - goto error; + if (g->error_prev_line != token.line || g->error_prev_column != token.column) { + va_list va; + + g->error_prev_line = token.line; + g->error_prev_column = token.column; + + #if 0 + gb_printf_err("%s()\n", function); + #endif + va_start(va, fmt); + gb_printf_err("%s(%td:%td) %s\n", + g->checker->parser->tokenizer.fullpath, token.line, token.column, + gb_bprintf_va(fmt, va)); + va_end(va); + } - g->error_prev_line = token.line; - g->error_prev_column = token.column; - -#if 0 - gb_printf_err("%s()\n", function); -#endif - va_start(va, fmt); - gb_printf_err("%s(%td:%td) %s\n", - g->checker->parser->tokenizer.fullpath, token.line, token.column, - gb_bprintf_va(fmt, va)); - va_end(va); - -error: g->error_count++; - // NOTE(bill): If there are too many errors, just quit - if (g->error_count > MAX_GENERATOR_ERROR_COUNT) { - gb_exit(1); - return; - } } -- cgit v1.2.3