Line | Branch | Exec | Source |
---|---|---|---|
1 | // Copyright (c) 2021-2025 ChilliBits. All rights reserved. | ||
2 | |||
3 | #pragma once | ||
4 | |||
5 | #include <string> | ||
6 | #include <vector> | ||
7 | |||
8 | #include <CompilerPass.h> | ||
9 | #include <ast/ASTNodes.h> | ||
10 | #include <ast/AbstractASTVisitor.h> | ||
11 | #include <util/CommonUtil.h> | ||
12 | |||
13 | namespace spice::compiler { | ||
14 | |||
15 | /** | ||
16 | * Visitor for debug purposes (is only executed in the compiler debug mode and when explicitly enabling it via cli flag) | ||
17 | * | ||
18 | * Jobs: | ||
19 | * - Visualize AST | ||
20 | */ | ||
21 | class ASTVisualizer final : CompilerPass, public AbstractASTVisitor { | ||
22 | public: | ||
23 | // Constructors | ||
24 | using CompilerPass::CompilerPass; | ||
25 | |||
26 | // Visitor methods | ||
27 |
2/4✓ Branch 0 (2→3) taken 630 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 630 times.
✗ Branch 3 (3→8) not taken.
|
630 | std::any visitEntry(EntryNode *ctx) override { return buildNode(ctx); } |
28 |
2/4✓ Branch 0 (2→3) taken 8 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 8 times.
✗ Branch 3 (3→8) not taken.
|
8 | std::any visitMainFctDef(MainFctDefNode *ctx) override { return buildNode(ctx); } |
29 |
2/4✓ Branch 0 (2→3) taken 5884 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 5884 times.
✗ Branch 3 (3→8) not taken.
|
5884 | std::any visitFctDef(FctDefNode *ctx) override { return buildNode(ctx); } |
30 |
2/4✓ Branch 0 (2→3) taken 2864 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 2864 times.
✗ Branch 3 (3→8) not taken.
|
2864 | std::any visitProcDef(ProcDefNode *ctx) override { return buildNode(ctx); } |
31 |
2/4✓ Branch 0 (2→3) taken 8748 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 8748 times.
✗ Branch 3 (3→8) not taken.
|
8748 | std::any visitFctName(FctNameNode *ctx) override { return buildNode(ctx); } |
32 |
2/4✓ Branch 0 (2→3) taken 468 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 468 times.
✗ Branch 3 (3→8) not taken.
|
468 | std::any visitStructDef(StructDefNode *ctx) override { return buildNode(ctx); } |
33 |
2/4✓ Branch 0 (2→3) taken 67 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 67 times.
✗ Branch 3 (3→8) not taken.
|
67 | std::any visitInterfaceDef(InterfaceDefNode *ctx) override { return buildNode(ctx); } |
34 |
2/4✓ Branch 0 (2→3) taken 57 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 57 times.
✗ Branch 3 (3→8) not taken.
|
57 | std::any visitEnumDef(EnumDefNode *ctx) override { return buildNode(ctx); } |
35 |
2/4✓ Branch 0 (2→3) taken 725 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 725 times.
✗ Branch 3 (3→8) not taken.
|
725 | std::any visitGenericTypeDef(GenericTypeDefNode *ctx) override { return buildNode(ctx); } |
36 |
2/4✓ Branch 0 (2→3) taken 41 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 41 times.
✗ Branch 3 (3→8) not taken.
|
41 | std::any visitAliasDef(AliasDefNode *ctx) override { return buildNode(ctx); } |
37 |
2/4✓ Branch 0 (2→3) taken 741 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 741 times.
✗ Branch 3 (3→8) not taken.
|
741 | std::any visitGlobalVarDef(GlobalVarDefNode *ctx) override { return buildNode(ctx); } |
38 |
2/4✓ Branch 0 (2→3) taken 842 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 842 times.
✗ Branch 3 (3→8) not taken.
|
842 | std::any visitExtDecl(ExtDeclNode *ctx) override { return buildNode(ctx); } |
39 |
2/4✓ Branch 0 (2→3) taken 352 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 352 times.
✗ Branch 3 (3→8) not taken.
|
352 | std::any visitImportDef(ImportDefNode *ctx) override { return buildNode(ctx); } |
40 |
2/4✓ Branch 0 (2→3) taken 2072 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 2072 times.
✗ Branch 3 (3→8) not taken.
|
2072 | std::any visitUnsafeBlock(UnsafeBlockNode *ctx) override { return buildNode(ctx); } |
41 |
2/4✓ Branch 0 (2→3) taken 986 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 986 times.
✗ Branch 3 (3→8) not taken.
|
986 | std::any visitForLoop(ForLoopNode *ctx) override { return buildNode(ctx); } |
42 |
2/4✓ Branch 0 (2→3) taken 49 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 49 times.
✗ Branch 3 (3→8) not taken.
|
49 | std::any visitForeachLoop(ForeachLoopNode *ctx) override { return buildNode(ctx); } |
43 |
2/4✓ Branch 0 (2→3) taken 560 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 560 times.
✗ Branch 3 (3→8) not taken.
|
560 | std::any visitWhileLoop(WhileLoopNode *ctx) override { return buildNode(ctx); } |
44 |
2/4✓ Branch 0 (2→3) taken 3 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 3 times.
✗ Branch 3 (3→8) not taken.
|
3 | std::any visitDoWhileLoop(DoWhileLoopNode *ctx) override { return buildNode(ctx); } |
45 |
2/4✓ Branch 0 (2→3) taken 3335 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 3335 times.
✗ Branch 3 (3→8) not taken.
|
3335 | std::any visitIfStmt(IfStmtNode *ctx) override { return buildNode(ctx); } |
46 |
2/4✓ Branch 0 (2→3) taken 160 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 160 times.
✗ Branch 3 (3→8) not taken.
|
160 | std::any visitElseStmt(ElseStmtNode *ctx) override { return buildNode(ctx); } |
47 |
2/4✓ Branch 0 (2→3) taken 5 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 5 times.
✗ Branch 3 (3→8) not taken.
|
5 | std::any visitSwitchStmt(SwitchStmtNode *ctx) override { return buildNode(ctx); } |
48 |
2/4✓ Branch 0 (2→3) taken 31 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 31 times.
✗ Branch 3 (3→8) not taken.
|
31 | std::any visitCaseBranch(CaseBranchNode *ctx) override { return buildNode(ctx); } |
49 |
2/4✓ Branch 0 (2→3) taken 3 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 3 times.
✗ Branch 3 (3→8) not taken.
|
3 | std::any visitDefaultBranch(DefaultBranchNode *ctx) override { return buildNode(ctx); } |
50 |
2/4✓ Branch 0 (2→3) taken 78 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 78 times.
✗ Branch 3 (3→8) not taken.
|
78 | std::any visitAssertStmt(AssertStmtNode *ctx) override { return buildNode(ctx); } |
51 | ✗ | std::any visitAnonymousBlockStmt(AnonymousBlockStmtNode *ctx) override { return buildNode(ctx); } | |
52 |
2/4✓ Branch 0 (2→3) taken 15911 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 15911 times.
✗ Branch 3 (3→8) not taken.
|
15911 | std::any visitStmtLst(StmtLstNode *ctx) override { return buildNode(ctx); } |
53 |
2/4✓ Branch 0 (2→3) taken 4764 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 4764 times.
✗ Branch 3 (3→8) not taken.
|
4764 | std::any visitTypeLst(TypeLstNode *ctx) override { return buildNode(ctx); } |
54 |
2/4✓ Branch 0 (2→3) taken 725 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 725 times.
✗ Branch 3 (3→8) not taken.
|
725 | std::any visitTypeAltsLst(TypeAltsLstNode *ctx) override { return buildNode(ctx); } |
55 |
2/4✓ Branch 0 (2→3) taken 6567 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 6567 times.
✗ Branch 3 (3→8) not taken.
|
6567 | std::any visitParamLst(ParamLstNode *ctx) override { return buildNode(ctx); } |
56 |
2/4✓ Branch 0 (2→3) taken 9263 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 9263 times.
✗ Branch 3 (3→8) not taken.
|
9263 | std::any visitArgLst(ArgLstNode *ctx) override { return buildNode(ctx); } |
57 |
2/4✓ Branch 0 (2→3) taken 57 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 57 times.
✗ Branch 3 (3→8) not taken.
|
57 | std::any visitEnumItemLst(EnumItemLstNode *ctx) override { return buildNode(ctx); } |
58 |
2/4✓ Branch 0 (2→3) taken 708 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 708 times.
✗ Branch 3 (3→8) not taken.
|
708 | std::any visitEnumItem(EnumItemNode *ctx) override { return buildNode(ctx); } |
59 |
2/4✓ Branch 0 (2→3) taken 1061 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 1061 times.
✗ Branch 3 (3→8) not taken.
|
1061 | std::any visitField(FieldNode *ctx) override { return buildNode(ctx); } |
60 |
2/4✓ Branch 0 (2→3) taken 172 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 172 times.
✗ Branch 3 (3→8) not taken.
|
172 | std::any visitSignature(SignatureNode *ctx) override { return buildNode(ctx); } |
61 |
2/4✓ Branch 0 (2→3) taken 14968 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 14968 times.
✗ Branch 3 (3→8) not taken.
|
14968 | std::any visitDeclStmt(DeclStmtNode *ctx) override { return buildNode(ctx); } |
62 |
2/4✓ Branch 0 (2→3) taken 9653 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 9653 times.
✗ Branch 3 (3→8) not taken.
|
9653 | std::any visitExprStmt(ExprStmtNode *ctx) override { return buildNode(ctx); } |
63 |
2/4✓ Branch 0 (2→3) taken 23474 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 23474 times.
✗ Branch 3 (3→8) not taken.
|
23474 | std::any visitQualifierLst(QualifierLstNode *ctx) override { return buildNode(ctx); } |
64 |
2/4✓ Branch 0 (2→3) taken 28147 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 28147 times.
✗ Branch 3 (3→8) not taken.
|
28147 | std::any visitQualifier(QualifierNode *ctx) override { return buildNode(ctx); } |
65 |
2/4✓ Branch 0 (2→3) taken 292 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 292 times.
✗ Branch 3 (3→8) not taken.
|
292 | std::any visitModAttr(ModAttrNode *ctx) override { return buildNode(ctx); } |
66 |
2/4✓ Branch 0 (2→3) taken 422 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 422 times.
✗ Branch 3 (3→8) not taken.
|
422 | std::any visitTopLevelDefinitionAttr(TopLevelDefinitionAttrNode *ctx) override { return buildNode(ctx); } |
67 |
2/4✓ Branch 0 (2→3) taken 1 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 1 times.
✗ Branch 3 (3→8) not taken.
|
1 | std::any visitLambdaAttr(LambdaAttrNode *ctx) override { return buildNode(ctx); } |
68 |
2/4✓ Branch 0 (2→3) taken 715 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 715 times.
✗ Branch 3 (3→8) not taken.
|
715 | std::any visitAttrLst(AttrLstNode *ctx) override { return buildNode(ctx); } |
69 |
2/4✓ Branch 0 (2→3) taken 1150 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 1150 times.
✗ Branch 3 (3→8) not taken.
|
1150 | std::any visitAttr(AttrNode *ctx) override { return buildNode(ctx); } |
70 |
2/4✓ Branch 0 (2→3) taken 48 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 48 times.
✗ Branch 3 (3→8) not taken.
|
48 | std::any visitCaseConstant(CaseConstantNode *ctx) override { return buildNode(ctx); } |
71 |
2/4✓ Branch 0 (2→3) taken 7417 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 7417 times.
✗ Branch 3 (3→8) not taken.
|
7417 | std::any visitReturnStmt(ReturnStmtNode *ctx) override { return buildNode(ctx); } |
72 |
2/4✓ Branch 0 (2→3) taken 96 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 96 times.
✗ Branch 3 (3→8) not taken.
|
96 | std::any visitBreakStmt(BreakStmtNode *ctx) override { return buildNode(ctx); } |
73 |
2/4✓ Branch 0 (2→3) taken 172 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 172 times.
✗ Branch 3 (3→8) not taken.
|
172 | std::any visitContinueStmt(ContinueStmtNode *ctx) override { return buildNode(ctx); } |
74 | ✗ | std::any visitFallthroughStmt(FallthroughStmtNode *ctx) override { return buildNode(ctx); } | |
75 |
2/4✓ Branch 0 (2→3) taken 1045 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 1045 times.
✗ Branch 3 (3→8) not taken.
|
1045 | std::any visitBuiltinCall(BuiltinCallNode *ctx) override { return buildNode(ctx); } |
76 |
2/4✓ Branch 0 (2→3) taken 158 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 158 times.
✗ Branch 3 (3→8) not taken.
|
158 | std::any visitPrintfCall(PrintfCallNode *ctx) override { return buildNode(ctx); } |
77 |
2/4✓ Branch 0 (2→3) taken 184 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 184 times.
✗ Branch 3 (3→8) not taken.
|
184 | std::any visitSizeofCall(SizeofCallNode *ctx) override { return buildNode(ctx); } |
78 | ✗ | std::any visitAlignofCall(AlignofCallNode *ctx) override { return buildNode(ctx); } | |
79 |
2/4✓ Branch 0 (2→3) taken 18 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 18 times.
✗ Branch 3 (3→8) not taken.
|
18 | std::any visitLenCall(LenCallNode *ctx) override { return buildNode(ctx); } |
80 |
2/4✓ Branch 0 (2→3) taken 685 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 685 times.
✗ Branch 3 (3→8) not taken.
|
685 | std::any visitPanicCall(PanicCallNode *ctx) override { return buildNode(ctx); } |
81 | ✗ | std::any visitSysCall(SysCallNode *ctx) override { return buildNode(ctx); } | |
82 |
2/4✓ Branch 0 (2→3) taken 52228 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 52228 times.
✗ Branch 3 (3→8) not taken.
|
52228 | std::any visitAssignExpr(AssignExprNode *ctx) override { return buildNode(ctx); } |
83 |
2/4✓ Branch 0 (2→3) taken 46760 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 46760 times.
✗ Branch 3 (3→8) not taken.
|
46760 | std::any visitTernaryExpr(TernaryExprNode *ctx) override { return buildNode(ctx); } |
84 |
2/4✓ Branch 0 (2→3) taken 47270 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 47270 times.
✗ Branch 3 (3→8) not taken.
|
47270 | std::any visitLogicalOrExpr(LogicalOrExprNode *ctx) override { return buildNode(ctx); } |
85 |
2/4✓ Branch 0 (2→3) taken 48369 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 48369 times.
✗ Branch 3 (3→8) not taken.
|
48369 | std::any visitLogicalAndExpr(LogicalAndExprNode *ctx) override { return buildNode(ctx); } |
86 |
2/4✓ Branch 0 (2→3) taken 48578 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 48578 times.
✗ Branch 3 (3→8) not taken.
|
48578 | std::any visitBitwiseOrExpr(BitwiseOrExprNode *ctx) override { return buildNode(ctx); } |
87 |
2/4✓ Branch 0 (2→3) taken 48637 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 48637 times.
✗ Branch 3 (3→8) not taken.
|
48637 | std::any visitBitwiseXorExpr(BitwiseXorExprNode *ctx) override { return buildNode(ctx); } |
88 |
2/4✓ Branch 0 (2→3) taken 48637 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 48637 times.
✗ Branch 3 (3→8) not taken.
|
48637 | std::any visitBitwiseAndExpr(BitwiseAndExprNode *ctx) override { return buildNode(ctx); } |
89 |
2/4✓ Branch 0 (2→3) taken 48657 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 48657 times.
✗ Branch 3 (3→8) not taken.
|
48657 | std::any visitEqualityExpr(EqualityExprNode *ctx) override { return buildNode(ctx); } |
90 |
2/4✓ Branch 0 (2→3) taken 52585 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 52585 times.
✗ Branch 3 (3→8) not taken.
|
52585 | std::any visitRelationalExpr(RelationalExprNode *ctx) override { return buildNode(ctx); } |
91 |
2/4✓ Branch 0 (2→3) taken 55426 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 55426 times.
✗ Branch 3 (3→8) not taken.
|
55426 | std::any visitShiftExpr(ShiftExprNode *ctx) override { return buildNode(ctx); } |
92 |
2/4✓ Branch 0 (2→3) taken 55463 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 55463 times.
✗ Branch 3 (3→8) not taken.
|
55463 | std::any visitAdditiveExpr(AdditiveExprNode *ctx) override { return buildNode(ctx); } |
93 |
2/4✓ Branch 0 (2→3) taken 58592 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 58592 times.
✗ Branch 3 (3→8) not taken.
|
58592 | std::any visitMultiplicativeExpr(MultiplicativeExprNode *ctx) override { return buildNode(ctx); } |
94 |
2/4✓ Branch 0 (2→3) taken 59682 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 59682 times.
✗ Branch 3 (3→8) not taken.
|
59682 | std::any visitCastExpr(CastExprNode *ctx) override { return buildNode(ctx); } |
95 |
2/4✓ Branch 0 (2→3) taken 66145 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 66145 times.
✗ Branch 3 (3→8) not taken.
|
66145 | std::any visitPrefixUnaryExpr(PrefixUnaryExprNode *ctx) override { return buildNode(ctx); } |
96 |
2/4✓ Branch 0 (2→3) taken 84232 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 84232 times.
✗ Branch 3 (3→8) not taken.
|
84232 | std::any visitPostfixUnaryExpr(PostfixUnaryExprNode *ctx) override { return buildNode(ctx); } |
97 |
2/4✓ Branch 0 (2→3) taken 65275 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 65275 times.
✗ Branch 3 (3→8) not taken.
|
65275 | std::any visitAtomicExpr(AtomicExprNode *ctx) override { return buildNode(ctx); } |
98 |
2/4✓ Branch 0 (2→3) taken 12588 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 12588 times.
✗ Branch 3 (3→8) not taken.
|
12588 | std::any visitValue(ValueNode *ctx) override { return buildNode(ctx); } |
99 |
2/4✓ Branch 0 (2→3) taken 12054 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 12054 times.
✗ Branch 3 (3→8) not taken.
|
12054 | std::any visitConstant(ConstantNode *ctx) override { return buildNode(ctx); } |
100 |
2/4✓ Branch 0 (2→3) taken 11527 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 11527 times.
✗ Branch 3 (3→8) not taken.
|
11527 | std::any visitFctCall(FctCallNode *ctx) override { return buildNode(ctx); } |
101 |
2/4✓ Branch 0 (2→3) taken 5 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 5 times.
✗ Branch 3 (3→8) not taken.
|
5 | std::any visitArrayInitialization(ArrayInitializationNode *ctx) override { return buildNode(ctx); } |
102 |
2/4✓ Branch 0 (2→3) taken 155 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 155 times.
✗ Branch 3 (3→8) not taken.
|
155 | std::any visitStructInstantiation(StructInstantiationNode *ctx) override { return buildNode(ctx); } |
103 | ✗ | std::any visitLambdaFunc(LambdaFuncNode *ctx) override { return buildNode(ctx); } | |
104 |
2/4✓ Branch 0 (2→3) taken 2 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 2 times.
✗ Branch 3 (3→8) not taken.
|
2 | std::any visitLambdaProc(LambdaProcNode *ctx) override { return buildNode(ctx); } |
105 | ✗ | std::any visitLambdaExpr(LambdaExprNode *ctx) override { return buildNode(ctx); } | |
106 |
2/4✓ Branch 0 (2→3) taken 34853 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 34853 times.
✗ Branch 3 (3→8) not taken.
|
34853 | std::any visitDataType(DataTypeNode *ctx) override { return buildNode(ctx); } |
107 |
2/4✓ Branch 0 (2→3) taken 34853 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 34853 times.
✗ Branch 3 (3→8) not taken.
|
34853 | std::any visitBaseDataType(BaseDataTypeNode *ctx) override { return buildNode(ctx); } |
108 |
2/4✓ Branch 0 (2→3) taken 12709 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 12709 times.
✗ Branch 3 (3→8) not taken.
|
12709 | std::any visitCustomDataType(CustomDataTypeNode *ctx) override { return buildNode(ctx); } |
109 |
2/4✓ Branch 0 (2→3) taken 56 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 56 times.
✗ Branch 3 (3→8) not taken.
|
56 | std::any visitFunctionDataType(FunctionDataTypeNode *ctx) override { return buildNode(ctx); } |
110 | |||
111 | private: | ||
112 | // Members | ||
113 | const std::vector<std::string> nodeNames; | ||
114 | std::stack<std::string> parentNodeIds; | ||
115 | |||
116 | // Private methods | ||
117 | template <typename T> | ||
118 | 1161920 | std::string buildNode(const T *node) | |
119 | requires std::is_base_of_v<ASTNode, T> | ||
120 | { | ||
121 |
1/2✓ Branch 0 (2→3) taken 1161920 times.
✗ Branch 1 (2→72) not taken.
|
1161920 | std::stringstream result; |
122 | |||
123 | // Prepare strings | ||
124 |
1/2✓ Branch 0 (4→5) taken 1161920 times.
✗ Branch 1 (4→70) not taken.
|
1161920 | const std::string typeName(CommonUtil::demangleTypeName(typeid(T).name())); |
125 |
1/2✓ Branch 0 (5→6) taken 1161920 times.
✗ Branch 1 (5→68) not taken.
|
1161920 | const std::string codeLoc = node->codeLoc.toString(); |
126 |
2/4✓ Branch 0 (6→7) taken 1161920 times.
✗ Branch 1 (6→66) not taken.
✓ Branch 2 (7→8) taken 1161920 times.
✗ Branch 3 (7→66) not taken.
|
1161920 | const std::string nodeName = typeName.substr(typeName.rfind("::") + 2); |
127 |
2/4✓ Branch 0 (8→9) taken 1161920 times.
✗ Branch 1 (8→52) not taken.
✓ Branch 2 (9→10) taken 1161920 times.
✗ Branch 3 (9→50) not taken.
|
1161920 | const std::string nodeId = codeLoc + "_" + nodeName; |
128 | |||
129 | // Build result | ||
130 |
4/8✓ Branch 0 (11→12) taken 1161920 times.
✗ Branch 1 (11→62) not taken.
✓ Branch 2 (12→13) taken 1161920 times.
✗ Branch 3 (12→62) not taken.
✓ Branch 4 (13→14) taken 1161920 times.
✗ Branch 5 (13→62) not taken.
✓ Branch 6 (14→15) taken 1161920 times.
✗ Branch 7 (14→62) not taken.
|
1161920 | result << nodeId << R"( [color="lightgreen",label=")" << nodeName << "\"];\n"; |
131 | |||
132 | // Link parent node with the current one | ||
133 |
2/2✓ Branch 0 (16→17) taken 1161290 times.
✓ Branch 1 (16→23) taken 630 times.
|
1161920 | if (!parentNodeIds.empty()) |
134 |
5/10✓ Branch 0 (17→18) taken 1161290 times.
✗ Branch 1 (17→62) not taken.
✓ Branch 2 (19→20) taken 1161290 times.
✗ Branch 3 (19→62) not taken.
✓ Branch 4 (20→21) taken 1161290 times.
✗ Branch 5 (20→62) not taken.
✓ Branch 6 (21→22) taken 1161290 times.
✗ Branch 7 (21→62) not taken.
✓ Branch 8 (22→23) taken 1161290 times.
✗ Branch 9 (22→62) not taken.
|
1161290 | result << " " << parentNodeIds.top() << " -> " << nodeId << ";\n"; |
135 | |||
136 |
1/2✓ Branch 0 (23→24) taken 1161920 times.
✗ Branch 1 (23→62) not taken.
|
1161920 | parentNodeIds.push(nodeId); // Set parentNodeId for children |
137 | |||
138 | // Visit all the children | ||
139 |
3/4✓ Branch 0 (24→25) taken 1161920 times.
✗ Branch 1 (24→61) not taken.
✓ Branch 2 (38→27) taken 1161290 times.
✓ Branch 3 (38→39) taken 1161920 times.
|
2323210 | for (ASTNode *child : node->getChildren()) |
140 |
1/2✓ Branch 0 (28→29) taken 1161290 times.
✗ Branch 1 (28→36) not taken.
|
1161290 | if (child != nullptr) |
141 |
4/8✓ Branch 0 (29→30) taken 1161290 times.
✗ Branch 1 (29→59) not taken.
✓ Branch 2 (30→31) taken 1161290 times.
✗ Branch 3 (30→57) not taken.
✓ Branch 4 (31→32) taken 1161290 times.
✗ Branch 5 (31→55) not taken.
✓ Branch 6 (32→33) taken 1161290 times.
✗ Branch 7 (32→53) not taken.
|
1161290 | result << " " << std::any_cast<std::string>(visit(child)); |
142 | |||
143 | // Remove parent node id from the stack | ||
144 | 1161920 | parentNodeIds.pop(); | |
145 | |||
146 |
1/2✓ Branch 0 (41→42) taken 1161920 times.
✗ Branch 1 (41→62) not taken.
|
2323840 | return result.str(); |
147 | 1161920 | } | |
148 | }; | ||
149 | |||
150 | } // namespace spice::compiler | ||
151 |