From 1d02efce746aa8b6e678a3bf56bfbbbe0aea6952 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Wed, 3 Mar 2021 17:13:22 +0200 Subject: [PATCH] Fix VariableResolver doing bogus things on certain invalid constructs --- source/glsl/generate.cpp | 19 ++++++++++++++++++- source/glsl/generate.h | 2 ++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/source/glsl/generate.cpp b/source/glsl/generate.cpp index 9adfb93d..ac3a4b75 100644 --- a/source/glsl/generate.cpp +++ b/source/glsl/generate.cpp @@ -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) diff --git a/source/glsl/generate.h b/source/glsl/generate.h index bcb70c04..f76c2c2d 100644 --- a/source/glsl/generate.h +++ b/source/glsl/generate.h @@ -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 &); -- 2.45.2