X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fglsl%2Freflect.h;h=c2d7aa0483bd36e4411a55c2d5325158dfae1b92;hb=cdc2c7176202b4f8d1f3fd21db9c571511b32fa2;hp=162ed9c0b8bcf4ddb01daf17724e4308138decd0;hpb=8967d38bc578f1653c1dde01dce49a8f7b0c912e;p=libs%2Fgl.git diff --git a/source/glsl/reflect.h b/source/glsl/reflect.h index 162ed9c0..c2d7aa04 100644 --- a/source/glsl/reflect.h +++ b/source/glsl/reflect.h @@ -7,6 +7,34 @@ namespace Msp { namespace GL { namespace SL { +/** Compares two types for equality. Struct types are compared recursively. */ +class TypeComparer: private NodeVisitor +{ +private: + Node *first; + Node *second; + unsigned first_tag; + bool r_result; + + static unsigned next_tag; + +public: + TypeComparer(); + + bool apply(TypeDeclaration &t1, TypeDeclaration &t2) { compare(t1, t2); return r_result; } + +private: + void compare(Node &, Node &); + template + T *multi_visit(T &); + virtual void visit(Literal &); + virtual void visit(VariableReference &); + virtual void visit(BasicTypeDeclaration &); + virtual void visit(ImageTypeDeclaration &); + virtual void visit(StructDeclaration &); + virtual void visit(VariableDeclaration &); +}; + /** Determines the number of interface locations required by a variable. */ class LocationCounter: private NodeVisitor { @@ -57,6 +85,7 @@ class DependencyCollector: private TraversingVisitor private: std::set dependencies; std::set locals; + std::set visited_functions; public: std::set apply(FunctionDeclaration &); @@ -66,6 +95,7 @@ private: virtual void visit(InterfaceBlockReference &); virtual void visit(FunctionCall &); virtual void visit(VariableDeclaration &); + virtual void visit(FunctionDeclaration &); }; } // namespace SL