summaryrefslogtreecommitdiff
path: root/src/mesa
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2008-11-01 15:55:39 -0600
committerBrian Paul <brian.paul@tungstengraphics.com>2008-11-01 16:03:03 -0600
commite9bc632d829f38e5b15c2cdbaaa61caffb02f8c8 (patch)
treefb27932af3cf780883a30a765547205b64393944 /src/mesa
parent58936b51af5806a5c260a30e961a37c77bdbdd17 (diff)
mesa: do scope replacement for while/for loops too
This fixes a function inlining bug involving vars declared inside loop bodies.
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/shader/slang/slang_compile_operation.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/mesa/shader/slang/slang_compile_operation.c b/src/mesa/shader/slang/slang_compile_operation.c
index 1002be16cb..53cf6faff9 100644
--- a/src/mesa/shader/slang/slang_compile_operation.c
+++ b/src/mesa/shader/slang/slang_compile_operation.c
@@ -80,21 +80,23 @@ slang_replace_scope(slang_operation *oper,
slang_variable_scope *newScope)
{
GLuint i;
+
if (oper->locals != newScope &&
oper->locals->outer_scope == oldScope) {
+ /* found. replace old w/ new */
oper->locals->outer_scope = newScope;
}
if (oper->type == SLANG_OPER_VARIABLE_DECL) {
+ /* search/replace in the initializer */
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);
}
}
+ /* search/replace in children */
for (i = 0; i < oper->num_children; i++) {
slang_replace_scope(&oper->children[i], oldScope, newScope);
}
@@ -159,7 +161,9 @@ slang_operation_copy(slang_operation * x, const slang_operation * y)
/* If this operation declares a new scope, we need to make sure
* all children point to it, not the original operation's scope!
*/
- if (x->type == SLANG_OPER_BLOCK_NEW_SCOPE) {
+ if (x->type == SLANG_OPER_BLOCK_NEW_SCOPE ||
+ x->type == SLANG_OPER_WHILE ||
+ x->type == SLANG_OPER_FOR) {
slang_replace_scope(x, y->locals, x->locals);
}