]> git.tdb.fi Git - libs/gl.git/commitdiff
Rename imported interface variables in InterfaceGenerator
authorMikko Rasa <tdb@tdb.fi>
Sat, 14 Apr 2018 07:42:02 +0000 (10:42 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sat, 14 Apr 2018 07:51:58 +0000 (10:51 +0300)
Doing it as a separate pass caused trouble when a variable was accessed
both with passthrough and explicitly.  Two input variable declarations
were generated and only one of them was linked to the output variable of
the previous stage, leading to the output variable being removed.

source/programcompiler.cpp
source/programcompiler.h

index e102349a6482f0dc4a679ee325561210948dd52b..e03e64cd288708c8e476a56a9e921a3f5cbd3b59 100644 (file)
@@ -205,7 +205,6 @@ void ProgramCompiler::generate(Stage &stage)
        apply<VariableResolver>(stage);
        apply<InterfaceGenerator>(stage);
        apply<VariableResolver>(stage);
-       apply<VariableRenamer>(stage);
        apply<DeclarationReorderer>(stage);
        apply<LegacyConverter>(stage);
 }
@@ -876,7 +875,10 @@ void ProgramCompiler::InterfaceGenerator::visit(VariableReference &var)
        if(i==prev_out.end())
                i = prev_out.find(in_prefix+var.name);
        if(i!=prev_out.end())
-               generate_interface(*i->second, "in", var.name);
+       {
+               generate_interface(*i->second, "in", i->second->name);
+               var.name = i->second->name;
+       }
 }
 
 void ProgramCompiler::InterfaceGenerator::visit(VariableDeclaration &var)
@@ -978,20 +980,6 @@ void ProgramCompiler::InterfaceGenerator::visit(Passthrough &pass)
 }
 
 
-void ProgramCompiler::VariableRenamer::visit(VariableReference &var)
-{
-       if(var.declaration)
-               var.name = var.declaration->name;
-}
-
-void ProgramCompiler::VariableRenamer::visit(VariableDeclaration &var)
-{
-       if(var.linked_declaration)
-               var.name = var.linked_declaration->name;
-       TraversingVisitor::visit(var);
-}
-
-
 ProgramCompiler::DeclarationReorderer::DeclarationReorderer():
        kind(NO_DECLARATION)
 { }
index d7b8a8701ff0f8687cf871e59f000ba18c134ed2..be2afab6fdd4d5746c5605aa8c1e9e1ea9707146 100644 (file)
@@ -158,13 +158,6 @@ private:
                virtual void visit(ProgramSyntax::Passthrough &);
        };
 
-       struct VariableRenamer: Visitor
-       {
-               using Visitor::visit;
-               virtual void visit(ProgramSyntax::VariableReference &);
-               virtual void visit(ProgramSyntax::VariableDeclaration &);
-       };
-
        struct DeclarationReorderer: Visitor
        {
                enum DeclarationKind