]> git.tdb.fi Git - libs/gl.git/commitdiff
Visit the entire call graph in DependencyCollector
authorMikko Rasa <tdb@tdb.fi>
Thu, 8 Apr 2021 21:52:06 +0000 (00:52 +0300)
committerMikko Rasa <tdb@tdb.fi>
Fri, 9 Apr 2021 14:45:42 +0000 (17:45 +0300)
source/glsl/reflect.cpp
source/glsl/reflect.h

index e63553163c8435f23e2199effa17cc91eb5e52ee..c38e3aecbb3d487c6c7c2f10f510b6495092e872 100644 (file)
@@ -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
index 56ead82ceface5a35fc72af0a2f2b60ae874efc0..c2d7aa0483bd36e4411a55c2d5325158dfae1b92 100644 (file)
@@ -85,6 +85,7 @@ class DependencyCollector: private TraversingVisitor
 private:
        std::set<Node *> dependencies;
        std::set<Node *> locals;
+       std::set<FunctionDeclaration *> visited_functions;
 
 public:
        std::set<Node *> 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