X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;ds=sidebyside;f=source%2Fglsl%2Fsyntax.cpp;h=32a7b12c6639aebd69344aa7a2f6408c67de308f;hb=d8bdf61007978e2c3670a22a58e2f105e8347537;hp=469ce5a602c2f22a464a5896c003c5aa209d29ef;hpb=a4cd67f1c9f1f375bacacfbb421d40f78a22644b;p=libs%2Fgl.git diff --git a/source/glsl/syntax.cpp b/source/glsl/syntax.cpp index 469ce5a6..32a7b12c 100644 --- a/source/glsl/syntax.cpp +++ b/source/glsl/syntax.cpp @@ -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