From fdf2d162b21f55ad60bfeec2ad98c58356a083c0 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Mon, 5 Apr 2021 16:44:16 +0300 Subject: [PATCH] Refactor add_to_chain as a common utility function --- source/glsl/resolve.cpp | 13 +++---------- source/glsl/resolve.h | 1 - source/glsl/syntax.cpp | 7 +++++++ source/glsl/syntax.h | 1 + 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/source/glsl/resolve.cpp b/source/glsl/resolve.cpp index c5a507a2..bf32326f 100644 --- a/source/glsl/resolve.cpp +++ b/source/glsl/resolve.cpp @@ -281,13 +281,6 @@ void VariableResolver::visit(InterfaceBlockReference &iface) check_assignment_target(iface.declaration); } -void VariableResolver::add_to_chain(Assignment::Target::ChainType type, unsigned index) -{ - if(r_assignment_target.chain_len<7) - r_assignment_target.chain[r_assignment_target.chain_len] = type | min(index, 0x3F); - ++r_assignment_target.chain_len; -} - void VariableResolver::visit(MemberAccess &memacc) { TraversingVisitor::visit(memacc); @@ -304,7 +297,7 @@ void VariableResolver::visit(MemberAccess &memacc) ++index; if(record_target) - add_to_chain(Assignment::Target::MEMBER, index); + add_to_chain(r_assignment_target, Assignment::Target::MEMBER, index); } } else if(BasicTypeDeclaration *basic = dynamic_cast(memacc.left->type)) @@ -349,7 +342,7 @@ void VariableResolver::visit(Swizzle &swizzle) unsigned mask = 0; for(unsigned i=0; i(binary.right.get())) if(literal_subscript->value.check_type()) index = literal_subscript->value.value(); - add_to_chain(Assignment::Target::ARRAY, index); + add_to_chain(r_assignment_target, Assignment::Target::ARRAY, index); } } else diff --git a/source/glsl/resolve.h b/source/glsl/resolve.h index bbd2d620..9e1d4f51 100644 --- a/source/glsl/resolve.h +++ b/source/glsl/resolve.h @@ -79,7 +79,6 @@ private: void check_assignment_target(Statement *); virtual void visit(VariableReference &); virtual void visit(InterfaceBlockReference &); - void add_to_chain(Assignment::Target::ChainType, unsigned); virtual void visit(MemberAccess &); virtual void visit(Swizzle &); virtual void visit(BinaryExpression &); diff --git a/source/glsl/syntax.cpp b/source/glsl/syntax.cpp index c54a8297..b2247632 100644 --- a/source/glsl/syntax.cpp +++ b/source/glsl/syntax.cpp @@ -555,6 +555,13 @@ int get_layout_value(const Layout &layout, const string &name, int def_value) return def_value; } +void add_to_chain(Assignment::Target &target, Assignment::Target::ChainType type, unsigned index) +{ + if(target.chain_len<7) + target.chain[target.chain_len] = type | min(index, 0x3F); + ++target.chain_len; +} + } // namespace SL } // namespace GL } // namespace Msp diff --git a/source/glsl/syntax.h b/source/glsl/syntax.h index 66fed6e8..3518cb4c 100644 --- a/source/glsl/syntax.h +++ b/source/glsl/syntax.h @@ -558,6 +558,7 @@ std::string get_unused_variable_name(const Block &, const std::string &); bool is_same_type(const TypeDeclaration &, const TypeDeclaration &); int get_layout_value(const Layout &, const std::string &, int = -1); +void add_to_chain(Assignment::Target &, Assignment::Target::ChainType, unsigned); } // namespace SL } // namespace GL -- 2.45.2