]> git.tdb.fi Git - libs/gl.git/blob - source/glsl/debug.h
Assign a result type to all expressions
[libs/gl.git] / source / glsl / debug.h
1 #ifndef MSP_GL_SL_DEBUG_H_
2 #define MSP_GL_SL_DEBUG_H_
3
4 #include "syntax.h"
5 #include "visitor.h"
6
7 namespace Msp {
8 namespace GL {
9 namespace SL {
10
11 /** Creates a textual representation of the syntax tree.  The result is encoded
12 as UTF-8. */
13 class DumpTree: private TraversingVisitor
14 {
15 private:
16         enum TreeChars
17         {
18                 EMPTY = 0x20,
19                 STRAIGHT = 0x2502,     // │
20                 BRANCH = 0x251C,       // ├
21                 BRANCH_LAST = 0x2514,  // └
22                 REACH = 0x2574         // ╴
23         };
24
25         std::map<const Node *, unsigned> node_labels;
26         std::string formatted;
27         std::vector<TreeChars> tree;
28
29 public:
30         const std::string &apply(Stage &);
31
32 private:
33         void append(const std::string &);
34         void begin_sub();
35         void last_branch();
36         void end_sub();
37         void annotated_branch(const std::string &, Node &);
38         unsigned get_label(const Node &);
39         std::string format_type(TypeDeclaration *);
40
41         template<typename T>
42         typename T::const_iterator increment(typename T::const_iterator &, const T &);
43
44         virtual void visit(Block &);
45         virtual void visit(Literal &);
46         virtual void visit(ParenthesizedExpression &);
47         virtual void visit(VariableReference &);
48         virtual void visit(InterfaceBlockReference &);
49         virtual void visit(MemberAccess &);
50         virtual void visit(UnaryExpression &);
51         virtual void visit(BinaryExpression &);
52         virtual void visit(Assignment &);
53         virtual void visit(FunctionCall &);
54         virtual void visit(ExpressionStatement &);
55         virtual void visit(Import &);
56         virtual void visit(Precision &);
57         virtual void visit(Layout &);
58         virtual void visit(InterfaceLayout &);
59         virtual void visit(BasicTypeDeclaration &);
60         virtual void visit(ImageTypeDeclaration &);
61         virtual void visit(StructDeclaration &);
62         virtual void visit(VariableDeclaration &);
63         virtual void visit(InterfaceBlock &);
64         virtual void visit(FunctionDeclaration &);
65         virtual void visit(Conditional &);
66         virtual void visit(Iteration &);
67         virtual void visit(Passthrough &);
68         virtual void visit(Return &);
69         virtual void visit(Jump &);
70 };
71
72 } // namespace SL
73 } // namespace GL
74 } // namespace Msp
75
76 #endif