X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fglsl%2Fdebug.h;h=3837c569bb18e13aacf3d02a9d1d58eadecd5cb0;hb=f526938b407e061c7424adedc34af4d1ff687f90;hp=6aca7af0fb2a94b0aab0b8936f1c9ea902021d2a;hpb=bd8816692056230c36504dcccd76c6946dff47b1;p=libs%2Fgl.git diff --git a/source/glsl/debug.h b/source/glsl/debug.h index 6aca7af0..3837c569 100644 --- a/source/glsl/debug.h +++ b/source/glsl/debug.h @@ -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 node_labels; std::string formatted; std::vector tree; @@ -29,11 +41,13 @@ public: private: void append(const std::string &); + void append_subtree(const std::vector &); 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::const_iterator increment(typename T::const_iterator &, const T &); @@ -44,6 +58,7 @@ private: virtual void visit(VariableReference &); virtual void visit(InterfaceBlockReference &); virtual void visit(MemberAccess &); + virtual void visit(Swizzle &); virtual void visit(UnaryExpression &); virtual void visit(BinaryExpression &); virtual void visit(Assignment &); @@ -53,6 +68,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 &);