From bbafd2b849629d3155fe0eef655bbc166a901925 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Sat, 1 Jan 2011 03:37:02 -0800 Subject: [PATCH] ir_reader: Make assignment conditions optional. You can now simply write (assign (xy) ) instead of the verbose (assign (constant bool (1)) (xy) ). --- src/glsl/ir_print_visitor.cpp | 3 --- src/glsl/ir_reader.cpp | 21 +++++++++++++-------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/glsl/ir_print_visitor.cpp b/src/glsl/ir_print_visitor.cpp index 0aa0b0a5d32..c56bafd00c5 100644 --- a/src/glsl/ir_print_visitor.cpp +++ b/src/glsl/ir_print_visitor.cpp @@ -281,9 +281,6 @@ void ir_print_visitor::visit(ir_assignment *ir) if (ir->condition) ir->condition->accept(this); - else - printf("(constant bool (1))"); - char mask[5]; unsigned j = 0; diff --git a/src/glsl/ir_reader.cpp b/src/glsl/ir_reader.cpp index 11a8cb7ac24..40901dc6c92 100644 --- a/src/glsl/ir_reader.cpp +++ b/src/glsl/ir_reader.cpp @@ -538,20 +538,25 @@ ir_reader::read_rvalue(s_expression *expr) ir_assignment * ir_reader::read_assignment(s_expression *expr) { - s_expression *cond_expr, *lhs_expr, *rhs_expr; + s_expression *cond_expr = NULL; + s_expression *lhs_expr, *rhs_expr; s_list *mask_list; - s_pattern pat[] = { "assign", cond_expr, mask_list, lhs_expr, rhs_expr }; - if (!MATCH(expr, pat)) { - ir_read_error(expr, "expected (assign () " + s_pattern pat4[] = { "assign", mask_list, lhs_expr, rhs_expr }; + s_pattern pat5[] = { "assign", cond_expr, mask_list, lhs_expr, rhs_expr }; + if (!MATCH(expr, pat4) && !MATCH(expr, pat5)) { + ir_read_error(expr, "expected (assign [] () " " )"); return NULL; } - ir_rvalue *condition = read_rvalue(cond_expr); - if (condition == NULL) { - ir_read_error(NULL, "when reading condition of assignment"); - return NULL; + ir_rvalue *condition = NULL; + if (cond_expr != NULL) { + condition = read_rvalue(cond_expr); + if (condition == NULL) { + ir_read_error(NULL, "when reading condition of assignment"); + return NULL; + } } unsigned mask = 0; -- 2.30.2