]> git.tdb.fi Git - libs/gl.git/blobdiff - source/glsl/syntax.cpp
Add a utility function for following a chain of base types
[libs/gl.git] / source / glsl / syntax.cpp
index 1489eb9e2af7e04ec542deb1c740efa6d8fc4d7f..40f6d4f660b24c84dff02a910951c71c87ad6c4e 100644 (file)
@@ -402,6 +402,19 @@ string get_unused_variable_name(const Block &block, const string &base)
        }
 }
 
+const TypeDeclaration *get_ultimate_base_type(const TypeDeclaration *type)
+{
+       if(!type)
+               return 0;
+       while(const BasicTypeDeclaration *basic = dynamic_cast<const BasicTypeDeclaration *>(type))
+       {
+               if(!basic->base_type)
+                       break;
+               type = basic->base_type;
+       }
+       return type;
+}
+
 int get_layout_value(const Layout &layout, const string &name, int def_value)
 {
        auto i = find_member(layout.qualifiers, name, &Layout::Qualifier::name);