]> git.tdb.fi Git - libs/gl.git/blobdiff - source/glsl/output.cpp
Minor, largely cosmetic tweaks
[libs/gl.git] / source / glsl / output.cpp
index 7d502739903a6cd8708cfc758aac470cad2fa17f..72af837958e77a712196b97cc9279258e8c08555 100644 (file)
@@ -82,6 +82,32 @@ void Formatter::set_source(unsigned index, unsigned line)
        source_line = line;
 }
 
+void Formatter::visit(Block &block)
+{
+       unsigned brace_indent = indent;
+       bool use_braces = (block.use_braces || (indent && block.body.size()!=1));
+       if(use_braces)
+               append(format("%s{\n", string(brace_indent*2, ' ')));
+
+       SetForScope<unsigned> set(indent, indent+(indent>0 || use_braces));
+       string spaces(indent*2, ' ');
+       bool first = true;
+       for(NodeList<Statement>::iterator i=block.body.begin(); i!=block.body.end(); ++i)
+       {
+               if((*i)->source==BUILTIN_SOURCE)
+                       continue;
+               if(!first)
+                       append('\n');
+               first = false;
+               set_source((*i)->source, (*i)->line);
+               append(spaces);
+               (*i)->visit(*this);
+       }
+
+       if(use_braces)
+               append(format("\n%s}", string(brace_indent*2, ' ')));
+}
+
 void Formatter::visit(Literal &literal)
 {
        append(literal.token);
@@ -153,32 +179,6 @@ void Formatter::visit(ExpressionStatement &expr)
        append(';');
 }
 
-void Formatter::visit(Block &block)
-{
-       unsigned brace_indent = indent;
-       bool use_braces = (block.use_braces || (indent && block.body.size()!=1));
-       if(use_braces)
-               append(format("%s{\n", string(brace_indent*2, ' ')));
-
-       SetForScope<unsigned> set(indent, indent+(indent>0 || use_braces));
-       string spaces(indent*2, ' ');
-       bool first = true;
-       for(NodeList<Statement>::iterator i=block.body.begin(); i!=block.body.end(); ++i)
-       {
-               if((*i)->source==BUILTIN_SOURCE)
-                       continue;
-               if(!first)
-                       append('\n');
-               first = false;
-               set_source((*i)->source, (*i)->line);
-               append(spaces);
-               (*i)->visit(*this);
-       }
-
-       if(use_braces)
-               append(format("\n%s}", string(brace_indent*2, ' ')));
-}
-
 void Formatter::visit(Import &import)
 {
        append(format("import %s;", import.module));