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 659 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 659 times.
✗ Branch 3 (3→8) not taken.
|
659 | 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 6103 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 6103 times.
✗ Branch 3 (3→8) not taken.
|
6103 | std::any visitFctDef(FctDefNode *ctx) override { return buildNode(ctx); } |
30 |
2/4✓ Branch 0 (2→3) taken 3312 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 3312 times.
✗ Branch 3 (3→8) not taken.
|
3312 | std::any visitProcDef(ProcDefNode *ctx) override { return buildNode(ctx); } |
31 |
2/4✓ Branch 0 (2→3) taken 9415 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 9415 times.
✗ Branch 3 (3→8) not taken.
|
9415 | std::any visitFctName(FctNameNode *ctx) override { return buildNode(ctx); } |
32 |
2/4✓ Branch 0 (2→3) taken 487 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 487 times.
✗ Branch 3 (3→8) not taken.
|
487 | std::any visitStructDef(StructDefNode *ctx) override { return buildNode(ctx); } |
33 |
2/4✓ Branch 0 (2→3) taken 70 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 70 times.
✗ Branch 3 (3→8) not taken.
|
70 | 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 773 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 773 times.
✗ Branch 3 (3→8) not taken.
|
773 | std::any visitGenericTypeDef(GenericTypeDefNode *ctx) override { return buildNode(ctx); } |
36 |
2/4✓ Branch 0 (2→3) taken 46 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 46 times.
✗ Branch 3 (3→8) not taken.
|
46 | std::any visitAliasDef(AliasDefNode *ctx) override { return buildNode(ctx); } |
37 |
2/4✓ Branch 0 (2→3) taken 1125 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 1125 times.
✗ Branch 3 (3→8) not taken.
|
1125 | std::any visitGlobalVarDef(GlobalVarDefNode *ctx) override { return buildNode(ctx); } |
38 |
2/4✓ Branch 0 (2→3) taken 859 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 859 times.
✗ Branch 3 (3→8) not taken.
|
859 | std::any visitExtDecl(ExtDeclNode *ctx) override { return buildNode(ctx); } |
39 |
2/4✓ Branch 0 (2→3) taken 391 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 391 times.
✗ Branch 3 (3→8) not taken.
|
391 | std::any visitImportDef(ImportDefNode *ctx) override { return buildNode(ctx); } |
40 |
2/4✓ Branch 0 (2→3) taken 2382 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 2382 times.
✗ Branch 3 (3→8) not taken.
|
2382 | std::any visitUnsafeBlock(UnsafeBlockNode *ctx) override { return buildNode(ctx); } |
41 |
2/4✓ Branch 0 (2→3) taken 1192 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 1192 times.
✗ Branch 3 (3→8) not taken.
|
1192 | std::any visitForLoop(ForLoopNode *ctx) override { return buildNode(ctx); } |
42 |
2/4✓ Branch 0 (2→3) taken 61 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 61 times.
✗ Branch 3 (3→8) not taken.
|
61 | std::any visitForeachLoop(ForeachLoopNode *ctx) override { return buildNode(ctx); } |
43 |
2/4✓ Branch 0 (2→3) taken 667 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 667 times.
✗ Branch 3 (3→8) not taken.
|
667 | 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 3556 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 3556 times.
✗ Branch 3 (3→8) not taken.
|
3556 | std::any visitIfStmt(IfStmtNode *ctx) override { return buildNode(ctx); } |
46 |
2/4✓ Branch 0 (2→3) taken 164 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 164 times.
✗ Branch 3 (3→8) not taken.
|
164 | 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 82 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 82 times.
✗ Branch 3 (3→8) not taken.
|
82 | 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 17437 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 17437 times.
✗ Branch 3 (3→8) not taken.
|
17437 | std::any visitStmtLst(StmtLstNode *ctx) override { return buildNode(ctx); } |
53 |
2/4✓ Branch 0 (2→3) taken 5278 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 5278 times.
✗ Branch 3 (3→8) not taken.
|
5278 | std::any visitTypeLst(TypeLstNode *ctx) override { return buildNode(ctx); } |
54 |
2/4✓ Branch 0 (2→3) taken 773 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 773 times.
✗ Branch 3 (3→8) not taken.
|
773 | std::any visitTypeAltsLst(TypeAltsLstNode *ctx) override { return buildNode(ctx); } |
55 |
2/4✓ Branch 0 (2→3) taken 7142 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 7142 times.
✗ Branch 3 (3→8) not taken.
|
7142 | std::any visitParamLst(ParamLstNode *ctx) override { return buildNode(ctx); } |
56 |
2/4✓ Branch 0 (2→3) taken 9895 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 9895 times.
✗ Branch 3 (3→8) not taken.
|
9895 | 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 709 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 709 times.
✗ Branch 3 (3→8) not taken.
|
709 | std::any visitEnumItem(EnumItemNode *ctx) override { return buildNode(ctx); } |
59 |
2/4✓ Branch 0 (2→3) taken 1100 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 1100 times.
✗ Branch 3 (3→8) not taken.
|
1100 | std::any visitField(FieldNode *ctx) override { return buildNode(ctx); } |
60 |
2/4✓ Branch 0 (2→3) taken 178 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 178 times.
✗ Branch 3 (3→8) not taken.
|
178 | std::any visitSignature(SignatureNode *ctx) override { return buildNode(ctx); } |
61 |
2/4✓ Branch 0 (2→3) taken 16367 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 16367 times.
✗ Branch 3 (3→8) not taken.
|
16367 | std::any visitDeclStmt(DeclStmtNode *ctx) override { return buildNode(ctx); } |
62 |
2/4✓ Branch 0 (2→3) taken 10774 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 10774 times.
✗ Branch 3 (3→8) not taken.
|
10774 | std::any visitExprStmt(ExprStmtNode *ctx) override { return buildNode(ctx); } |
63 |
2/4✓ Branch 0 (2→3) taken 25684 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 25684 times.
✗ Branch 3 (3→8) not taken.
|
25684 | std::any visitQualifierLst(QualifierLstNode *ctx) override { return buildNode(ctx); } |
64 |
2/4✓ Branch 0 (2→3) taken 31340 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 31340 times.
✗ Branch 3 (3→8) not taken.
|
31340 | std::any visitQualifier(QualifierNode *ctx) override { return buildNode(ctx); } |
65 |
2/4✓ Branch 0 (2→3) taken 299 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 299 times.
✗ Branch 3 (3→8) not taken.
|
299 | std::any visitModAttr(ModAttrNode *ctx) override { return buildNode(ctx); } |
66 |
2/4✓ Branch 0 (2→3) taken 399 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 399 times.
✗ Branch 3 (3→8) not taken.
|
399 | 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 699 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 699 times.
✗ Branch 3 (3→8) not taken.
|
699 | std::any visitAttrLst(AttrLstNode *ctx) override { return buildNode(ctx); } |
69 |
2/4✓ Branch 0 (2→3) taken 1134 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 1134 times.
✗ Branch 3 (3→8) not taken.
|
1134 | 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 7691 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 7691 times.
✗ Branch 3 (3→8) not taken.
|
7691 | std::any visitReturnStmt(ReturnStmtNode *ctx) override { return buildNode(ctx); } |
72 |
2/4✓ Branch 0 (2→3) taken 98 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 98 times.
✗ Branch 3 (3→8) not taken.
|
98 | std::any visitBreakStmt(BreakStmtNode *ctx) override { return buildNode(ctx); } |
73 |
2/4✓ Branch 0 (2→3) taken 176 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 176 times.
✗ Branch 3 (3→8) not taken.
|
176 | 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 1266 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 1266 times.
✗ Branch 3 (3→8) not taken.
|
1266 | std::any visitBuiltinCall(BuiltinCallNode *ctx) override { return buildNode(ctx); } |
76 |
2/4✓ Branch 0 (2→3) taken 168 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 168 times.
✗ Branch 3 (3→8) not taken.
|
168 | std::any visitPrintfCall(PrintfCallNode *ctx) override { return buildNode(ctx); } |
77 |
2/4✓ Branch 0 (2→3) taken 193 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 193 times.
✗ Branch 3 (3→8) not taken.
|
193 | 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 108 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 108 times.
✗ Branch 3 (3→8) not taken.
|
108 | std::any visitLenCall(LenCallNode *ctx) override { return buildNode(ctx); } |
80 |
2/4✓ Branch 0 (2→3) taken 797 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 797 times.
✗ Branch 3 (3→8) not taken.
|
797 | 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 58953 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 58953 times.
✗ Branch 3 (3→8) not taken.
|
58953 | std::any visitAssignExpr(AssignExprNode *ctx) override { return buildNode(ctx); } |
83 |
2/4✓ Branch 0 (2→3) taken 52938 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 52938 times.
✗ Branch 3 (3→8) not taken.
|
52938 | std::any visitTernaryExpr(TernaryExprNode *ctx) override { return buildNode(ctx); } |
84 |
2/4✓ Branch 0 (2→3) taken 53516 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 53516 times.
✗ Branch 3 (3→8) not taken.
|
53516 | std::any visitLogicalOrExpr(LogicalOrExprNode *ctx) override { return buildNode(ctx); } |
85 |
2/4✓ Branch 0 (2→3) taken 54646 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 54646 times.
✗ Branch 3 (3→8) not taken.
|
54646 | std::any visitLogicalAndExpr(LogicalAndExprNode *ctx) override { return buildNode(ctx); } |
86 |
2/4✓ Branch 0 (2→3) taken 54865 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 54865 times.
✗ Branch 3 (3→8) not taken.
|
54865 | std::any visitBitwiseOrExpr(BitwiseOrExprNode *ctx) override { return buildNode(ctx); } |
87 |
2/4✓ Branch 0 (2→3) taken 54926 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 54926 times.
✗ Branch 3 (3→8) not taken.
|
54926 | std::any visitBitwiseXorExpr(BitwiseXorExprNode *ctx) override { return buildNode(ctx); } |
88 |
2/4✓ Branch 0 (2→3) taken 54926 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 54926 times.
✗ Branch 3 (3→8) not taken.
|
54926 | std::any visitBitwiseAndExpr(BitwiseAndExprNode *ctx) override { return buildNode(ctx); } |
89 |
2/4✓ Branch 0 (2→3) taken 54948 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 54948 times.
✗ Branch 3 (3→8) not taken.
|
54948 | std::any visitEqualityExpr(EqualityExprNode *ctx) override { return buildNode(ctx); } |
90 |
2/4✓ Branch 0 (2→3) taken 58977 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 58977 times.
✗ Branch 3 (3→8) not taken.
|
58977 | std::any visitRelationalExpr(RelationalExprNode *ctx) override { return buildNode(ctx); } |
91 |
2/4✓ Branch 0 (2→3) taken 62327 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 62327 times.
✗ Branch 3 (3→8) not taken.
|
62327 | std::any visitShiftExpr(ShiftExprNode *ctx) override { return buildNode(ctx); } |
92 |
2/4✓ Branch 0 (2→3) taken 62383 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 62383 times.
✗ Branch 3 (3→8) not taken.
|
62383 | std::any visitAdditiveExpr(AdditiveExprNode *ctx) override { return buildNode(ctx); } |
93 |
2/4✓ Branch 0 (2→3) taken 65893 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 65893 times.
✗ Branch 3 (3→8) not taken.
|
65893 | std::any visitMultiplicativeExpr(MultiplicativeExprNode *ctx) override { return buildNode(ctx); } |
94 |
2/4✓ Branch 0 (2→3) taken 67067 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 67067 times.
✗ Branch 3 (3→8) not taken.
|
67067 | std::any visitCastExpr(CastExprNode *ctx) override { return buildNode(ctx); } |
95 |
2/4✓ Branch 0 (2→3) taken 72239 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 72239 times.
✗ Branch 3 (3→8) not taken.
|
72239 | std::any visitPrefixUnaryExpr(PrefixUnaryExprNode *ctx) override { return buildNode(ctx); } |
96 |
2/4✓ Branch 0 (2→3) taken 92350 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 92350 times.
✗ Branch 3 (3→8) not taken.
|
92350 | std::any visitPostfixUnaryExpr(PostfixUnaryExprNode *ctx) override { return buildNode(ctx); } |
97 |
2/4✓ Branch 0 (2→3) taken 71339 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 71339 times.
✗ Branch 3 (3→8) not taken.
|
71339 | std::any visitAtomicExpr(AtomicExprNode *ctx) override { return buildNode(ctx); } |
98 |
2/4✓ Branch 0 (2→3) taken 13422 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 13422 times.
✗ Branch 3 (3→8) not taken.
|
13422 | std::any visitValue(ValueNode *ctx) override { return buildNode(ctx); } |
99 |
2/4✓ Branch 0 (2→3) taken 13143 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 13143 times.
✗ Branch 3 (3→8) not taken.
|
13143 | std::any visitConstant(ConstantNode *ctx) override { return buildNode(ctx); } |
100 |
2/4✓ Branch 0 (2→3) taken 12326 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 12326 times.
✗ Branch 3 (3→8) not taken.
|
12326 | std::any visitFctCall(FctCallNode *ctx) override { return buildNode(ctx); } |
101 |
2/4✓ Branch 0 (2→3) taken 9 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 9 times.
✗ Branch 3 (3→8) not taken.
|
9 | std::any visitArrayInitialization(ArrayInitializationNode *ctx) override { return buildNode(ctx); } |
102 |
2/4✓ Branch 0 (2→3) taken 156 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 156 times.
✗ Branch 3 (3→8) not taken.
|
156 | 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 37290 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 37290 times.
✗ Branch 3 (3→8) not taken.
|
37290 | std::any visitDataType(DataTypeNode *ctx) override { return buildNode(ctx); } |
107 |
2/4✓ Branch 0 (2→3) taken 37290 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 37290 times.
✗ Branch 3 (3→8) not taken.
|
37290 | std::any visitBaseDataType(BaseDataTypeNode *ctx) override { return buildNode(ctx); } |
108 |
2/4✓ Branch 0 (2→3) taken 14103 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 14103 times.
✗ Branch 3 (3→8) not taken.
|
14103 | std::any visitCustomDataType(CustomDataTypeNode *ctx) override { return buildNode(ctx); } |
109 |
2/4✓ Branch 0 (2→3) taken 44 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 44 times.
✗ Branch 3 (3→8) not taken.
|
44 | 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 | 1291340 | std::string buildNode(const T *node) | |
119 | requires std::is_base_of_v<ASTNode, T> | ||
120 | { | ||
121 |
1/2✓ Branch 0 (2→3) taken 1291340 times.
✗ Branch 1 (2→72) not taken.
|
1291340 | std::stringstream result; |
122 | |||
123 | // Prepare strings | ||
124 |
1/2✓ Branch 0 (4→5) taken 1291340 times.
✗ Branch 1 (4→70) not taken.
|
1291340 | const std::string typeName(CommonUtil::demangleTypeName(typeid(T).name())); |
125 |
1/2✓ Branch 0 (5→6) taken 1291340 times.
✗ Branch 1 (5→68) not taken.
|
1291340 | const std::string codeLoc = node->codeLoc.toString(); |
126 |
2/4✓ Branch 0 (6→7) taken 1291340 times.
✗ Branch 1 (6→66) not taken.
✓ Branch 2 (7→8) taken 1291340 times.
✗ Branch 3 (7→66) not taken.
|
1291340 | const std::string nodeName = typeName.substr(typeName.rfind("::") + 2); |
127 |
2/4✓ Branch 0 (8→9) taken 1291340 times.
✗ Branch 1 (8→52) not taken.
✓ Branch 2 (9→10) taken 1291340 times.
✗ Branch 3 (9→50) not taken.
|
1291340 | const std::string nodeId = codeLoc + "_" + nodeName; |
128 | |||
129 | // Build result | ||
130 |
4/8✓ Branch 0 (11→12) taken 1291340 times.
✗ Branch 1 (11→62) not taken.
✓ Branch 2 (12→13) taken 1291340 times.
✗ Branch 3 (12→62) not taken.
✓ Branch 4 (13→14) taken 1291340 times.
✗ Branch 5 (13→62) not taken.
✓ Branch 6 (14→15) taken 1291340 times.
✗ Branch 7 (14→62) not taken.
|
1291340 | 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 1290681 times.
✓ Branch 1 (16→23) taken 659 times.
|
1291340 | if (!parentNodeIds.empty()) |
134 |
5/10✓ Branch 0 (17→18) taken 1290681 times.
✗ Branch 1 (17→62) not taken.
✓ Branch 2 (19→20) taken 1290681 times.
✗ Branch 3 (19→62) not taken.
✓ Branch 4 (20→21) taken 1290681 times.
✗ Branch 5 (20→62) not taken.
✓ Branch 6 (21→22) taken 1290681 times.
✗ Branch 7 (21→62) not taken.
✓ Branch 8 (22→23) taken 1290681 times.
✗ Branch 9 (22→62) not taken.
|
1290681 | result << " " << parentNodeIds.top() << " -> " << nodeId << ";\n"; |
135 | |||
136 |
1/2✓ Branch 0 (23→24) taken 1291340 times.
✗ Branch 1 (23→62) not taken.
|
1291340 | parentNodeIds.push(nodeId); // Set parentNodeId for children |
137 | |||
138 | // Visit all the children | ||
139 |
3/4✓ Branch 0 (24→25) taken 1291340 times.
✗ Branch 1 (24→61) not taken.
✓ Branch 2 (38→27) taken 1290681 times.
✓ Branch 3 (38→39) taken 1291340 times.
|
2582021 | for (ASTNode *child : node->getChildren()) |
140 |
1/2✓ Branch 0 (28→29) taken 1290681 times.
✗ Branch 1 (28→36) not taken.
|
1290681 | if (child != nullptr) |
141 |
4/8✓ Branch 0 (29→30) taken 1290681 times.
✗ Branch 1 (29→59) not taken.
✓ Branch 2 (30→31) taken 1290681 times.
✗ Branch 3 (30→57) not taken.
✓ Branch 4 (31→32) taken 1290681 times.
✗ Branch 5 (31→55) not taken.
✓ Branch 6 (32→33) taken 1290681 times.
✗ Branch 7 (32→53) not taken.
|
1290681 | result << " " << std::any_cast<std::string>(visit(child)); |
142 | |||
143 | // Remove parent node id from the stack | ||
144 | 1291340 | parentNodeIds.pop(); | |
145 | |||
146 |
1/2✓ Branch 0 (41→42) taken 1291340 times.
✗ Branch 1 (41→62) not taken.
|
2582680 | return result.str(); |
147 | 1291340 | } | |
148 | }; | ||
149 | |||
150 | } // namespace spice::compiler | ||
151 |