From: Mikko Rasa Date: Mon, 8 Mar 2021 11:49:03 +0000 (+0200) Subject: Remove the NodeGatherer visitor X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=cd01b904990d306eadd120f306b1d0ceb4d8f5c8;p=libs%2Fgl.git Remove the NodeGatherer visitor It was somewhat poorly thought out since it's unable to gather nodes of a base class type. --- diff --git a/source/glsl/compiler.cpp b/source/glsl/compiler.cpp index 7dbb501c..ac014a00 100644 --- a/source/glsl/compiler.cpp +++ b/source/glsl/compiler.cpp @@ -174,7 +174,10 @@ void Compiler::append_module(Module &mod, DataFile::Collection *res) { module->source_map.merge_from(mod.source_map); - vector imports = NodeGatherer().apply(mod.shared); + vector imports; + for(NodeList::const_iterator i=mod.shared.content.body.begin(); i!=mod.shared.content.body.end(); ++i) + if(Import *imp = dynamic_cast(i->get())) + imports.push_back(imp); for(vector::iterator i=imports.begin(); i!=imports.end(); ++i) import(res, (*i)->module); NodeRemover().apply(mod.shared, set(imports.begin(), imports.end())); diff --git a/source/glsl/visitor.h b/source/glsl/visitor.h index 6fe1868c..30b9b484 100644 --- a/source/glsl/visitor.h +++ b/source/glsl/visitor.h @@ -74,20 +74,6 @@ public: virtual void visit(Return &); }; -/** Gathers nodes of a particular type from the syntax tree. */ -template -class NodeGatherer: private TraversingVisitor -{ -private: - std::vector nodes; - -public: - const std::vector &apply(Stage &s) { s.content.visit(*this); return nodes; } - -private: - virtual void visit(T &n) { nodes.push_back(&n); } -}; - /** Removes a set of nodes from the syntax tree. */ class NodeRemover: private TraversingVisitor {