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.
apply<VariableResolver>(stage);
apply<InterfaceGenerator>(stage);
apply<VariableResolver>(stage);
apply<VariableResolver>(stage);
apply<InterfaceGenerator>(stage);
apply<VariableResolver>(stage);
- apply<VariableRenamer>(stage);
apply<DeclarationReorderer>(stage);
apply<LegacyConverter>(stage);
}
apply<DeclarationReorderer>(stage);
apply<LegacyConverter>(stage);
}
if(i==prev_out.end())
i = prev_out.find(in_prefix+var.name);
if(i!=prev_out.end())
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)
}
void ProgramCompiler::InterfaceGenerator::visit(VariableDeclaration &var)
-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)
{ }
ProgramCompiler::DeclarationReorderer::DeclarationReorderer():
kind(NO_DECLARATION)
{ }
virtual void visit(ProgramSyntax::Passthrough &);
};
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
struct DeclarationReorderer: Visitor
{
enum DeclarationKind