1 #ifndef MSP_GL_SL_DEBUG_H_
2 #define MSP_GL_SL_DEBUG_H_
11 /** Creates a textual representation of the syntax tree. The result is encoded
13 class DumpTree: private TraversingVisitor
19 STRAIGHT = 0x2502, // │
21 BRANCH_LAST = 0x2514, // └
30 Branch(const char *t, Node *n = 0): text(t), node(n) { }
31 Branch(const std::string &t, Node *n = 0): text(t), node(n) { }
32 Branch(Node *n): node(n) { }
37 const char *default_color;
38 const char *tree_color;
39 const char *location_color;
40 const char *label_color;
41 const char *type_color;
42 const char *name_color;
43 const char *error_color;
46 std::map<const Node *, unsigned> node_labels;
47 std::string formatted;
48 std::vector<TreeChars> tree;
51 static const Colors no_colors;
52 static const Colors default_colors;
55 DumpTree(bool = false);
57 std::string apply(Stage &);
58 std::string apply(Node &n) { n.visit(*this); return formatted; }
61 void append(const std::string &);
62 void append(const Node &, const std::string &);
63 void append_subtree(const std::vector<Branch> &);
64 void append_subtree(Node &);
68 std::string get_label(const Node &);
69 std::string format_type(TypeDeclaration *);
70 std::string format_type(const std::string &);
71 std::string format_name(const std::string &);
74 typename T::const_iterator increment(typename T::const_iterator &, const T &);
76 virtual void visit(Block &);
77 virtual void visit(Literal &);
78 virtual void visit(VariableReference &);
79 virtual void visit(MemberAccess &);
80 virtual void visit(Swizzle &);
81 virtual void visit(UnaryExpression &);
82 virtual void visit(BinaryExpression &);
83 virtual void visit(Assignment &);
84 virtual void visit(TernaryExpression &);
85 virtual void visit(FunctionCall &);
86 virtual void visit(ExpressionStatement &);
87 virtual void visit(Import &);
88 virtual void visit(Precision &);
89 virtual void visit(Layout &);
90 virtual void visit(InterfaceLayout &);
91 virtual void visit(BasicTypeDeclaration &);
92 virtual void visit(ImageTypeDeclaration &);
93 virtual void visit(StructDeclaration &);
94 virtual void visit(VariableDeclaration &);
95 virtual void visit(FunctionDeclaration &);
96 virtual void visit(Conditional &);
97 virtual void visit(Iteration &);
98 virtual void visit(Passthrough &);
99 virtual void visit(Return &);
100 virtual void visit(Jump &);