diff options
author | Brian Paul <brian.paul@tungstengraphics.com> | 2008-07-29 17:05:54 -0600 |
---|---|---|
committer | Brian Paul <brian.paul@tungstengraphics.com> | 2008-07-29 17:05:54 -0600 |
commit | 153407f72d3492f9d35e2424bb877def8b1a1dcd (patch) | |
tree | f9afee20c821990f07b4ecec487c0a5c013d4c26 /src/mesa/shader/slang/slang_compile_operation.c | |
parent | 527e1357b59a476348b5fd2600fb99e85cc4e897 (diff) |
mesa: fix some function inlining bugs
Need to add local vars of original function to the new scope's variable
list (though the DECLs were already present).
In slang_operation_copy() call slang_replace_scope() for SLANG_OPER_BLOCK_NEW_SCOPE opers.
Diffstat (limited to 'src/mesa/shader/slang/slang_compile_operation.c')
-rw-r--r-- | src/mesa/shader/slang/slang_compile_operation.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/mesa/shader/slang/slang_compile_operation.c b/src/mesa/shader/slang/slang_compile_operation.c index b18e08d2ae..4d2fd5b666 100644 --- a/src/mesa/shader/slang/slang_compile_operation.c +++ b/src/mesa/shader/slang/slang_compile_operation.c @@ -69,8 +69,31 @@ slang_operation_destruct(slang_operation * oper) oper->locals = NULL; } + +/** + * Recursively traverse 'oper', replacing occurances of 'oldScope' with + * 'newScope' in the oper->locals->outer_scope field. + */ +void +slang_replace_scope(slang_operation *oper, + slang_variable_scope *oldScope, + slang_variable_scope *newScope) +{ + GLuint i; + if (oper->locals != newScope && + oper->locals->outer_scope == oldScope) { + oper->locals->outer_scope = newScope; + } + for (i = 0; i < oper->num_children; i++) { + slang_replace_scope(&oper->children[i], oldScope, newScope); + } +} + + /** * Recursively copy a slang_operation node. + * \param x copy target + * \param y copy source * \return GL_TRUE for success, GL_FALSE if failure */ GLboolean @@ -121,6 +144,14 @@ slang_operation_copy(slang_operation * x, const slang_operation * y) #endif slang_operation_destruct(x); *x = z; + + /* 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) { + slang_replace_scope(x, y->locals, x->locals); + } + return GL_TRUE; } |