X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fglsl%2Freflect.h;h=6e6f9d8316bf2c5af1522a03b097bf301c057df6;hp=63dfe7bec53ed2e843d2f8857d8cb18b056a6fb2;hb=HEAD;hpb=523491787b2b0321748a53f139c1a4355d2f9e85 diff --git a/source/glsl/reflect.h b/source/glsl/reflect.h index 63dfe7be..308d7c80 100644 --- a/source/glsl/reflect.h +++ b/source/glsl/reflect.h @@ -16,16 +16,14 @@ bool can_convert(const BasicTypeDeclaration &, const BasicTypeDeclaration &); class TypeComparer: private NodeVisitor { private: - Node *first; - Node *second; - unsigned first_tag; - bool r_result; + Node *first = 0; + Node *second = 0; + unsigned first_tag = 0; + bool r_result = false; static unsigned next_tag; public: - TypeComparer(); - bool apply(TypeDeclaration &t1, TypeDeclaration &t2) { compare(t1, t2); return r_result; } private: @@ -34,6 +32,10 @@ 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(FunctionCall &); virtual void visit(BasicTypeDeclaration &); virtual void visit(ImageTypeDeclaration &); virtual void visit(StructDeclaration &); @@ -44,11 +46,9 @@ private: class LocationCounter: private NodeVisitor { private: - unsigned r_count; + unsigned r_count = 0; public: - LocationCounter(); - unsigned apply(VariableDeclaration &v) { v.visit(*this); return r_count; } private: @@ -71,9 +71,9 @@ public: Result(unsigned s, unsigned a): size(s), alignment(a), stride(s+a-1-(s+a-1)%a) { } }; private: - unsigned r_size; - unsigned r_alignment; - int r_offset; + unsigned r_size = 0; + unsigned r_alignment = 1; + int r_offset = -1; public: Result apply(VariableDeclaration &v) { v.visit(*this); return Result(r_size, r_alignment); } @@ -99,12 +99,27 @@ public: private: virtual void visit(VariableReference &); - virtual void visit(InterfaceBlockReference &); virtual void visit(FunctionCall &); virtual void visit(VariableDeclaration &); virtual void visit(FunctionDeclaration &); }; +class AssignmentCollector: private TraversingVisitor +{ +private: + bool assignment_target = false; + std::set assigned_variables; + +public: + std::set apply(Node &); + +private: + virtual void visit(VariableReference &); + virtual void visit(UnaryExpression &); + virtual void visit(BinaryExpression &); + virtual void visit(Assignment &); +}; + } // namespace SL } // namespace GL } // namespace Msp