summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2008-12-12 16:20:31 -0700
committerBrian Paul <brianp@vmware.com>2009-01-06 09:11:52 -0700
commite153275ae80e04de2fbc33313327a4a7cc754649 (patch)
treecaf581de692f7086206faf9ac29ddd59fba8845e
parent70050191ed39bab72b90ec891c413669d0f5a33f (diff)
mesa: code clean-up in glsl compiler
(cherry picked from commit d4be09fb2b4a2a45a95a388f536aee566e05f96a)
-rw-r--r--src/mesa/shader/slang/slang_codegen.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/mesa/shader/slang/slang_codegen.c b/src/mesa/shader/slang/slang_codegen.c
index d0e6b6cc5e..5da0614243 100644
--- a/src/mesa/shader/slang/slang_codegen.c
+++ b/src/mesa/shader/slang/slang_codegen.c
@@ -2709,12 +2709,6 @@ _slang_gen_var_decl(slang_assemble_ctx *A, slang_variable *var,
const char *varName = (const char *) var->a_name;
slang_ir_node *varRef, *init;
- varRef = new_var(A, var);
- if (!varRef) {
- slang_info_log_error(A->log, "undefined variable '%s'", varName);
- return NULL;
- }
-
if (var->type.qualifier == SLANG_QUAL_CONST) {
/* if the variable is const, the initializer must be a const
* expression as well.
@@ -2731,11 +2725,17 @@ _slang_gen_var_decl(slang_assemble_ctx *A, slang_variable *var,
/* constant-folding, etc here */
_slang_simplify(initializer, &A->space, A->atoms);
+ /* IR for initializer */
init = _slang_gen_operation(A, initializer);
if (!init)
return NULL;
- /*assert(init->Store);*/
+ /* IR for the variable we're initializing */
+ varRef = new_var(A, var);
+ if (!varRef) {
+ slang_info_log_error(A->log, "undefined variable '%s'", varName);
+ return NULL;
+ }
/* XXX remove this when type checking is added above */
if (init->Store && varRef->Store->Size != init->Store->Size) {
@@ -2743,6 +2743,7 @@ _slang_gen_var_decl(slang_assemble_ctx *A, slang_variable *var,
return NULL;
}
+ /* assign RHS to LHS */
n = new_node2(IR_COPY, varRef, init);
n = new_seq(varDecl, n);
}