Refactor ir_expression::get_num_operands.
authorKenneth Graunke <kenneth@whitecape.org>
Wed, 7 Apr 2010 23:56:57 +0000 (16:56 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Wed, 28 Apr 2010 22:34:52 +0000 (15:34 -0700)
A new static version takes an ir_expression_operation enum, and the
original non-static version now uses it.  This will make it easier to
read operations (where the ir_expression doesn't yet exist).

ir.cpp
ir.h

diff --git a/ir.cpp b/ir.cpp
index 1ae7dd6f0e5774bcee94d149374e0874b8c83198..b4b2ca4d91617a09b3912b0869a489421162452f 100644 (file)
--- a/ir.cpp
+++ b/ir.cpp
@@ -46,7 +46,7 @@ ir_expression::ir_expression(int op, const struct glsl_type *type,
 }
 
 unsigned int
-ir_expression::get_num_operands(void)
+ir_expression::get_num_operands(ir_expression_operation op)
 {
 /* Update ir_print_visitor.cpp when updating this list. */
    const int num_operands[] = {
@@ -105,7 +105,7 @@ ir_expression::get_num_operands(void)
 
    assert(sizeof(num_operands) / sizeof(num_operands[0]) == ir_binop_pow + 1);
 
-   return num_operands[this->operation];
+   return num_operands[op];
 }
 
 
diff --git a/ir.h b/ir.h
index c93c043f5e53bf85e86e183bdea800f1eecb5a7b..892455e1dee29a74f25318cf2f2255529b83d28a 100644 (file)
--- a/ir.h
+++ b/ir.h
@@ -471,7 +471,11 @@ public:
    ir_expression(int op, const struct glsl_type *type,
                 ir_rvalue *, ir_rvalue *);
 
-   unsigned int get_num_operands(void);
+   static unsigned int get_num_operands(ir_expression_operation);
+   unsigned int get_num_operands()
+   {
+      return get_num_operands(operation);
+   }
 
    virtual void accept(ir_visitor *v)
    {