From: Mikko Rasa Date: Fri, 8 Oct 2021 07:14:22 +0000 (+0300) Subject: Consider expressions in array sizes when comparing types for equality X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=3f245515062d10e4d527827e5126fe412de06ce0;p=libs%2Fgl.git Consider expressions in array sizes when comparing types for equality --- diff --git a/source/glsl/reflect.cpp b/source/glsl/reflect.cpp index 82ad244c..83af09a6 100644 --- a/source/glsl/reflect.cpp +++ b/source/glsl/reflect.cpp @@ -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)) diff --git a/source/glsl/reflect.h b/source/glsl/reflect.h index 63dfe7be..6c00bca8 100644 --- a/source/glsl/reflect.h +++ b/source/glsl/reflect.h @@ -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 &);