From: Mikko Rasa Date: Tue, 23 Feb 2021 21:35:59 +0000 (+0200) Subject: Remove the using declarations from visitors X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=5c33b56c3b97ca0381ac216a603c7553f4bea499;p=libs%2Fgl.git Remove the using declarations from visitors Instead always invoke visit through the node --- diff --git a/source/glsl/compatibility.cpp b/source/glsl/compatibility.cpp index a65f6de7..128902f3 100644 --- a/source/glsl/compatibility.cpp +++ b/source/glsl/compatibility.cpp @@ -17,7 +17,7 @@ DefaultPrecisionGenerator::DefaultPrecisionGenerator(): void DefaultPrecisionGenerator::apply(Stage &s) { stage = &s; - visit(s.content); + s.content.visit(*this); } void DefaultPrecisionGenerator::visit(Block &block) @@ -65,7 +65,7 @@ void DefaultPrecisionGenerator::visit(VariableDeclaration &var) void PrecisionRemover::apply(Stage &stage) { - visit(stage.content); + stage.content.visit(*this); NodeRemover().apply(stage, nodes_to_remove); } @@ -90,7 +90,7 @@ void LegacyConverter::apply(Stage &s, const Features &feat) features = feat; if(!supports_stage(s.type)) throw unsupported_shader(format("Stage %s is not supported", Stage::get_stage_name(s.type))); - visit(s.content); + s.content.visit(*this); } void LegacyConverter::visit(Block &block) diff --git a/source/glsl/compatibility.h b/source/glsl/compatibility.h index f91f1882..852a6590 100644 --- a/source/glsl/compatibility.h +++ b/source/glsl/compatibility.h @@ -24,7 +24,6 @@ private: virtual void visit(Block &); virtual void visit(Precision &); virtual void visit(VariableDeclaration &); - using TraversingVisitor::visit; }; class PrecisionRemover: private TraversingVisitor @@ -38,7 +37,6 @@ public: private: virtual void visit(Precision &); virtual void visit(VariableDeclaration &); - using TraversingVisitor::visit; }; class LegacyConverter: private TraversingVisitor @@ -72,7 +70,6 @@ private: virtual void visit(VariableDeclaration &); bool supports_interface_blocks(const std::string &) const; virtual void visit(InterfaceBlock &); - using TraversingVisitor::visit; }; } // namespace SL diff --git a/source/glsl/debug.cpp b/source/glsl/debug.cpp index 6bf6eef9..32eb0ec3 100644 --- a/source/glsl/debug.cpp +++ b/source/glsl/debug.cpp @@ -17,7 +17,7 @@ const std::string &DumpTree::apply(Stage &stage) for(map::const_iterator i=stage.out_variables.begin(); i!=stage.out_variables.end(); ++i) append(format("Output: %%%d %s %s", get_label(*i->second), i->second->type, i->first)); last_branch(); - visit(stage.content); + stage.content.visit(*this); return formatted; } diff --git a/source/glsl/debug.h b/source/glsl/debug.h index 5bc7a8bf..66f2b067 100644 --- a/source/glsl/debug.h +++ b/source/glsl/debug.h @@ -61,7 +61,6 @@ private: virtual void visit(Passthrough &); virtual void visit(Return &); virtual void visit(Jump &); - using TraversingVisitor::visit; }; } // namespace SL diff --git a/source/glsl/generate.cpp b/source/glsl/generate.cpp index d435d29a..ca4d41e6 100644 --- a/source/glsl/generate.cpp +++ b/source/glsl/generate.cpp @@ -10,7 +10,7 @@ namespace SL { void DeclarationCombiner::apply(Stage &stage) { - visit(stage.content); + stage.content.visit(*this); NodeRemover().apply(stage, nodes_to_remove); } @@ -96,7 +96,7 @@ void VariableResolver::apply(Stage &stage) { Stage *builtin_stage = get_builtins(stage.type); builtins = (builtin_stage ? &builtin_stage->content : 0); - visit(stage.content); + stage.content.visit(*this); } Block *VariableResolver::next_block(Block &block) @@ -285,7 +285,7 @@ void InterfaceGenerator::apply(Stage &s) if(stage->previous) in_prefix = get_out_prefix(stage->previous->type); out_prefix = get_out_prefix(stage->type); - visit(s.content); + s.content.visit(*this); NodeRemover().apply(s, nodes_to_remove); } diff --git a/source/glsl/generate.h b/source/glsl/generate.h index 511a4607..6740f38e 100644 --- a/source/glsl/generate.h +++ b/source/glsl/generate.h @@ -25,18 +25,16 @@ private: virtual void visit(Block &); virtual void visit(FunctionDeclaration &); virtual void visit(VariableDeclaration &); - using TraversingVisitor::visit; }; class BlockResolver: private TraversingVisitor { public: - void apply(Stage &s) { visit(s.content); } + void apply(Stage &s) { s.content.visit(*this); } private: virtual void visit(Block &); virtual void visit(InterfaceBlock &); - using TraversingVisitor::visit; }; class VariableResolver: private TraversingVisitor @@ -67,7 +65,6 @@ private: virtual void visit(InterfaceBlock &); virtual void visit(FunctionDeclaration &); virtual void visit(Iteration &); - using TraversingVisitor::visit; }; class FunctionResolver: private TraversingVisitor @@ -76,12 +73,11 @@ private: std::map > functions; public: - void apply(Stage &s) { visit(s.content); } + void apply(Stage &s) { s.content.visit(*this); } private: virtual void visit(FunctionCall &); virtual void visit(FunctionDeclaration &); - using TraversingVisitor::visit; }; class InterfaceGenerator: private TraversingVisitor @@ -108,7 +104,6 @@ private: virtual void visit(VariableReference &); virtual void visit(VariableDeclaration &); virtual void visit(Passthrough &); - using TraversingVisitor::visit; }; class DeclarationReorderer: private TraversingVisitor @@ -130,7 +125,7 @@ private: public: DeclarationReorderer(); - void apply(Stage &s) { visit(s.content); } + void apply(Stage &s) { s.content.visit(*this); } private: virtual void visit(Block &); @@ -140,7 +135,6 @@ private: virtual void visit(VariableDeclaration &); virtual void visit(InterfaceBlock &) { kind = VARIABLE; } virtual void visit(FunctionDeclaration &); - using TraversingVisitor::visit; }; } // namespace SL diff --git a/source/glsl/optimize.cpp b/source/glsl/optimize.cpp index 4f1f8629..1f5b5d31 100644 --- a/source/glsl/optimize.cpp +++ b/source/glsl/optimize.cpp @@ -46,7 +46,7 @@ FunctionInliner::FunctionInliner(): void FunctionInliner::apply(Stage &stage) { inlineable = InlineableFunctionLocator().apply(stage); - visit(stage.content); + stage.content.visit(*this); } void FunctionInliner::visit_and_inline(RefPtr &ptr) @@ -129,7 +129,7 @@ ConstantConditionEliminator::ConstantConditionEliminator(): void ConstantConditionEliminator::apply(Stage &stage) { - visit(stage.content); + stage.content.visit(*this); NodeRemover().apply(stage, nodes_to_remove); } @@ -231,7 +231,7 @@ UnusedVariableRemover::UnusedVariableRemover(): bool UnusedVariableRemover::apply(Stage &stage) { variables.push_back(BlockVariableMap()); - visit(stage.content); + stage.content.visit(*this); BlockVariableMap &global_variables = variables.back(); for(BlockVariableMap::iterator i=global_variables.begin(); i!=global_variables.end(); ++i) { @@ -444,7 +444,7 @@ void UnusedVariableRemover::visit(Iteration &iter) bool UnusedFunctionRemover::apply(Stage &stage) { - visit(stage.content); + stage.content.visit(*this); NodeRemover().apply(stage, unused_nodes); return !unused_nodes.empty(); } diff --git a/source/glsl/optimize.h b/source/glsl/optimize.h index 2caa498d..c412433e 100644 --- a/source/glsl/optimize.h +++ b/source/glsl/optimize.h @@ -20,12 +20,11 @@ private: public: InlineableFunctionLocator(); - const std::set &apply(Stage &s) { visit(s.content); return inlineable; } + const std::set &apply(Stage &s) { s.content.visit(*this); return inlineable; } private: virtual void visit(FunctionCall &); virtual void visit(FunctionDeclaration &); - using TraversingVisitor::visit; }; class FunctionInliner: private TraversingVisitor @@ -50,7 +49,6 @@ private: virtual void visit(FunctionCall &); virtual void visit(VariableDeclaration &); virtual void visit(Return &); - using TraversingVisitor::visit; }; class ConstantConditionEliminator: private TraversingVisitor @@ -73,7 +71,6 @@ private: virtual void visit(VariableDeclaration &); virtual void visit(Conditional &); virtual void visit(Iteration &); - using TraversingVisitor::visit; }; class UnusedVariableRemover: private TraversingVisitor @@ -119,7 +116,6 @@ private: void merge_down_variables(); virtual void visit(Conditional &); virtual void visit(Iteration &); - using TraversingVisitor::visit; }; class UnusedFunctionRemover: private TraversingVisitor @@ -134,7 +130,6 @@ public: private: virtual void visit(FunctionCall &); virtual void visit(FunctionDeclaration &); - using TraversingVisitor::visit; }; } // namespace SL diff --git a/source/glsl/output.cpp b/source/glsl/output.cpp index 46314588..ef7910f1 100644 --- a/source/glsl/output.cpp +++ b/source/glsl/output.cpp @@ -44,7 +44,7 @@ const string &Formatter::apply(Stage &s, Compiler::Mode m) append("#extension ext_texture_array: require\n"); formatted += '\n'; - visit(s.content); + s.content.visit(*this); return formatted; } diff --git a/source/glsl/output.h b/source/glsl/output.h index e09f7c2e..b8554b7d 100644 --- a/source/glsl/output.h +++ b/source/glsl/output.h @@ -55,7 +55,6 @@ private: virtual void visit(Passthrough &); virtual void visit(Return &); virtual void visit(Jump &); - using TraversingVisitor::visit; }; } // namespace SL diff --git a/source/glsl/visitor.cpp b/source/glsl/visitor.cpp index 265b11d4..1a7adcc5 100644 --- a/source/glsl/visitor.cpp +++ b/source/glsl/visitor.cpp @@ -126,7 +126,7 @@ void NodeRemover::apply(Stage &s, const set &tr) { stage = &s; to_remove = &tr; - visit(s.content); + s.content.visit(*this); } void NodeRemover::remove_variable(map &vars, VariableDeclaration &decl) diff --git a/source/glsl/visitor.h b/source/glsl/visitor.h index 35dce524..ba345c45 100644 --- a/source/glsl/visitor.h +++ b/source/glsl/visitor.h @@ -49,7 +49,6 @@ protected: TraversingVisitor(): current_block(0) { } public: - using NodeVisitor::visit; virtual void visit(Block &); virtual void visit(ParenthesizedExpression &); virtual void visit(MemberAccess &); @@ -75,10 +74,9 @@ private: std::vector nodes; public: - const std::vector &apply(Stage &s) { nodes.clear(); visit(s.content); return nodes; } + const std::vector &apply(Stage &s) { s.content.visit(*this); return nodes; } private: - using TraversingVisitor::visit; virtual void visit(T &n) { nodes.push_back(&n); } }; @@ -99,7 +97,6 @@ public: private: void remove_variable(std::map &, VariableDeclaration &); - using TraversingVisitor::visit; virtual void visit(Block &); virtual void visit(StructDeclaration &); virtual void visit(VariableDeclaration &);