#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);
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);
_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);
unsigned language_version;
enum _mesa_glsl_parser_targets target;
+
+ /** Was there an error during compilation? */
+ bool error;
};
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);