]> git.tdb.fi Git - libs/gl.git/blobdiff - source/glsl/debug.h
Easier way of adding complex subtrees to GLSL debug dump
[libs/gl.git] / source / glsl / debug.h
index 5bc7a8bf884fbb09700b72490890e08ffc6b36ba..d873ea379a9019241385b8106196fd1c503c6a1e 100644 (file)
@@ -8,6 +8,8 @@ namespace Msp {
 namespace GL {
 namespace SL {
 
+/** Creates a textual representation of the syntax tree.  The result is encoded
+as UTF-8. */
 class DumpTree: private TraversingVisitor
 {
 private:
@@ -20,6 +22,16 @@ private:
                REACH = 0x2574         // ╴
        };
 
+       struct Branch
+       {
+               std::string text;
+               Node *node;
+
+               Branch(const char *t, Node *n = 0): text(t), node(n) { }
+               Branch(const std::string &t, Node *n = 0): text(t), node(n) { }
+               Branch(Node *n): node(n) { }
+       };
+
        std::map<const Node *, unsigned> node_labels;
        std::string formatted;
        std::vector<TreeChars> tree;
@@ -29,11 +41,13 @@ public:
 
 private:
        void append(const std::string &);
+       void append_subtree(const std::vector<Branch> &);
        void begin_sub();
        void last_branch();
        void end_sub();
        void annotated_branch(const std::string &, Node &);
        unsigned get_label(const Node &);
+       std::string format_type(TypeDeclaration *);
 
        template<typename T>
        typename T::const_iterator increment(typename T::const_iterator &, const T &);
@@ -42,6 +56,7 @@ private:
        virtual void visit(Literal &);
        virtual void visit(ParenthesizedExpression &);
        virtual void visit(VariableReference &);
+       virtual void visit(InterfaceBlockReference &);
        virtual void visit(MemberAccess &);
        virtual void visit(UnaryExpression &);
        virtual void visit(BinaryExpression &);
@@ -52,6 +67,8 @@ private:
        virtual void visit(Precision &);
        virtual void visit(Layout &);
        virtual void visit(InterfaceLayout &);
+       virtual void visit(BasicTypeDeclaration &);
+       virtual void visit(ImageTypeDeclaration &);
        virtual void visit(StructDeclaration &);
        virtual void visit(VariableDeclaration &);
        virtual void visit(InterfaceBlock &);
@@ -61,7 +78,6 @@ private:
        virtual void visit(Passthrough &);
        virtual void visit(Return &);
        virtual void visit(Jump &);
-       using TraversingVisitor::visit;
 };
 
 } // namespace SL