From f9e37879eb6407d9374e74d3982651b60ce096a1 Mon Sep 17 00:00:00 2001 From: Matt Turner Date: Tue, 9 Apr 2013 16:43:14 -0700 Subject: [PATCH] glsl: Rework ir_reader to handle expressions with four operands. Needed to support the bitfieldInsert() built-in added by ARB_gpu_shader5. Reviewed-by: Chris Forbes --- src/glsl/ir_reader.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/glsl/ir_reader.cpp b/src/glsl/ir_reader.cpp index 16fdc41b456..b3667124fa8 100644 --- a/src/glsl/ir_reader.cpp +++ b/src/glsl/ir_reader.cpp @@ -676,16 +676,18 @@ ir_reader::read_expression(s_expression *expr) { s_expression *s_type; s_symbol *s_op; - s_expression *s_arg[3]; + s_expression *s_arg[4] = {NULL}; s_pattern pat[] = { "expression", s_type, s_op, s_arg[0] }; if (!PARTIAL_MATCH(expr, pat)) { ir_read_error(expr, "expected (expression " - " [])"); + " [] [] [])"); return NULL; } s_arg[1] = (s_expression *) s_arg[0]->next; // may be tail sentinel s_arg[2] = (s_expression *) s_arg[1]->next; // may be tail sentinel or NULL + if (s_arg[2]) + s_arg[3] = (s_expression *) s_arg[2]->next; // may be tail sentinel or NULL const glsl_type *type = read_type(s_type); if (type == NULL) @@ -709,7 +711,7 @@ ir_reader::read_expression(s_expression *expr) return NULL; } - ir_rvalue *arg[3] = {NULL, NULL, NULL}; + ir_rvalue *arg[4] = {NULL}; for (int i = 0; i < num_operands; i++) { arg[i] = read_rvalue(s_arg[i]); if (arg[i] == NULL) { @@ -718,7 +720,7 @@ ir_reader::read_expression(s_expression *expr) } } - return new(mem_ctx) ir_expression(op, type, arg[0], arg[1], arg[2]); + return new(mem_ctx) ir_expression(op, type, arg[0], arg[1], arg[2], arg[3]); } ir_swizzle * -- 2.30.2