Line |
Branch |
Exec |
Source |
1 |
|
|
// Copyright (c) 2021-2024 ChilliBits. All rights reserved. |
2 |
|
|
|
3 |
|
|
#pragma once |
4 |
|
|
|
5 |
|
|
#include <any> |
6 |
|
|
|
7 |
|
|
namespace spice::compiler { |
8 |
|
|
|
9 |
|
|
// Forward declarations |
10 |
|
|
class ASTNode; |
11 |
|
|
class EntryNode; |
12 |
|
|
class MainFctDefNode; |
13 |
|
|
class FctNameNode; |
14 |
|
|
class FctDefNode; |
15 |
|
|
class ProcDefNode; |
16 |
|
|
class StructDefNode; |
17 |
|
|
class InterfaceDefNode; |
18 |
|
|
class EnumDefNode; |
19 |
|
|
class GenericTypeDefNode; |
20 |
|
|
class AliasDefNode; |
21 |
|
|
class GlobalVarDefNode; |
22 |
|
|
class ExtDeclNode; |
23 |
|
|
class UnsafeBlockNode; |
24 |
|
|
class ForLoopNode; |
25 |
|
|
class ForeachLoopNode; |
26 |
|
|
class WhileLoopNode; |
27 |
|
|
class DoWhileLoopNode; |
28 |
|
|
class IfStmtNode; |
29 |
|
|
class ElseStmtNode; |
30 |
|
|
class SwitchStmtNode; |
31 |
|
|
class CaseBranchNode; |
32 |
|
|
class DefaultBranchNode; |
33 |
|
|
class AssertStmtNode; |
34 |
|
|
class AnonymousBlockStmtNode; |
35 |
|
|
class StmtLstNode; |
36 |
|
|
class TypeLstNode; |
37 |
|
|
class TypeAltsLstNode; |
38 |
|
|
class ParamLstNode; |
39 |
|
|
class ArgLstNode; |
40 |
|
|
class EnumItemLstNode; |
41 |
|
|
class EnumItemNode; |
42 |
|
|
class FieldNode; |
43 |
|
|
class SignatureNode; |
44 |
|
|
class DeclStmtNode; |
45 |
|
|
class SpecifierLstNode; |
46 |
|
|
class SpecifierNode; |
47 |
|
|
class ModAttrNode; |
48 |
|
|
class TopLevelDefinitionAttrNode; |
49 |
|
|
class LambdaAttrNode; |
50 |
|
|
class AttrLstNode; |
51 |
|
|
class AttrNode; |
52 |
|
|
class CaseConstantNode; |
53 |
|
|
class ImportDefNode; |
54 |
|
|
class ReturnStmtNode; |
55 |
|
|
class BreakStmtNode; |
56 |
|
|
class ContinueStmtNode; |
57 |
|
|
class FallthroughStmtNode; |
58 |
|
|
class PrintfCallNode; |
59 |
|
|
class SizeofCallNode; |
60 |
|
|
class AlignofCallNode; |
61 |
|
|
class LenCallNode; |
62 |
|
|
class PanicCallNode; |
63 |
|
|
class SysCallNode; |
64 |
|
|
class AssignExprNode; |
65 |
|
|
class TernaryExprNode; |
66 |
|
|
class LogicalOrExprNode; |
67 |
|
|
class LogicalAndExprNode; |
68 |
|
|
class BitwiseOrExprNode; |
69 |
|
|
class BitwiseXorExprNode; |
70 |
|
|
class BitwiseAndExprNode; |
71 |
|
|
class EqualityExprNode; |
72 |
|
|
class RelationalExprNode; |
73 |
|
|
class ShiftExprNode; |
74 |
|
|
class AdditiveExprNode; |
75 |
|
|
class MultiplicativeExprNode; |
76 |
|
|
class CastExprNode; |
77 |
|
|
class PrefixUnaryExprNode; |
78 |
|
|
class PostfixUnaryExprNode; |
79 |
|
|
class AtomicExprNode; |
80 |
|
|
class ValueNode; |
81 |
|
|
class ConstantNode; |
82 |
|
|
class FctCallNode; |
83 |
|
|
class ArrayInitializationNode; |
84 |
|
|
class StructInstantiationNode; |
85 |
|
|
class LambdaFuncNode; |
86 |
|
|
class LambdaProcNode; |
87 |
|
|
class LambdaExprNode; |
88 |
|
|
class DataTypeNode; |
89 |
|
|
class BaseDataTypeNode; |
90 |
|
|
class CustomDataTypeNode; |
91 |
|
|
class FunctionDataTypeNode; |
92 |
|
|
|
93 |
|
|
class ParallelizableASTVisitor { |
94 |
|
|
public: |
95 |
|
|
// Destructor |
96 |
|
1356 |
virtual ~ParallelizableASTVisitor() = default; |
97 |
|
|
|
98 |
|
|
// General visitor method |
99 |
|
|
std::any visit(const ASTNode *node); |
100 |
|
|
std::any visitChildren(const ASTNode *node); |
101 |
|
|
|
102 |
|
|
// Visitor methods |
103 |
|
|
virtual std::any visitEntry(const EntryNode *node); |
104 |
|
|
virtual std::any visitMainFctDef(const MainFctDefNode *node); |
105 |
|
|
virtual std::any visitFctDef(const FctDefNode *node); |
106 |
|
|
virtual std::any visitProcDef(const ProcDefNode *node); |
107 |
|
|
virtual std::any visitFctName(const FctNameNode *node); |
108 |
|
|
virtual std::any visitStructDef(const StructDefNode *node); |
109 |
|
|
virtual std::any visitInterfaceDef(const InterfaceDefNode *node); |
110 |
|
|
virtual std::any visitEnumDef(const EnumDefNode *node); |
111 |
|
|
virtual std::any visitGenericTypeDef(const GenericTypeDefNode *node); |
112 |
|
|
virtual std::any visitAliasDef(const AliasDefNode *node); |
113 |
|
|
virtual std::any visitGlobalVarDef(const GlobalVarDefNode *node); |
114 |
|
|
virtual std::any visitExtDecl(const ExtDeclNode *node); |
115 |
|
|
virtual std::any visitImportDef(const ImportDefNode *node); |
116 |
|
|
virtual std::any visitUnsafeBlockDef(const UnsafeBlockNode *node); |
117 |
|
|
virtual std::any visitForLoop(const ForLoopNode *node); |
118 |
|
|
virtual std::any visitForeachLoop(const ForeachLoopNode *node); |
119 |
|
|
virtual std::any visitWhileLoop(const WhileLoopNode *node); |
120 |
|
|
virtual std::any visitDoWhileLoop(const DoWhileLoopNode *node); |
121 |
|
|
virtual std::any visitIfStmt(const IfStmtNode *node); |
122 |
|
|
virtual std::any visitElseStmt(const ElseStmtNode *node); |
123 |
|
|
virtual std::any visitSwitchStmt(const SwitchStmtNode *node); |
124 |
|
|
virtual std::any visitCaseBranch(const CaseBranchNode *node); |
125 |
|
|
virtual std::any visitDefaultBranch(const DefaultBranchNode *node); |
126 |
|
|
virtual std::any visitAnonymousBlockStmt(const AnonymousBlockStmtNode *node); |
127 |
|
|
virtual std::any visitStmtLst(const StmtLstNode *node); |
128 |
|
|
virtual std::any visitTypeLst(const TypeLstNode *node); |
129 |
|
|
virtual std::any visitTypeAltsLst(const TypeAltsLstNode *node); |
130 |
|
|
virtual std::any visitParamLst(const ParamLstNode *node); |
131 |
|
|
virtual std::any visitArgLst(const ArgLstNode *node); |
132 |
|
|
virtual std::any visitEnumItemLst(const EnumItemLstNode *node); |
133 |
|
|
virtual std::any visitEnumItem(const EnumItemNode *node); |
134 |
|
|
virtual std::any visitField(const FieldNode *node); |
135 |
|
|
virtual std::any visitSignature(const SignatureNode *node); |
136 |
|
|
virtual std::any visitDeclStmt(const DeclStmtNode *node); |
137 |
|
|
virtual std::any visitSpecifierLst(const SpecifierLstNode *node); |
138 |
|
|
virtual std::any visitSpecifier(const SpecifierNode *node); |
139 |
|
|
virtual std::any visitModAttr(const ModAttrNode *node); |
140 |
|
|
virtual std::any visitTopLevelDefinitionAttr(const TopLevelDefinitionAttrNode *node); |
141 |
|
|
virtual std::any visitLambdaAttr(const LambdaAttrNode *node); |
142 |
|
|
virtual std::any visitAttrLst(const AttrLstNode *node); |
143 |
|
|
virtual std::any visitAttr(const AttrNode *node); |
144 |
|
|
virtual std::any visitCaseConstant(const CaseConstantNode *node); |
145 |
|
|
virtual std::any visitReturnStmt(const ReturnStmtNode *node); |
146 |
|
|
virtual std::any visitBreakStmt(const BreakStmtNode *node); |
147 |
|
|
virtual std::any visitContinueStmt(const ContinueStmtNode *node); |
148 |
|
|
virtual std::any visitFallthroughStmt(const FallthroughStmtNode *node); |
149 |
|
|
virtual std::any visitAssertStmt(const AssertStmtNode *node); |
150 |
|
|
virtual std::any visitPrintfCall(const PrintfCallNode *node); |
151 |
|
|
virtual std::any visitSizeofCall(const SizeofCallNode *node); |
152 |
|
|
virtual std::any visitAlignofCall(const AlignofCallNode *node); |
153 |
|
|
virtual std::any visitLenCall(const LenCallNode *node); |
154 |
|
|
virtual std::any visitPanicCall(const PanicCallNode *node); |
155 |
|
|
virtual std::any visitSysCall(const SysCallNode *node); |
156 |
|
|
virtual std::any visitAssignExpr(const AssignExprNode *node); |
157 |
|
|
virtual std::any visitTernaryExpr(const TernaryExprNode *node); |
158 |
|
|
virtual std::any visitLogicalOrExpr(const LogicalOrExprNode *node); |
159 |
|
|
virtual std::any visitLogicalAndExpr(const LogicalAndExprNode *node); |
160 |
|
|
virtual std::any visitBitwiseOrExpr(const BitwiseOrExprNode *node); |
161 |
|
|
virtual std::any visitBitwiseXorExpr(const BitwiseXorExprNode *node); |
162 |
|
|
virtual std::any visitBitwiseAndExpr(const BitwiseAndExprNode *node); |
163 |
|
|
virtual std::any visitEqualityExpr(const EqualityExprNode *node); |
164 |
|
|
virtual std::any visitRelationalExpr(const RelationalExprNode *node); |
165 |
|
|
virtual std::any visitShiftExpr(const ShiftExprNode *node); |
166 |
|
|
virtual std::any visitAdditiveExpr(const AdditiveExprNode *node); |
167 |
|
|
virtual std::any visitMultiplicativeExpr(const MultiplicativeExprNode *node); |
168 |
|
|
virtual std::any visitCastExpr(const CastExprNode *node); |
169 |
|
|
virtual std::any visitPrefixUnaryExpr(const PrefixUnaryExprNode *node); |
170 |
|
|
virtual std::any visitPostfixUnaryExpr(const PostfixUnaryExprNode *node); |
171 |
|
|
virtual std::any visitAtomicExpr(const AtomicExprNode *node); |
172 |
|
|
virtual std::any visitValue(const ValueNode *node); |
173 |
|
|
virtual std::any visitConstant(const ConstantNode *node); |
174 |
|
|
virtual std::any visitFctCall(const FctCallNode *node); |
175 |
|
|
virtual std::any visitArrayInitialization(const ArrayInitializationNode *node); |
176 |
|
|
virtual std::any visitStructInstantiation(const StructInstantiationNode *node); |
177 |
|
|
virtual std::any visitLambdaFunc(const LambdaFuncNode *node); |
178 |
|
|
virtual std::any visitLambdaProc(const LambdaProcNode *node); |
179 |
|
|
virtual std::any visitLambdaExpr(const LambdaExprNode *node); |
180 |
|
|
virtual std::any visitDataType(const DataTypeNode *node); |
181 |
|
|
virtual std::any visitBaseDataType(const BaseDataTypeNode *node); |
182 |
|
|
virtual std::any visitCustomDataType(const CustomDataTypeNode *node); |
183 |
|
|
virtual std::any visitFunctionDataType(const FunctionDataTypeNode *node); |
184 |
|
|
}; |
185 |
|
|
|
186 |
|
|
} // namespace spice::compiler |
187 |
|
|
|