]> git.tdb.fi Git - libs/gl.git/commitdiff
Consider expressions in array sizes when comparing types for equality
authorMikko Rasa <tdb@tdb.fi>
Fri, 8 Oct 2021 07:14:22 +0000 (10:14 +0300)
committerMikko Rasa <tdb@tdb.fi>
Fri, 8 Oct 2021 07:14:22 +0000 (10:14 +0300)
source/glsl/reflect.cpp
source/glsl/reflect.h

index 82ad244c1d7083c1ad8b61e4c22fee69e25e7f2f..83af09a6f8b092bfb9cf3a76d949644ae5638793 100644 (file)
@@ -122,6 +122,49 @@ void TypeComparer::visit(VariableReference &var)
        }
 }
 
+void TypeComparer::visit(UnaryExpression &unary)
+{
+       if(UnaryExpression *unary1 = multi_visit(unary))
+       {
+               if(unary1->oper!=unary.oper)
+                       r_result = false;
+               else
+                       compare(*unary1->expression, *unary.expression);
+       }
+}
+
+void TypeComparer::visit(BinaryExpression &binary)
+{
+       if(BinaryExpression *binary1 = multi_visit(binary))
+       {
+               if(binary1->oper!=binary.oper)
+                       r_result = false;
+               else
+               {
+                       compare(*binary1->left, *binary.left);
+                       if(r_result)
+                               compare(*binary1->right, *binary.right);
+               }
+       }
+}
+
+void TypeComparer::visit(TernaryExpression &ternary)
+{
+       if(TernaryExpression *ternary1 = multi_visit(ternary))
+       {
+               if(ternary1->oper!=ternary.oper)
+                       r_result = false;
+               else
+               {
+                       compare(*ternary1->condition, *ternary.condition);
+                       if(r_result)
+                               compare(*ternary1->true_expr, *ternary.true_expr);
+                       if(r_result)
+                               compare(*ternary1->false_expr, *ternary.false_expr);
+               }
+       }
+}
+
 void TypeComparer::visit(BasicTypeDeclaration &basic)
 {
        if(BasicTypeDeclaration *basic1 = multi_visit(basic))
index 63dfe7bec53ed2e843d2f8857d8cb18b056a6fb2..6c00bca8de3d7f5f8dc3372dfd45cc8937b0568f 100644 (file)
@@ -34,6 +34,9 @@ private:
        T *multi_visit(T &);
        virtual void visit(Literal &);
        virtual void visit(VariableReference &);
+       virtual void visit(UnaryExpression &);
+       virtual void visit(BinaryExpression &);
+       virtual void visit(TernaryExpression &);
        virtual void visit(BasicTypeDeclaration &);
        virtual void visit(ImageTypeDeclaration &);
        virtual void visit(StructDeclaration &);