diff options
author | Brian <[email protected]> | 2007-01-17 09:54:31 -0700 |
---|---|---|
committer | Brian <[email protected]> | 2007-01-17 09:54:31 -0700 |
commit | 811f54fa75a557380b34ac97929eaa0190d2d5aa (patch) | |
tree | 6241ff5addff4e0d5e92a9808c232ffa7f4ec9fa /src/mesa/shader/slang/slang_vartable.c | |
parent | 552a65e4546bd543d60ffe87dc298a41d8a318be (diff) |
Fix/clean-up a number of things related to variable/temporary allocation.
Diffstat (limited to 'src/mesa/shader/slang/slang_vartable.c')
-rw-r--r-- | src/mesa/shader/slang/slang_vartable.c | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/src/mesa/shader/slang/slang_vartable.c b/src/mesa/shader/slang/slang_vartable.c index cd6a081e04b..d4ec848a0a1 100644 --- a/src/mesa/shader/slang/slang_vartable.c +++ b/src/mesa/shader/slang/slang_vartable.c @@ -3,6 +3,7 @@ #include "slang_compile.h" #include "slang_compile_variable.h" #include "slang_vartable.h" +#include "slang_ir.h" static int dbg = 0; @@ -58,16 +59,28 @@ _slang_pop_var_table(slang_var_table *t) { slang_var_table *parent = t->parent; int i; + if (dbg) printf("Popping level %d\n", t->level); + + /* free the storage allocated for each variable */ + for (i = 0; i < t->num_entries; i++) { + slang_ir_storage *store = (slang_ir_storage *) t->vars[i]->aux; + if (dbg) printf(" Free var %s\n", (char*) t->vars[i]->a_name); + assert(t->temps[store->Index] == VAR); + t->temps[store->Index] = FREE; + store->Index = -1; + } if (t->parent) { + /* just verify that any remaining allocations in this scope + * were for temps + */ for (i = 0; i < MAX_PROGRAM_TEMPS; i++) { - if (t->temps[i] && !t->parent->temps[i]) + if (t->temps[i] && !t->parent->temps[i]) { if (dbg) printf(" Free reg %d\n", i); + assert(t->temps[i] == TEMP); + } } } - for (i = 0; i < t->num_entries; i++) { - if (dbg) printf(" Free var %s\n", (char*) t->vars[i]->a_name); - } if (t->vars) free(t->vars); @@ -84,6 +97,7 @@ void _slang_add_variable(slang_var_table *t, slang_variable *v) { assert(t); + if (dbg) printf("Adding var %s\n", (char *) v->a_name); t->vars = realloc(t->vars, (t->num_entries + 1) * sizeof(slang_variable *)); t->vars[t->num_entries] = v; t->num_entries++; |