GCC Code Coverage Report


Directory: ./
File: src/plugin/plugin.h
Date: 2023-04-27 00:55:30
Exec Total Coverage
Lines: 0 0 -%
Functions: 0 1 0.0%
Branches: 0 0 -%

Line Branch Exec Source
1 #ifndef LYTHON_PLUGIN_VISITOR_HEADER
2 #define LYTHON_PLUGIN_VISITOR_HEADER
3
4 #include "ast/visitor.h"
5
6 namespace lython {
7
8 struct VisitorPluginTrait {
9 using StmtRet = void;
10 using ExprRet = void;
11 using ModRet = void;
12 using PatRet = void;
13 using IsConst = std::false_type;
14 using Trace = std::true_type;
15
16 enum
17 { MaxRecursionDepth = LY_MAX_VISITOR_RECURSION_DEPTH };
18 };
19
20 /*
21 */
22 struct VisitorPlugin: BaseVisitor<VisitorPlugin, false, VisitorPluginTrait> {
23 public:
24 using Super = BaseVisitor<VisitorPlugin, false, VisitorPluginTrait>;
25
26 using StmtRet = Super::StmtRet;
27 using ExprRet = Super::ExprRet;
28 using ModRet = Super::ModRet;
29 using PatRet = Super::PatRet;
30
31 #define TYPE_GEN(rtype) using rtype##_t = Super::rtype##_t;
32
33 #define X(name, _)
34 #define SSECTION(name)
35 #define EXPR(name, fun) TYPE_GEN(name)
36 #define STMT(name, fun) TYPE_GEN(name)
37 #define MOD(name, fun) TYPE_GEN(name)
38 #define MATCH(name, fun) TYPE_GEN(name)
39
40 NODEKIND_ENUM(X, SSECTION, EXPR, STMT, MOD, MATCH)
41
42 #undef X
43 #undef SSECTION
44 #undef EXPR
45 #undef STMT
46 #undef MOD
47 #undef MATCH
48 #undef TYPE_GEN
49
50 virtual ~VisitorPlugin() {}
51
52 #define FUNCTION_GEN(name, fun, ret) virtual ret fun(name##_t* n, int depth) = 0;
53
54 #define X(name, _)
55 #define SSECTION(name)
56 #define MOD(name, fun) FUNCTION_GEN(name, fun, ModRet)
57 #define EXPR(name, fun) FUNCTION_GEN(name, fun, ExprRet)
58 #define STMT(name, fun) FUNCTION_GEN(name, fun, StmtRet)
59 #define MATCH(name, fun) FUNCTION_GEN(name, fun, PatRet)
60
61 NODEKIND_ENUM(X, SSECTION, EXPR, STMT, MOD, MATCH)
62
63 #undef X
64 #undef SSECTION
65 #undef EXPR
66 #undef STMT
67 #undef MOD
68 #undef MATCH
69
70 #undef FUNCTION_GEN
71 };
72
73
74 } // namespace lython
75
76 extern "C" {
77 typedef void* VisitorPlugin_C;
78 extern VisitorPlugin_C make_plugin();
79
80 extern void free_plugin(VisitorPlugin_C* plugin);
81 }
82
83 #endif
84