graphVisitor.hpp
Go to the documentation of this file.
1
2#pragma once
3
5
6namespace by {
7
11 class _nout graphVisitor: public visitor {
12 BY(CLASS(graphVisitor, visitor))
13
14 public:
16
17 public:
18 nbool onVisit(const visitInfo& i, node& visitee, nbool alreadyVisited) override;
19 void onLeave(const visitInfo& i, node& visitee, nbool alreadyVisited) override;
20 nbool onVisit(const visitInfo& i, obj& obj, nbool alreadyVisited) override;
21 nbool onVisit(const visitInfo& i, baseFunc& fun, nbool alreadyVisited) override;
22 nbool onVisit(const visitInfo& i, func& fun, nbool alreadyVisited) override;
23 nbool onVisit(const visitInfo& i, defNestedFuncExpr& e, nbool alreadyVisited) override;
24 nbool onVisit(const visitInfo& i, genericOrigin& o, nbool alreadyVisited) override;
25 nbool onVisit(const visitInfo& i, getExpr& e, nbool alreadyVisited) override;
26 nbool onVisit(const visitInfo& i, runExpr& e, nbool alreadyVisited) override;
27 nbool onVisit(const visitInfo& i, FBOExpr& e, nbool alreadyVisited) override;
28 nbool onVisit(const visitInfo& i, FUOExpr& e, nbool alreadyVisited) override;
29 nbool onVisit(const visitInfo& i, assignExpr& e, nbool alreadyVisited) override;
30 nbool onVisit(const visitInfo& i, defVarExpr& e, nbool alreadyVisited) override;
31 nbool onVisit(const visitInfo& i, nInt& e, nbool alreadyVisited) override;
32 nbool onVisit(const visitInfo& i, nFlt& e, nbool alreadyVisited) override;
33 nbool onVisit(const visitInfo& i, nStr& e, nbool alreadyVisited) override;
34 nbool onVisit(const visitInfo& i, nByte& e, nbool alreadyVisited) override;
35 nbool onVisit(const visitInfo& i, nBool& e, nbool alreadyVisited) override;
36 me& setShowData(nbool showData);
37 nbool isShowData() const;
38
39 protected:
40 void _onWork() override;
41
42 private:
43 void _drawIndent();
44 void _onIndent();
45 void _drawFrame(const visitInfo& i);
46
47 template <typename T> nbool _onVisitPrimitive(const visitInfo& i, T& e) {
48 _drawFrame(i);
49 using platformAPI::foreColor;
50 _showModifier(e.getModifier());
51 std::cout << foreColor(LIGHTRED) << i.name << " " << foreColor(CYAN) << e.getType().getName()
52 << foreColor(LIGHTGRAY) << " = " << foreColor(YELLOW) << e.get();
53 return false;
54 }
55
56 std::string _encodeNewLine(const std::string& msg) const;
57 std::string _getNameFrom(const node& it) const;
58 std::string _getNameFrom(const node* it) const BY_SIDE_FUNC(it, _getNameFrom(*it), "frame");
59 void _showModifier(const modifier& mod);
60
61 private:
62 std::vector<nbool> _parentsLast;
63 std::vector<const char*> _indents;
64 nbool _isStart;
65 nbool _isShowData;
66 };
67} // namespace by
Fundamental Binary Operation expression.
Definition: FBOExpr.hpp:17
Fundamental Unary Operation expression.
Definition: FUOExpr.hpp:17
Assignment expression for variable assignment.
Definition: assignExpr.hpp:16
Base class for all function types.
Definition: baseFunc.hpp:18
Nested func definition expression (lambda)
Definition: defNestedFuncExpr.hpp:13
Variable definition expression base class.
Definition: defVarExpr.hpp:17
Function definition in byeol language.
Definition: func.hpp:20
Generic type origin with type parameters.
Definition: genericOrigin.hpp:15
Expression for property and method access.
Definition: getExpr.hpp:17
AST graph visualization visitor.
Definition: graphVisitor.hpp:11
Access modifier for class members and func.
Definition: modifier.hpp:12
Boolean primitive type in byeol language.
Definition: nBool.hpp:12
Byte primitive type in byeol language.
Definition: nByte.hpp:12
Float primitive type in byeol language.
Definition: nFlt.hpp:12
Integer primitive type in byeol language.
Definition: nInt.hpp:12
String primitive type in byeol language.
Definition: nStr.hpp:13
Base class for all AST nodes in byeol language.
Definition: node.hpp:30
Managed object in byeol programming environment.
Definition: obj.hpp:19
Function/method call expression.
Definition: runExpr.hpp:14
Visitor context information.
Definition: visitInfo.hpp:10
Base visitor class for AST traversal.
Definition: visitor.hpp:20