X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fglsl%2Fsyntax.cpp;h=e7a3990e5c1478b3fcdf8e5727226b05ba688582;hb=22d5405729048ee2677a1e45e309e6328de64a26;hp=bbd364c0730d7cca157376ad34bbdbd028ec1581;hpb=911c6c4acc8218bc40d93917207f9dc32e9f2596;p=libs%2Fgl.git diff --git a/source/glsl/syntax.cpp b/source/glsl/syntax.cpp index bbd364c0..e7a3990e 100644 --- a/source/glsl/syntax.cpp +++ b/source/glsl/syntax.cpp @@ -105,12 +105,6 @@ void Literal::visit(NodeVisitor &visitor) } -void ParenthesizedExpression::visit(NodeVisitor &visitor) -{ - visitor.visit(*this); -} - - VariableReference::VariableReference(): declaration(0) { } @@ -470,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