OSDN Git Service

glsl: Constify the as_foo functions
authorIan Romanick <ian.d.romanick@intel.com>
Tue, 24 Mar 2015 16:14:35 +0000 (09:14 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Wed, 25 Mar 2015 17:40:52 +0000 (10:40 -0700)
Now that they're all implemented using macros, this is trivial.

v2: Remove redundant parenthesis.  Suggested by Curro.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Francisco Jerez <currojerez@riseup.net>
src/glsl/ir.h

index 0284b02..b95ba2c 100644 (file)
@@ -147,6 +147,11 @@ public:
    {                                                    \
       assume(this != NULL);                             \
       return is_##TYPE() ? (ir_##TYPE *) this : NULL;   \
+   }                                                    \
+   const class ir_##TYPE *as_##TYPE() const             \
+   {                                                    \
+      assume(this != NULL);                             \
+      return is_##TYPE() ? (ir_##TYPE *) this : NULL;   \
    }
 
    AS_BASE(rvalue)
@@ -159,6 +164,11 @@ public:
    { \
       assume(this != NULL);                                         \
       return ir_type == ir_type_##TYPE ? (ir_##TYPE *) this : NULL; \
+   }                                                                      \
+   const class ir_##TYPE * as_##TYPE() const                              \
+   {                                                                      \
+      assume(this != NULL);                                               \
+      return ir_type == ir_type_##TYPE ? (const ir_##TYPE *) this : NULL; \
    }
    AS_CHILD(variable)
    AS_CHILD(function)