Line | Branch | Exec | Source |
---|---|---|---|
1 | // Copyright (c) 2021-2024 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 1 taken 521 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 521 times.
✗ Branch 5 not taken.
|
521 | std::any visitEntry(EntryNode *ctx) override { return buildNode(ctx); } |
28 |
2/4✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
|
8 | std::any visitMainFctDef(MainFctDefNode *ctx) override { return buildNode(ctx); } |
29 |
2/4✓ Branch 1 taken 4140 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 4140 times.
✗ Branch 5 not taken.
|
4140 | std::any visitFctDef(FctDefNode *ctx) override { return buildNode(ctx); } |
30 |
2/4✓ Branch 1 taken 2617 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2617 times.
✗ Branch 5 not taken.
|
2617 | std::any visitProcDef(ProcDefNode *ctx) override { return buildNode(ctx); } |
31 |
2/4✓ Branch 1 taken 6757 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 6757 times.
✗ Branch 5 not taken.
|
6757 | std::any visitFctName(FctNameNode *ctx) override { return buildNode(ctx); } |
32 |
2/4✓ Branch 1 taken 429 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 429 times.
✗ Branch 5 not taken.
|
429 | std::any visitStructDef(StructDefNode *ctx) override { return buildNode(ctx); } |
33 |
2/4✓ Branch 1 taken 61 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 61 times.
✗ Branch 5 not taken.
|
61 | std::any visitInterfaceDef(InterfaceDefNode *ctx) override { return buildNode(ctx); } |
34 |
2/4✓ Branch 1 taken 32 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 32 times.
✗ Branch 5 not taken.
|
32 | std::any visitEnumDef(EnumDefNode *ctx) override { return buildNode(ctx); } |
35 |
2/4✓ Branch 1 taken 688 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 688 times.
✗ Branch 5 not taken.
|
688 | std::any visitGenericTypeDef(GenericTypeDefNode *ctx) override { return buildNode(ctx); } |
36 |
2/4✓ Branch 1 taken 26 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 26 times.
✗ Branch 5 not taken.
|
26 | std::any visitAliasDef(AliasDefNode *ctx) override { return buildNode(ctx); } |
37 |
2/4✓ Branch 1 taken 715 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 715 times.
✗ Branch 5 not taken.
|
715 | std::any visitGlobalVarDef(GlobalVarDefNode *ctx) override { return buildNode(ctx); } |
38 |
2/4✓ Branch 1 taken 692 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 692 times.
✗ Branch 5 not taken.
|
692 | std::any visitExtDecl(ExtDeclNode *ctx) override { return buildNode(ctx); } |
39 |
2/4✓ Branch 1 taken 254 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 254 times.
✗ Branch 5 not taken.
|
254 | std::any visitImportDef(ImportDefNode *ctx) override { return buildNode(ctx); } |
40 |
2/4✓ Branch 1 taken 1802 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1802 times.
✗ Branch 5 not taken.
|
1802 | std::any visitUnsafeBlock(UnsafeBlockNode *ctx) override { return buildNode(ctx); } |
41 |
2/4✓ Branch 1 taken 934 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 934 times.
✗ Branch 5 not taken.
|
934 | std::any visitForLoop(ForLoopNode *ctx) override { return buildNode(ctx); } |
42 |
2/4✓ Branch 1 taken 49 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 49 times.
✗ Branch 5 not taken.
|
49 | std::any visitForeachLoop(ForeachLoopNode *ctx) override { return buildNode(ctx); } |
43 |
2/4✓ Branch 1 taken 382 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 382 times.
✗ Branch 5 not taken.
|
382 | std::any visitWhileLoop(WhileLoopNode *ctx) override { return buildNode(ctx); } |
44 |
2/4✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
|
3 | std::any visitDoWhileLoop(DoWhileLoopNode *ctx) override { return buildNode(ctx); } |
45 |
2/4✓ Branch 1 taken 2852 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2852 times.
✗ Branch 5 not taken.
|
2852 | std::any visitIfStmt(IfStmtNode *ctx) override { return buildNode(ctx); } |
46 |
2/4✓ Branch 1 taken 157 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 157 times.
✗ Branch 5 not taken.
|
157 | std::any visitElseStmt(ElseStmtNode *ctx) override { return buildNode(ctx); } |
47 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | std::any visitSwitchStmt(SwitchStmtNode *ctx) override { return buildNode(ctx); } |
48 |
2/4✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
|
6 | std::any visitCaseBranch(CaseBranchNode *ctx) override { return buildNode(ctx); } |
49 | ✗ | std::any visitDefaultBranch(DefaultBranchNode *ctx) override { return buildNode(ctx); } | |
50 |
2/4✓ Branch 1 taken 66 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 66 times.
✗ Branch 5 not taken.
|
66 | std::any visitAssertStmt(AssertStmtNode *ctx) override { return buildNode(ctx); } |
51 | ✗ | std::any visitAnonymousBlockStmt(AnonymousBlockStmtNode *ctx) override { return buildNode(ctx); } | |
52 |
2/4✓ Branch 1 taken 12907 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 12907 times.
✗ Branch 5 not taken.
|
12907 | std::any visitStmtLst(StmtLstNode *ctx) override { return buildNode(ctx); } |
53 |
2/4✓ Branch 1 taken 4209 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 4209 times.
✗ Branch 5 not taken.
|
4209 | std::any visitTypeLst(TypeLstNode *ctx) override { return buildNode(ctx); } |
54 |
2/4✓ Branch 1 taken 688 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 688 times.
✗ Branch 5 not taken.
|
688 | std::any visitTypeAltsLst(TypeAltsLstNode *ctx) override { return buildNode(ctx); } |
55 |
2/4✓ Branch 1 taken 4817 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 4817 times.
✗ Branch 5 not taken.
|
4817 | std::any visitParamLst(ParamLstNode *ctx) override { return buildNode(ctx); } |
56 |
2/4✓ Branch 1 taken 6646 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 6646 times.
✗ Branch 5 not taken.
|
6646 | std::any visitArgLst(ArgLstNode *ctx) override { return buildNode(ctx); } |
57 |
2/4✓ Branch 1 taken 32 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 32 times.
✗ Branch 5 not taken.
|
32 | std::any visitEnumItemLst(EnumItemLstNode *ctx) override { return buildNode(ctx); } |
58 |
2/4✓ Branch 1 taken 408 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 408 times.
✗ Branch 5 not taken.
|
408 | std::any visitEnumItem(EnumItemNode *ctx) override { return buildNode(ctx); } |
59 |
2/4✓ Branch 1 taken 986 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 986 times.
✗ Branch 5 not taken.
|
986 | std::any visitField(FieldNode *ctx) override { return buildNode(ctx); } |
60 |
2/4✓ Branch 1 taken 158 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 158 times.
✗ Branch 5 not taken.
|
158 | std::any visitSignature(SignatureNode *ctx) override { return buildNode(ctx); } |
61 |
2/4✓ Branch 1 taken 11853 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 11853 times.
✗ Branch 5 not taken.
|
11853 | std::any visitDeclStmt(DeclStmtNode *ctx) override { return buildNode(ctx); } |
62 |
2/4✓ Branch 1 taken 19534 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 19534 times.
✗ Branch 5 not taken.
|
19534 | std::any visitSpecifierLst(SpecifierLstNode *ctx) override { return buildNode(ctx); } |
63 |
2/4✓ Branch 1 taken 22874 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 22874 times.
✗ Branch 5 not taken.
|
22874 | std::any visitSpecifier(SpecifierNode *ctx) override { return buildNode(ctx); } |
64 |
2/4✓ Branch 1 taken 275 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 275 times.
✗ Branch 5 not taken.
|
275 | std::any visitModAttr(ModAttrNode *ctx) override { return buildNode(ctx); } |
65 |
2/4✓ Branch 1 taken 104 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 104 times.
✗ Branch 5 not taken.
|
104 | std::any visitTopLevelDefinitionAttr(TopLevelDefinitionAttrNode *ctx) override { return buildNode(ctx); } |
66 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | std::any visitLambdaAttr(LambdaAttrNode *ctx) override { return buildNode(ctx); } |
67 |
2/4✓ Branch 1 taken 380 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 380 times.
✗ Branch 5 not taken.
|
380 | std::any visitAttrLst(AttrLstNode *ctx) override { return buildNode(ctx); } |
68 |
2/4✓ Branch 1 taken 591 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 591 times.
✗ Branch 5 not taken.
|
591 | std::any visitAttr(AttrNode *ctx) override { return buildNode(ctx); } |
69 |
2/4✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
|
6 | std::any visitCaseConstant(CaseConstantNode *ctx) override { return buildNode(ctx); } |
70 |
2/4✓ Branch 1 taken 5457 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 5457 times.
✗ Branch 5 not taken.
|
5457 | std::any visitReturnStmt(ReturnStmtNode *ctx) override { return buildNode(ctx); } |
71 |
2/4✓ Branch 1 taken 92 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 92 times.
✗ Branch 5 not taken.
|
92 | std::any visitBreakStmt(BreakStmtNode *ctx) override { return buildNode(ctx); } |
72 |
2/4✓ Branch 1 taken 164 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 164 times.
✗ Branch 5 not taken.
|
164 | std::any visitContinueStmt(ContinueStmtNode *ctx) override { return buildNode(ctx); } |
73 | ✗ | std::any visitFallthroughStmt(FallthroughStmtNode *ctx) override { return buildNode(ctx); } | |
74 |
2/4✓ Branch 1 taken 147 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 147 times.
✗ Branch 5 not taken.
|
147 | std::any visitPrintfCall(PrintfCallNode *ctx) override { return buildNode(ctx); } |
75 |
2/4✓ Branch 1 taken 170 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 170 times.
✗ Branch 5 not taken.
|
170 | std::any visitSizeofCall(SizeofCallNode *ctx) override { return buildNode(ctx); } |
76 | ✗ | std::any visitAlignofCall(AlignofCallNode *ctx) override { return buildNode(ctx); } | |
77 |
2/4✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 18 times.
✗ Branch 5 not taken.
|
18 | std::any visitLenCall(LenCallNode *ctx) override { return buildNode(ctx); } |
78 |
2/4✓ Branch 1 taken 458 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 458 times.
✗ Branch 5 not taken.
|
458 | std::any visitPanicCall(PanicCallNode *ctx) override { return buildNode(ctx); } |
79 | ✗ | std::any visitSysCall(SysCallNode *ctx) override { return buildNode(ctx); } | |
80 |
2/4✓ Branch 1 taken 42357 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 42357 times.
✗ Branch 5 not taken.
|
42357 | std::any visitAssignExpr(AssignExprNode *ctx) override { return buildNode(ctx); } |
81 |
2/4✓ Branch 1 taken 37248 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 37248 times.
✗ Branch 5 not taken.
|
37248 | std::any visitTernaryExpr(TernaryExprNode *ctx) override { return buildNode(ctx); } |
82 |
2/4✓ Branch 1 taken 37730 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 37730 times.
✗ Branch 5 not taken.
|
37730 | std::any visitLogicalOrExpr(LogicalOrExprNode *ctx) override { return buildNode(ctx); } |
83 |
2/4✓ Branch 1 taken 38046 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 38046 times.
✗ Branch 5 not taken.
|
38046 | std::any visitLogicalAndExpr(LogicalAndExprNode *ctx) override { return buildNode(ctx); } |
84 |
2/4✓ Branch 1 taken 38140 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 38140 times.
✗ Branch 5 not taken.
|
38140 | std::any visitBitwiseOrExpr(BitwiseOrExprNode *ctx) override { return buildNode(ctx); } |
85 |
2/4✓ Branch 1 taken 38167 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 38167 times.
✗ Branch 5 not taken.
|
38167 | std::any visitBitwiseXorExpr(BitwiseXorExprNode *ctx) override { return buildNode(ctx); } |
86 |
2/4✓ Branch 1 taken 38167 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 38167 times.
✗ Branch 5 not taken.
|
38167 | std::any visitBitwiseAndExpr(BitwiseAndExprNode *ctx) override { return buildNode(ctx); } |
87 |
2/4✓ Branch 1 taken 38187 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 38187 times.
✗ Branch 5 not taken.
|
38187 | std::any visitEqualityExpr(EqualityExprNode *ctx) override { return buildNode(ctx); } |
88 |
2/4✓ Branch 1 taken 41293 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 41293 times.
✗ Branch 5 not taken.
|
41293 | std::any visitRelationalExpr(RelationalExprNode *ctx) override { return buildNode(ctx); } |
89 |
2/4✓ Branch 1 taken 43764 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 43764 times.
✗ Branch 5 not taken.
|
43764 | std::any visitShiftExpr(ShiftExprNode *ctx) override { return buildNode(ctx); } |
90 |
2/4✓ Branch 1 taken 43770 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 43770 times.
✗ Branch 5 not taken.
|
43770 | std::any visitAdditiveExpr(AdditiveExprNode *ctx) override { return buildNode(ctx); } |
91 |
2/4✓ Branch 1 taken 46513 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 46513 times.
✗ Branch 5 not taken.
|
46513 | std::any visitMultiplicativeExpr(MultiplicativeExprNode *ctx) override { return buildNode(ctx); } |
92 |
2/4✓ Branch 1 taken 47543 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 47543 times.
✗ Branch 5 not taken.
|
47543 | std::any visitCastExpr(CastExprNode *ctx) override { return buildNode(ctx); } |
93 |
2/4✓ Branch 1 taken 53519 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 53519 times.
✗ Branch 5 not taken.
|
53519 | std::any visitPrefixUnaryExpr(PrefixUnaryExprNode *ctx) override { return buildNode(ctx); } |
94 |
2/4✓ Branch 1 taken 69541 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 69541 times.
✗ Branch 5 not taken.
|
69541 | std::any visitPostfixUnaryExpr(PostfixUnaryExprNode *ctx) override { return buildNode(ctx); } |
95 |
2/4✓ Branch 1 taken 52764 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 52764 times.
✗ Branch 5 not taken.
|
52764 | std::any visitAtomicExpr(AtomicExprNode *ctx) override { return buildNode(ctx); } |
96 |
2/4✓ Branch 1 taken 9527 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 9527 times.
✗ Branch 5 not taken.
|
9527 | std::any visitValue(ValueNode *ctx) override { return buildNode(ctx); } |
97 |
2/4✓ Branch 1 taken 9153 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 9153 times.
✗ Branch 5 not taken.
|
9153 | std::any visitConstant(ConstantNode *ctx) override { return buildNode(ctx); } |
98 |
2/4✓ Branch 1 taken 8721 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 8721 times.
✗ Branch 5 not taken.
|
8721 | std::any visitFctCall(FctCallNode *ctx) override { return buildNode(ctx); } |
99 |
2/4✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
|
6 | std::any visitArrayInitialization(ArrayInitializationNode *ctx) override { return buildNode(ctx); } |
100 |
2/4✓ Branch 1 taken 83 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 83 times.
✗ Branch 5 not taken.
|
83 | std::any visitStructInstantiation(StructInstantiationNode *ctx) override { return buildNode(ctx); } |
101 | ✗ | std::any visitLambdaFunc(LambdaFuncNode *ctx) override { return buildNode(ctx); } | |
102 |
2/4✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
|
2 | std::any visitLambdaProc(LambdaProcNode *ctx) override { return buildNode(ctx); } |
103 | ✗ | std::any visitLambdaExpr(LambdaExprNode *ctx) override { return buildNode(ctx); } | |
104 |
2/4✓ Branch 1 taken 28295 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 28295 times.
✗ Branch 5 not taken.
|
28295 | std::any visitDataType(DataTypeNode *ctx) override { return buildNode(ctx); } |
105 |
2/4✓ Branch 1 taken 28295 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 28295 times.
✗ Branch 5 not taken.
|
28295 | std::any visitBaseDataType(BaseDataTypeNode *ctx) override { return buildNode(ctx); } |
106 |
2/4✓ Branch 1 taken 10792 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 10792 times.
✗ Branch 5 not taken.
|
10792 | std::any visitCustomDataType(CustomDataTypeNode *ctx) override { return buildNode(ctx); } |
107 |
2/4✓ Branch 1 taken 42 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 42 times.
✗ Branch 5 not taken.
|
42 | std::any visitFunctionDataType(FunctionDataTypeNode *ctx) override { return buildNode(ctx); } |
108 | |||
109 | private: | ||
110 | // Members | ||
111 | const std::vector<std::string> nodeNames; | ||
112 | std::stack<std::string> parentNodeIds; | ||
113 | |||
114 | // Private methods | ||
115 | template <typename T> | ||
116 | 1835664 | std::string buildNode(const T *node) | |
117 | requires std::is_base_of_v<ASTNode, T> | ||
118 | { | ||
119 |
1/2✓ Branch 1 taken 917832 times.
✗ Branch 2 not taken.
|
1835664 | std::stringstream result; |
120 | |||
121 | // Prepare strings | ||
122 |
1/2✓ Branch 2 taken 917832 times.
✗ Branch 3 not taken.
|
1835664 | const std::string typeName(CommonUtil::demangleTypeName(typeid(T).name())); |
123 |
1/2✓ Branch 1 taken 917832 times.
✗ Branch 2 not taken.
|
1835664 | const std::string codeLoc = node->codeLoc.toString(); |
124 |
2/4✓ Branch 1 taken 917832 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 917832 times.
✗ Branch 5 not taken.
|
1835664 | const std::string nodeName = typeName.substr(typeName.rfind("::") + 2); |
125 |
2/4✓ Branch 1 taken 917832 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 917832 times.
✗ Branch 5 not taken.
|
1835664 | const std::string nodeId = codeLoc + "_" + nodeName; |
126 | |||
127 | // Build result | ||
128 |
4/8✓ Branch 1 taken 917832 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 917832 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 917832 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 917832 times.
✗ Branch 11 not taken.
|
1835664 | result << nodeId << R"( [color="lightgreen",label=")" << nodeName << "\"];\n"; |
129 | |||
130 | // Link parent node with the current one | ||
131 |
2/2✓ Branch 1 taken 917311 times.
✓ Branch 2 taken 521 times.
|
1835664 | if (!parentNodeIds.empty()) |
132 |
5/10✓ Branch 1 taken 917311 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 917311 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 917311 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 917311 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 917311 times.
✗ Branch 15 not taken.
|
1834622 | result << " " << parentNodeIds.top() << " -> " << nodeId << ";\n"; |
133 | |||
134 |
1/2✓ Branch 1 taken 917832 times.
✗ Branch 2 not taken.
|
1835664 | parentNodeIds.push(nodeId); // Set parentNodeId for children |
135 | |||
136 | // Visit all the children | ||
137 |
2/2✓ Branch 5 taken 917311 times.
✓ Branch 6 taken 917832 times.
|
3670286 | for (ASTNode *child : node->children) |
138 |
1/2✓ Branch 0 taken 917311 times.
✗ Branch 1 not taken.
|
1834622 | if (child != nullptr) |
139 |
4/8✓ Branch 1 taken 917311 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 917311 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 917311 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 917311 times.
✗ Branch 11 not taken.
|
1834622 | result << " " << std::any_cast<std::string>(visit(child)); |
140 | |||
141 | // Remove parent node id from the stack | ||
142 | 1835664 | parentNodeIds.pop(); | |
143 | |||
144 |
1/2✓ Branch 1 taken 917832 times.
✗ Branch 2 not taken.
|
3671328 | return result.str(); |
145 | 1835664 | } | |
146 | }; | ||
147 | |||
148 | } // namespace spice::compiler | ||
149 |