]> git.tdb.fi Git - libs/gl.git/blobdiff - source/glsl/syntax.cpp
Make variable renaming while inlining more robust
[libs/gl.git] / source / glsl / syntax.cpp
index cb50fee18b79538c126482594a023ea8f3864001..c94e2e27042c63a6a7f0b2c91f3d26c5b00f1e30 100644 (file)
@@ -472,8 +472,14 @@ string get_unused_variable_name(const Block &block, const string &base, const st
        bool prefixed = false;
        unsigned number = 1;
        unsigned size_without_number = name.size();
-       while(block.variables.count(name))
+       while(1)
        {
+               bool unused = true;
+               for(const Block *b=█ (unused && b); b=b->parent)
+                       unused = !b->variables.count(name);
+               if(unused)
+                       return name;
+
                if(!prefixed && !prefix_hint.empty())
                {
                        if(name.front()!='_')
@@ -491,8 +497,6 @@ string get_unused_variable_name(const Block &block, const string &base, const st
                        ++number;
                }
        }
-
-       return name;
 }
 
 } // namespace SL