]> git.tdb.fi Git - libs/gl.git/commitdiff
Merge variable declaration layouts
authorMikko Rasa <tdb@tdb.fi>
Fri, 21 Jun 2019 08:23:21 +0000 (11:23 +0300)
committerMikko Rasa <tdb@tdb.fi>
Fri, 21 Jun 2019 11:54:28 +0000 (14:54 +0300)
source/programcompiler.cpp

index 6b8d2eb8a6ae75bbd7d5ea74c7fe7bde4e4b39b6..9a3986a12b21e094824175bf0dc7b052dd2af776 100644 (file)
@@ -643,6 +643,27 @@ void ProgramCompiler::DeclarationCombiner::visit(VariableDeclaration &var)
                ptr->type = var.type;
                if(var.init_expression)
                        ptr->init_expression = var.init_expression;
+               if(var.layout)
+               {
+                       if(ptr->layout)
+                       {
+                               for(vector<Layout::Qualifier>::iterator i=var.layout->qualifiers.begin(); i!=var.layout->qualifiers.end(); ++i)
+                               {
+                                       bool found = false;
+                                       for(vector<Layout::Qualifier>::iterator j=ptr->layout->qualifiers.begin(); (!found && j!=ptr->layout->qualifiers.end()); ++j)
+                                               if(j->identifier==i->identifier)
+                                               {
+                                                       j->value = i->value;
+                                                       found = true;
+                                               }
+
+                                       if(!found)
+                                               ptr->layout->qualifiers.push_back(*i);
+                               }
+                       }
+                       else
+                               ptr->layout = var.layout;
+               }
                remove_node = true;
        }
        else