[Mesa-dev] [PATCH 1/3] glsl: Make is_lvalue() and variable_referenced() const.

Chad Versace chad at chad-versace.us
Thu Aug 4 18:55:52 PDT 2011


On 08/02/2011 05:38 PM, Paul Berry wrote:
> These functions don't modify the target instruction, so it makes sense
> to make them const.  This allows these functions to be called from ir
> validation code (which uses const to ensure that it doesn't
> accidentally modify the IR being validated).
> ---
>  src/glsl/ir.cpp |    4 ++--
>  src/glsl/ir.h   |   18 +++++++++---------
>  2 files changed, 11 insertions(+), 11 deletions(-)
> 
> diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp
> index 827fe8e..6f8676e 100644
> --- a/src/glsl/ir.cpp
> +++ b/src/glsl/ir.cpp
> @@ -1096,7 +1096,7 @@ ir_dereference_record::ir_dereference_record(ir_variable *var,
>  }
>  
>  bool
> -ir_dereference::is_lvalue()
> +ir_dereference::is_lvalue() const
>  {
>     ir_variable *var = this->variable_referenced();
>  
> @@ -1310,7 +1310,7 @@ ir_swizzle::create(ir_rvalue *val, const char *str, unsigned vector_length)
>  #undef I
>  
>  ir_variable *
> -ir_swizzle::variable_referenced()
> +ir_swizzle::variable_referenced() const
>  {
>     return this->val->variable_referenced();
>  }
> diff --git a/src/glsl/ir.h b/src/glsl/ir.h
> index 50a9d6e..04fa97b 100644
> --- a/src/glsl/ir.h
> +++ b/src/glsl/ir.h
> @@ -144,7 +144,7 @@ public:
>  
>     ir_rvalue *as_rvalue_to_saturate();
>  
> -   virtual bool is_lvalue()
> +   virtual bool is_lvalue() const
>     {
>        return false;
>     }
> @@ -152,7 +152,7 @@ public:
>     /**
>      * Get the variable that is ultimately referenced by an r-value
>      */
> -   virtual ir_variable *variable_referenced()
> +   virtual ir_variable *variable_referenced() const
>     {
>        return NULL;
>     }
> @@ -1355,7 +1355,7 @@ public:
>  
>     virtual ir_visitor_status accept(ir_hierarchical_visitor *);
>  
> -   bool is_lvalue()
> +   bool is_lvalue() const
>     {
>        return val->is_lvalue() && !mask.has_duplicates;
>     }
> @@ -1363,7 +1363,7 @@ public:
>     /**
>      * Get the variable that is ultimately referenced by an r-value
>      */
> -   virtual ir_variable *variable_referenced();
> +   virtual ir_variable *variable_referenced() const;
>  
>     ir_rvalue *val;
>     ir_swizzle_mask mask;
> @@ -1387,12 +1387,12 @@ public:
>        return this;
>     }
>  
> -   bool is_lvalue();
> +   bool is_lvalue() const;
>  
>     /**
>      * Get the variable that is ultimately referenced by an r-value
>      */
> -   virtual ir_variable *variable_referenced() = 0;
> +   virtual ir_variable *variable_referenced() const = 0;
>  };
>  
>  
> @@ -1413,7 +1413,7 @@ public:
>     /**
>      * Get the variable that is ultimately referenced by an r-value
>      */
> -   virtual ir_variable *variable_referenced()
> +   virtual ir_variable *variable_referenced() const
>     {
>        return this->var;
>     }
> @@ -1462,7 +1462,7 @@ public:
>     /**
>      * Get the variable that is ultimately referenced by an r-value
>      */
> -   virtual ir_variable *variable_referenced()
> +   virtual ir_variable *variable_referenced() const
>     {
>        return this->array->variable_referenced();
>     }
> @@ -1496,7 +1496,7 @@ public:
>     /**
>      * Get the variable that is ultimately referenced by an r-value
>      */
> -   virtual ir_variable *variable_referenced()
> +   virtual ir_variable *variable_referenced() const
>     {
>        return this->record->variable_referenced();
>     }

This patch is sensible and straightforward.
Reviwed-by: Chad Versace <chad at chad-versace.us>

-- 
Chad Versace
chad at chad-versace.us

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 900 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20110804/faf77c5a/attachment.pgp>


More information about the mesa-dev mailing list