From f6dfd3e78fc8c4c4a14619f3fdece53600ab0db7 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sun, 28 Feb 2021 13:16:23 +0200 Subject: [PATCH] Move function override processing to FunctionResolver --- source/glsl/generate.cpp | 24 +++++------------------- source/glsl/generate.h | 2 +- 2 files changed, 6 insertions(+), 20 deletions(-) diff --git a/source/glsl/generate.cpp b/source/glsl/generate.cpp index 09c5c37d..13b62aa3 100644 --- a/source/glsl/generate.cpp +++ b/source/glsl/generate.cpp @@ -24,20 +24,6 @@ void DeclarationCombiner::visit(Block &block) TraversingVisitor::visit(block); } -void DeclarationCombiner::visit(FunctionDeclaration &func) -{ - vector &decls = functions[func.name]; - if(func.definition) - { - for(vector::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 &decls = functions[func.name]; - if(func.definition) + if(func.definition==&func) { for(vector::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); } diff --git a/source/glsl/generate.h b/source/glsl/generate.h index b82bdca3..dc90b6eb 100644 --- a/source/glsl/generate.h +++ b/source/glsl/generate.h @@ -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 -- 2.45.2