[Mesa-dev] [PATCH 3/5] glsl: Return error_type instead of NULL if element_type() is called on non array type.

Fabian Bieler fabianbieler at fastmail.fm
Tue Jun 18 02:42:50 PDT 2013


On 2013-06-18 11:24, Ian Romanick wrote:
> On 06/03/2013 01:23 PM, Fabian Bieler wrote:
>> This matches the behavior of field_type() and other get_*_type() methods.
>>
>> I looked through the calls to element_type() and didn't find a caller that
>> depends on the old behavior.
> 
> I'm a little be uncomfortable with this change.  There are a few places where the behavior could change (src/glsl/ast_to_hir.cpp:780 and src/glsl/ast_function.cpp:658).  The bigger issue is that error_type was only ever intend to "exist" in ast_to_hir.  The intention was that type checking operations could propagate error_type up the tree.  A compilation error would be emitted once, and when another expression saw "<int> + <error_type>" it wouldn't emit another error message.  We started off following that idea really well, but we kind of fell of the wagon somewhere along the line.
I see. Please disregard this patch, then.
> 
> Once compilation as completely transitioned from AST to GLSL IR, it should be impossible to get error_type.  That's the intention, anyway.
Thanks for pointing that out to me.
> 
>> Signed-off-by: Fabian Bieler <fabianbieler at fastmail.fm>
>> ---
>>   src/glsl/glsl_types.h | 6 +++---
>>   1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/src/glsl/glsl_types.h b/src/glsl/glsl_types.h
>> index 31e3dd2..362c970 100644
>> --- a/src/glsl/glsl_types.h
>> +++ b/src/glsl/glsl_types.h
>> @@ -213,12 +213,12 @@ struct glsl_type {
>>       * Query the type of elements in an array
>>       *
>>       * \return
>> -    * Pointer to the type of elements in the array for array types, or \c NULL
>> -    * for non-array types.
>> +    * Pointer to the type of elements in the array for array types, or
>> +    * \c glsl_type::error_type for non-array types.
>>       */
>>      const glsl_type *element_type() const
>>      {
>> -      return is_array() ? fields.array : NULL;
>> +      return is_array() ? fields.array : error_type;
>>      }
>>
>>      /**
>>
> 



More information about the mesa-dev mailing list