]> git.tdb.fi Git - libs/gl.git/blobdiff - source/glsl/syntax.cpp
Rename InterfaceBlock::name to block_name for clarity
[libs/gl.git] / source / glsl / syntax.cpp
index 469ce5a602c2f22a464a5896c003c5aa209d29ef..32a7b12c6639aebd69344aa7a2f6408c67de308f 100644 (file)
@@ -369,7 +369,7 @@ InterfaceBlock::InterfaceBlock():
 InterfaceBlock::InterfaceBlock(const InterfaceBlock &other):
        Statement(other),
        interface(other.interface),
-       name(other.name),
+       block_name(other.block_name),
        members(other.members),
        instance_name(other.instance_name),
        array(other.array),
@@ -464,6 +464,27 @@ Module::Module():
        shared(Stage::SHARED)
 { }
 
+
+string get_unused_variable_name(const Block &block, const string &base)
+{
+       string name = base;
+
+       unsigned number = 1;
+       unsigned base_size = name.size();
+       while(1)
+       {
+               bool unused = true;
+               for(const Block *b=█ (unused && b); b=b->parent)
+                       unused = !b->variables.count(name);
+               if(unused)
+                       return name;
+
+               name.erase(base_size);
+               name += format("_%d", number);
+               ++number;
+       }
+}
+
 } // namespace SL
 } // namespace GL
 } // namespace Msp