From 6fe1876a3040cc78ba4713194abf6d121f419458 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sat, 14 Apr 2018 10:42:02 +0300 Subject: [PATCH] Rename imported interface variables in InterfaceGenerator 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 | 20 ++++---------------- source/programcompiler.h | 7 ------- 2 files changed, 4 insertions(+), 23 deletions(-) diff --git a/source/programcompiler.cpp b/source/programcompiler.cpp index e102349a..e03e64cd 100644 --- a/source/programcompiler.cpp +++ b/source/programcompiler.cpp @@ -205,7 +205,6 @@ void ProgramCompiler::generate(Stage &stage) apply(stage); apply(stage); apply(stage); - apply(stage); apply(stage); apply(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) { } diff --git a/source/programcompiler.h b/source/programcompiler.h index d7b8a870..be2afab6 100644 --- a/source/programcompiler.h +++ b/source/programcompiler.h @@ -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 -- 2.45.2