[Mesa-dev] [PATCH 12/19] glsl: Generalize processing of variable redeclarations.
Paul Berry
stereotype441 at gmail.com
Tue Oct 8 14:38:49 PDT 2013
On 5 October 2013 12:25, Kenneth Graunke <kenneth at whitecape.org> wrote:
> On 10/02/2013 05:45 PM, Paul Berry wrote:
> > This patch modifies the get_variable_being_redeclared() function so
> > that it no longer relies on the ast_declaration for the variable being
> > redeclared. In future patches, this will allow
> > get_variable_being_redeclared() to be used for processing
> > redeclarations of the built-in gl_PerVertex interface block.
> > ---
> > src/glsl/ast_to_hir.cpp | 13 ++++++-------
> > 1 file changed, 6 insertions(+), 7 deletions(-)
> >
> > diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
> > index 8fb7f2f..de65c71 100644
> > --- a/src/glsl/ast_to_hir.cpp
> > +++ b/src/glsl/ast_to_hir.cpp
> > @@ -2327,7 +2327,7 @@ apply_type_qualifier_to_variable(const struct
> ast_type_qualifier *qual,
> > * is a redeclaration, \c NULL otherwise.
> > */
> > ir_variable *
> > -get_variable_being_redeclared(ir_variable *var, ast_declaration *decl,
> > +get_variable_being_redeclared(ir_variable *var, YYLTYPE loc,
> > struct _mesa_glsl_parse_state *state)
>
> While you're at it, would you mind making this function static?
>
Done.
>
> Either way, patches 5-12 are:
> Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
>
> > {
> > /* Check if this declaration is actually a re-declaration, either to
> > @@ -2336,16 +2336,14 @@ get_variable_being_redeclared(ir_variable *var,
> ast_declaration *decl,
> > * This is allowed for variables in the current scope, or when at
> > * global scope (for built-ins in the implicit outer scope).
> > */
> > - ir_variable *earlier =
> state->symbols->get_variable(decl->identifier);
> > + ir_variable *earlier = state->symbols->get_variable(var->name);
> > if (earlier == NULL ||
> > (state->current_function != NULL &&
> > - !state->symbols->name_declared_this_scope(decl->identifier))) {
> > + !state->symbols->name_declared_this_scope(var->name))) {
> > return NULL;
> > }
> >
> >
> > - YYLTYPE loc = decl->get_location();
> > -
> > /* From page 24 (page 30 of the PDF) of the GLSL 1.50 spec,
> > *
> > * "It is legal to declare an array without a size and then
> > @@ -2434,7 +2432,7 @@ get_variable_being_redeclared(ir_variable *var,
> ast_declaration *decl,
> > earlier->depth_layout = var->depth_layout;
> >
> > } else {
> > - _mesa_glsl_error(&loc, state, "`%s' redeclared",
> decl->identifier);
> > + _mesa_glsl_error(&loc, state, "`%s' redeclared", var->name);
> > }
> >
> > return earlier;
> > @@ -3221,7 +3219,8 @@ ast_declarator_list::hir(exec_list *instructions,
> > * instruction stream.
> > */
> > exec_list initializer_instructions;
> > - ir_variable *earlier = get_variable_being_redeclared(var, decl,
> state);
> > + ir_variable *earlier =
> > + get_variable_being_redeclared(var, decl->get_location(),
> state);
> >
> > if (decl->initializer != NULL) {
> > result = process_initializer((earlier == NULL) ? var : earlier,
> >
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20131008/1d10641b/attachment-0001.html>
More information about the mesa-dev
mailing list