]> git.tdb.fi Git - libs/gl.git/commitdiff
Fix VariableResolver doing bogus things on certain invalid constructs
authorMikko Rasa <tdb@tdb.fi>
Wed, 3 Mar 2021 15:13:22 +0000 (17:13 +0200)
committerMikko Rasa <tdb@tdb.fi>
Thu, 4 Mar 2021 00:26:15 +0000 (02:26 +0200)
source/glsl/generate.cpp
source/glsl/generate.h

index 9adfb93d5cbfab11984c6bcf5f5a6a8315f6d494..ac3a4b75e7f7f9d62aa3925f01be9d6eeb94f8c4 100644 (file)
@@ -228,6 +228,13 @@ void VariableResolver::visit(MemberAccess &memacc)
        }
 }
 
+void VariableResolver::visit(UnaryExpression &unary)
+{
+       TraversingVisitor::visit(unary);
+       r_members = 0;
+       r_iface_ref = 0;
+}
+
 void VariableResolver::visit(BinaryExpression &binary)
 {
        if(binary.oper->token[0]=='[')
@@ -241,13 +248,14 @@ void VariableResolver::visit(BinaryExpression &binary)
                binary.left->visit(*this);
                if(r_iface_ref)
                        binary.left = r_iface_ref;
-               r_iface_ref = 0;
        }
        else
        {
                TraversingVisitor::visit(binary);
                r_members = 0;
        }
+
+       r_iface_ref = 0;
 }
 
 void VariableResolver::visit(Assignment &assign)
@@ -263,6 +271,15 @@ void VariableResolver::visit(Assignment &assign)
 
        assign.self_referencing = (r_self_referencing || assign.oper->token[0]!='=');
        assign.target_declaration = r_assignment_target;
+       r_members = 0;
+       r_iface_ref = 0;
+}
+
+void VariableResolver::visit(FunctionCall &call)
+{
+       TraversingVisitor::visit(call);
+       r_members = 0;
+       r_iface_ref = 0;
 }
 
 void VariableResolver::visit(StructDeclaration &strct)
index bcb70c04c6da49c0df7dc294d37d38139bbd8fda..f76c2c2d8fba55d7231f95dfd487d20e897b3061 100644 (file)
@@ -78,8 +78,10 @@ private:
        virtual void visit(VariableReference &);
        virtual void visit(InterfaceBlockReference &);
        virtual void visit(MemberAccess &);
+       virtual void visit(UnaryExpression &);
        virtual void visit(BinaryExpression &);
        virtual void visit(Assignment &);
+       virtual void visit(FunctionCall &);
        virtual void visit(StructDeclaration &);
        virtual void visit(VariableDeclaration &);
        virtual void visit(InterfaceBlock &);