mesa: do scope replacement for variable initializers too
authorBrian Paul <brian.paul@tungstengraphics.com>
Fri, 31 Oct 2008 23:27:41 +0000 (17:27 -0600)
committerBrian Paul <brian.paul@tungstengraphics.com>
Fri, 31 Oct 2008 23:42:26 +0000 (17:42 -0600)
src/mesa/shader/slang/slang_compile_operation.c

index c0d469c8294d0bad310a4d6af33d2e5278190090..1002be16cb7124f5c84869b7f8e57697dab0a808 100644 (file)
@@ -84,6 +84,17 @@ slang_replace_scope(slang_operation *oper,
        oper->locals->outer_scope == oldScope) {
       oper->locals->outer_scope = newScope;
    }
+
+   if (oper->type == SLANG_OPER_VARIABLE_DECL) {
+      slang_variable *var;
+      var = _slang_locate_variable(oper->locals, oper->a_id, GL_TRUE);
+      if (var && var->initializer) {
+         printf("replace scope for %s initializer\n",
+                (char *) var->a_name);
+         slang_replace_scope(var->initializer, oldScope, newScope);
+      }
+   }
+
    for (i = 0; i < oper->num_children; i++) {
       slang_replace_scope(&oper->children[i], oldScope, newScope);
    }