]> git.tdb.fi Git - libs/gl.git/commitdiff
Move function override processing to FunctionResolver
authorMikko Rasa <tdb@tdb.fi>
Sun, 28 Feb 2021 11:16:23 +0000 (13:16 +0200)
committerMikko Rasa <tdb@tdb.fi>
Sun, 28 Feb 2021 19:41:54 +0000 (21:41 +0200)
source/glsl/generate.cpp
source/glsl/generate.h

index 09c5c37d3fa2c21fbf6afde8a594e04d1ecfa5f7..13b62aa32296a3d6c93c851827387205c08bfed1 100644 (file)
@@ -24,20 +24,6 @@ void DeclarationCombiner::visit(Block &block)
        TraversingVisitor::visit(block);
 }
 
-void DeclarationCombiner::visit(FunctionDeclaration &func)
-{
-       vector<FunctionDeclaration *> &decls = functions[func.name];
-       if(func.definition)
-       {
-               for(vector<FunctionDeclaration *>::iterator i=decls.begin(); i!=decls.end(); ++i)
-               {
-                       (*i)->definition = func.definition;
-                       (*i)->body.body.clear();
-               }
-       }
-       decls.push_back(&func);
-}
-
 void DeclarationCombiner::visit(VariableDeclaration &var)
 {
        VariableDeclaration *&ptr = variables[var.name];
@@ -335,17 +321,17 @@ void FunctionResolver::visit(FunctionCall &call)
 void FunctionResolver::visit(FunctionDeclaration &func)
 {
        vector<FunctionDeclaration *> &decls = functions[func.name];
-       if(func.definition)
+       if(func.definition==&func)
        {
                for(vector<FunctionDeclaration *>::iterator i=decls.begin(); i!=decls.end(); ++i)
+               {
                        (*i)->definition = func.definition;
-               decls.clear();
-               decls.push_back(&func);
+                       (*i)->body.body.clear();
+               }
        }
        else if(!decls.empty() && decls.back()->definition)
                func.definition = decls.back()->definition;
-       else
-               decls.push_back(&func);
+       decls.push_back(&func);
 
        TraversingVisitor::visit(func);
 }
index b82bdca365bc02e7fd856c86f5011eb124517f92..dc90b6eb5d36dc9b363ff0acbd01ba364c3f6a00 100644 (file)
@@ -24,8 +24,8 @@ public:
 
 private:
        virtual void visit(Block &);
-       virtual void visit(FunctionDeclaration &);
        virtual void visit(VariableDeclaration &);
+       virtual void visit(FunctionDeclaration &) { }
 };
 
 /** Manipulates specialization constants.  If values are specified, turns