]> git.tdb.fi Git - libs/gl.git/blobdiff - source/glsl/generate.cpp
Refactor the way of applying visitors to stages
[libs/gl.git] / source / glsl / generate.cpp
index 69a8dfb16d1eb62cccfbbba342418c0868bff69a..f3c57a2f0f9190352860bc5f7bc22ff634433123 100644 (file)
@@ -78,13 +78,12 @@ VariableResolver::VariableResolver():
        self_referencing(false)
 { }
 
-void VariableResolver::apply(Stage &s)
+void VariableResolver::apply(Stage &stage)
 {
-       SetForScope<Stage *> set(stage, &s);
-       Stage *builtins = get_builtins(stage->type);
+       Stage *builtins = get_builtins(stage.type);
        if(builtins)
                blocks.push_back(&builtins->content);
-       stage->content.visit(*this);
+       visit(stage.content);
        if(builtins)
                blocks.pop_back();
 }
@@ -240,6 +239,7 @@ void FunctionResolver::visit(FunctionDeclaration &func)
 
 
 InterfaceGenerator::InterfaceGenerator():
+       stage(0),
        scope_level(0)
 { }
 
@@ -259,7 +259,7 @@ void InterfaceGenerator::apply(Stage &s)
        if(stage->previous)
                in_prefix = get_out_prefix(stage->previous->type);
        out_prefix = get_out_prefix(stage->type);
-       stage->content.visit(*this);
+       visit(s.content);
 }
 
 void InterfaceGenerator::visit(Block &block)
@@ -471,7 +471,7 @@ void DeclarationReorderer::visit(Block &block)
 {
        SetForScope<unsigned> set(scope_level, scope_level+1);
        if(scope_level>1)
-               return StageVisitor::visit(block);
+               return TraversingVisitor::visit(block);
 
        NodeList<Statement>::iterator struct_insert_point = block.body.end();
        NodeList<Statement>::iterator variable_insert_point = block.body.end();
@@ -547,7 +547,7 @@ void DeclarationReorderer::visit(Block &block)
 
 void DeclarationReorderer::visit(VariableDeclaration &var)
 {
-       StageVisitor::visit(var);
+       TraversingVisitor::visit(var);
        kind = VARIABLE;
 }