]> git.tdb.fi Git - libs/gl.git/commitdiff
Properly use r_any_resolved in FunctionResolver
authorMikko Rasa <tdb@tdb.fi>
Tue, 9 Mar 2021 12:31:22 +0000 (14:31 +0200)
committerMikko Rasa <tdb@tdb.fi>
Tue, 9 Mar 2021 12:31:22 +0000 (14:31 +0200)
Apparently lacking this has not caused any trouble so far, but it would
soon.

source/glsl/generate.cpp

index 1f229991f7b2427e45b7fe511099dd2a894774c5..113b4324aa2b64432b41cf7be63ff13ca30ed8c4 100644 (file)
@@ -917,8 +917,9 @@ bool FunctionResolver::apply(Stage &s)
 void FunctionResolver::visit(FunctionCall &call)
 {
        map<string, FunctionDeclaration *>::iterator i = stage->functions.find(call.name);
-       if(i!=stage->functions.end())
-               call.declaration = i->second;
+       FunctionDeclaration *declaration = (i!=stage->functions.end() ? i->second : 0);
+       r_any_resolved |= (declaration!=call.declaration);
+       call.declaration = declaration;
 
        TraversingVisitor::visit(call);
 }
@@ -934,17 +935,19 @@ void FunctionResolver::visit(FunctionDeclaration &func)
                // Set all previous declarations to use this definition.
                for(vector<FunctionDeclaration *>::iterator i=decls.begin(); i!=decls.end(); ++i)
                {
+                       r_any_resolved |= (func.definition!=(*i)->definition);
                        (*i)->definition = func.definition;
                        (*i)->body.body.clear();
                }
        }
        else
        {
-               func.definition = 0;
+               FunctionDeclaration *definition = (stage_decl ? stage_decl->definition : 0);
+               r_any_resolved |= (definition!=func.definition);
+               func.definition = definition;
+
                if(!stage_decl)
                        stage_decl = &func;
-               else
-                       func.definition = stage_decl->definition;
        }
        decls.push_back(&func);