summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Romanick <ian.d.romanick@intel.com>2010-03-11 14:08:33 -0800
committerIan Romanick <ian.d.romanick@intel.com>2010-03-11 14:08:33 -0800
commit1f585180597290c7891c43dc0da3c9c06d7cebb1 (patch)
tree9628a03880afbd2fa0c1cac32c6fc7e20cb41067
parent3821761e45c455374c9fdb4cd02104f420373360 (diff)
Track generation of errors and halt compilation appropriately
-rw-r--r--glsl_parser_extras.cpp17
-rw-r--r--glsl_parser_extras.h6
2 files changed, 17 insertions, 6 deletions
diff --git a/glsl_parser_extras.cpp b/glsl_parser_extras.cpp
index d066ca3cd0..52ae79918a 100644
--- a/glsl_parser_extras.cpp
+++ b/glsl_parser_extras.cpp
@@ -38,13 +38,16 @@
#include "ir_print_visitor.h"
void
-_mesa_glsl_error(YYLTYPE *locp, void *state, const char *fmt, ...)
+_mesa_glsl_error(YYLTYPE *locp, _mesa_glsl_parse_state *state,
+ const char *fmt, ...)
{
char buf[1024];
int len;
va_list ap;
- (void) state;
+ if (state)
+ state->error = true;
+
len = snprintf(buf, sizeof(buf), "%u:%u(%u): error: ",
locp->source, locp->first_line, locp->first_column);
@@ -709,6 +712,7 @@ main(int argc, char **argv)
state.scanner = NULL;
make_empty_list(& state.translation_unit);
state.symbols = _mesa_symbol_table_ctor();
+ state.error = false;
_mesa_glsl_lexer_ctor(& state, shader, shader_len);
_mesa_glsl_parse(& state);
@@ -721,10 +725,13 @@ main(int argc, char **argv)
_mesa_ast_to_hir(&instructions, &state);
printf("\n\n");
- foreach_iter(exec_list_iterator, iter, instructions) {
- ir_print_visitor v;
- ((ir_instruction *)iter.get())->accept(& v);
+ if (!state.error) {
+ foreach_iter(exec_list_iterator, iter, instructions) {
+ ir_print_visitor v;
+
+ ((ir_instruction *)iter.get())->accept(& v);
+ }
}
_mesa_symbol_table_dtor(state.symbols);
diff --git a/glsl_parser_extras.h b/glsl_parser_extras.h
index 1c972623c2..c7cd68c181 100644
--- a/glsl_parser_extras.h
+++ b/glsl_parser_extras.h
@@ -41,6 +41,9 @@ struct _mesa_glsl_parse_state {
unsigned language_version;
enum _mesa_glsl_parser_targets target;
+
+ /** Was there an error during compilation? */
+ bool error;
};
typedef struct YYLTYPE {
@@ -53,7 +56,8 @@ typedef struct YYLTYPE {
# define YYLTYPE_IS_DECLARED 1
# define YYLTYPE_IS_TRIVIAL 1
-extern void _mesa_glsl_error(YYLTYPE *locp, void *state, const char *fmt, ...);
+extern void _mesa_glsl_error(YYLTYPE *locp, _mesa_glsl_parse_state *state,
+ const char *fmt, ...);
extern void _mesa_glsl_lexer_ctor(struct _mesa_glsl_parse_state *state,
const char *string, size_t len);