]> git.tdb.fi Git - libs/gl.git/blobdiff - source/glsl/reflect.h
Rewrite type comparisons as a visitor
[libs/gl.git] / source / glsl / reflect.h
index 162ed9c0b8bcf4ddb01daf17724e4308138decd0..9520feb6a924c797ee50b7e8a062dbd7b1f74795 100644 (file)
@@ -7,6 +7,32 @@ namespace Msp {
 namespace GL {
 namespace SL {
 
+/** Compares two types for equality.  Struct types are compared recursively. */
+class TypeComparer: private NodeVisitor
+{
+private:
+       Node *first;
+       Node *second;
+       unsigned first_tag;
+       bool r_result;
+
+       static unsigned next_tag;
+
+public:
+       TypeComparer();
+
+       bool apply(TypeDeclaration &t1, TypeDeclaration &t2) { compare(t1, t2); return r_result; }
+
+private:
+       void compare(Node &, Node &);
+       template<typename T>
+       T *multi_visit(T &);
+       virtual void visit(BasicTypeDeclaration &);
+       virtual void visit(ImageTypeDeclaration &);
+       virtual void visit(StructDeclaration &);
+       virtual void visit(VariableDeclaration &);
+};
+
 /** Determines the number of interface locations required by a variable. */
 class LocationCounter: private NodeVisitor
 {