[Mesa-dev] glsl: strange looking code in ast_function.cpp

Ian Romanick idr at freedesktop.org
Wed Aug 17 08:55:07 PDT 2011


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 08/17/2011 07:13 AM, Aras Pranckevicius wrote:
> Lines 290..294 in ast_function.cpp:
> 
>  deref = new(ctx) ir_dereference_variable(var);
>  ir_assignment *assign = new(ctx) ir_assignment(deref, call, NULL);
>  instructions->push_tail(assign);
>  deref = new(ctx) ir_dereference_variable(var);
> 
> 
> The second creation of ir_dereference_variable almost looks like some
> copy-paste accident. If there is a reason for it, I guess a code
> comment would help to figure out why.

The first dereference is to assign the result of the function call to
the temporary variable.  The second dereference is the result of the
function, and that is returned to the caller of match_function_by_name.
 The caller can then use this dereference without having to clone it
first.  Recall that, with the exception of the ir_variable in a
dereference, each node can only appear in the IR stream once.

I'll add a comment of:

	/* Make a new dereference to return to the caller.  This is
	 * used as the result of the function call in expressions.
	 */

Sound good?
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iEYEARECAAYFAk5L5FsACgkQX1gOwKyEAw8F7gCdG0k12GzyM8bMyCHmyw68jT2d
PrIAn36RJDbSTgOLMWTS+V08b/Smug/+
=BmDm
-----END PGP SIGNATURE-----


More information about the mesa-dev mailing list