From 007f4881503b69055d65cfb20bd237673779786b Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 17 Nov 2010 15:31:35 -0800 Subject: glsl: Refactor get_num_operands. This adds sentinel values to the ir_expression_operation enum type: ir_last_unop, ir_last_binop, and ir_last_opcode. They are set to the previous one so they don't trigger "unhandled case in switch statement" warnings, but should never be handled directly. This allows us to remove the huge array of 1s and 2s in ir_expression::get_num_operands(). --- src/glsl/ir.h | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src/glsl/ir.h') diff --git a/src/glsl/ir.h b/src/glsl/ir.h index 38ed2b23ef..3fc834906a 100644 --- a/src/glsl/ir.h +++ b/src/glsl/ir.h @@ -717,6 +717,11 @@ enum ir_expression_operation { ir_unop_noise, + /** + * A sentinel marking the last of the unary operations. + */ + ir_last_unop = ir_unop_noise, + ir_binop_add, ir_binop_sub, ir_binop_mul, @@ -774,7 +779,17 @@ enum ir_expression_operation { ir_binop_min, ir_binop_max, - ir_binop_pow + ir_binop_pow, + + /** + * A sentinel marking the last of the binary operations. + */ + ir_last_binop = ir_binop_pow, + + /** + * A sentinel marking the last of all operations. + */ + ir_last_opcode = ir_last_binop }; class ir_expression : public ir_rvalue { -- cgit v1.2.3