ir_expression: Add static operator_string method
authorIan Romanick <ian.d.romanick@intel.com>
Fri, 27 Aug 2010 20:53:25 +0000 (13:53 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Fri, 3 Sep 2010 18:55:21 +0000 (11:55 -0700)
I've used this in quite a few debug commits that never reached an
up-stream tree.

src/glsl/ir.cpp
src/glsl/ir.h

index 96b32a2..6d72725 100644 (file)
@@ -287,11 +287,15 @@ static const char *const operator_strs[] = {
    "pow",
 };
 
+const char *ir_expression::operator_string(ir_expression_operation op)
+{
+   assert((unsigned int) op < Elements(operator_strs));
+   return operator_strs[op];
+}
+
 const char *ir_expression::operator_string()
 {
-   assert((unsigned int) operation <=
-         sizeof(operator_strs) / sizeof(operator_strs[0]));
-   return operator_strs[operation];
+   return operator_string(this->operation);
 }
 
 ir_expression_operation
index cf3a882..efe59d8 100644 (file)
@@ -731,6 +731,12 @@ public:
    const char *operator_string();
 
    /**
+    * Return a string representing this expression's operator.
+    */
+   static const char *operator_string(ir_expression_operation);
+
+
+   /**
     * Do a reverse-lookup to translate the given string into an operator.
     */
    static ir_expression_operation get_operator(const char *);