[Mesa-dev] [PATCH] ast_to_hir: Only use the local 'type' variable as a temporary.
Eric Anholt
eric at anholt.net
Tue Apr 12 09:55:55 PDT 2011
On Tue, 12 Apr 2011 00:36:59 -0700, Kenneth Graunke <kenneth at whitecape.org> wrote:
> Lots of code (deleted in this patch) tried to make type == result->type,
> but not all cases did. Don't pretend; just use result->type.
> ---
> src/glsl/ast_to_hir.cpp | 23 ++++-------------------
> 1 files changed, 4 insertions(+), 19 deletions(-)
>
> Why, so it does! Good catch. Of course, "type" is silly. This patch
> starts the process of cleaning up some of the pointless cases. There's
> probably more that could be done - for example, the cases that call
> unary_arithmetic_result_type and completely ignore the type returned
> (they just use it for the error checking). But meh for now.
>
> IMHO the only real reason for 'type' to exist is to have a temporary
> available without having to use { } around case clauses.
>
> If you like this patch I can rebase Eric's changes on top of it.
I'm totally willing to rebase onto this -- I've pulled in the r-bs and
typo fixes already.
> @@ -1685,16 +1670,16 @@ ast_expression::hir(exec_list *instructions,
> foreach_list_typed (ast_node, ast, link, &this->expressions)
> result = ast->hir(instructions, state);
>
> - type = result->type;
> -
> /* Any errors should have already been emitted in the loop above.
> */
> error_emitted = true;
> break;
> }
> }
> + type = NULL; /* use result->type, not type. */
> + assert(result != NULL);
>
> - if (type->is_error() && !error_emitted)
> + if (result->type->is_error() && !error_emitted)
> _mesa_glsl_error(& loc, state, "type mismatch");
>
> return result;
I'd drop the dead assignment to type here, myself, but other than that
it's
Reviewed-by: Eric Anholt <eric at anholt.net>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20110412/e358d4ec/attachment.pgp>
More information about the mesa-dev
mailing list