From: Mikko Rasa Date: Thu, 8 Apr 2021 21:52:06 +0000 (+0300) Subject: Visit the entire call graph in DependencyCollector X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=c72c4ebe384a0d5a48c268d09449707bd86090a8;p=libs%2Fgl.git Visit the entire call graph in DependencyCollector --- diff --git a/source/glsl/reflect.cpp b/source/glsl/reflect.cpp index e6355316..c38e3aec 100644 --- a/source/glsl/reflect.cpp +++ b/source/glsl/reflect.cpp @@ -279,7 +279,10 @@ void DependencyCollector::visit(InterfaceBlockReference &iface) void DependencyCollector::visit(FunctionCall &call) { if(call.declaration) + { dependencies.insert(call.declaration); + call.declaration->visit(*this); + } TraversingVisitor::visit(call); } @@ -295,6 +298,15 @@ void DependencyCollector::visit(VariableDeclaration &var) TraversingVisitor::visit(var); } +void DependencyCollector::visit(FunctionDeclaration &func) +{ + if(!visited_functions.count(&func)) + { + visited_functions.insert(&func); + TraversingVisitor::visit(func); + } +} + } // namespace SL } // namespace GL } // namespace Msp diff --git a/source/glsl/reflect.h b/source/glsl/reflect.h index 56ead82c..c2d7aa04 100644 --- a/source/glsl/reflect.h +++ b/source/glsl/reflect.h @@ -85,6 +85,7 @@ class DependencyCollector: private TraversingVisitor private: std::set dependencies; std::set locals; + std::set visited_functions; public: std::set apply(FunctionDeclaration &); @@ -94,6 +95,7 @@ private: virtual void visit(InterfaceBlockReference &); virtual void visit(FunctionCall &); virtual void visit(VariableDeclaration &); + virtual void visit(FunctionDeclaration &); }; } // namespace SL