1
2
3
4
5
6 #ifndef SNGCPP_SYMBOLS_SYMBOL_CREATOR_INCLUDED
7 #define SNGCPP_SYMBOLS_SYMBOL_CREATOR_INCLUDED
8 #include <sngcpp/symbols/TypeSymbol.hpp>
9 #include <sngcpp/ast/Visitor.hpp>
10 #include <string>
11 #include <vector>
12 #include <stack>
13
14 namespace sngcpp { namespace symbols {
15
16 using namespace sngcpp::ast;
17
18 class SymbolTable;
19
20 class SymbolCreator : public sngcpp::ast::Visitor
21 {
22 public:
23 SymbolCreator(SymbolTable& symbolTable_, const std::u32string& projectName_);
24 SymbolCreator(const SymbolCreator&) = delete;
25 SymbolCreator(SymbolCreator&&) = delete;
26 SymbolCreator& operator=(const SymbolCreator&) = delete;
27 SymbolCreator& operator=(SymbolCreator&&) = delete;
28 void Visit(SourceFileNode& sourceFileNode) override;
29 void Visit(SourceFileSequenceNode& sourceFileSequenceNode) override;
30 void Visit(NamespaceNode& namespaceNode) override;
31 void Visit(DeclarationSequenceNode& declarationSequenceNode) override;
32 void Visit(LinkageSpecificationNode& linkageSpecificationNode) override;
33 void Visit(TypedefNode& typedefNode) override;
34 void Visit(TypeParameterNode& typeParameterNode) override;
35 void Visit(TemplateParameterSequenceNode& templateParameterSequenceNode) override;
36 void Visit(TemplateDeclarationNode& templateDeclarationNode) override;
37 void Visit(ClassNode& classNode) override;
38 void Visit(MemberAccessDeclarationNode& memberAccessDeclarationNode);
39 void Visit(MemberDeclarationNode& memberDeclarationNode) override;
40 void Visit(ArrayDeclaratorNode& arrayDeclaratorNode) override;
41 void Visit(EnumTypeNode& enumTypeNode) override;
42 void Visit(EnumeratorNode& enumeratorNode) override;
43 void Visit(EnumeratorSequenceNode& enumeratorSequenceNode) override;
44 void Visit(IdentifierNode& identifierNode) override;
45 void Visit(TemplateIdNode& templateIdNode) override;
46 void Visit(TemplateArgumentNode& templateArgumentNode) override;
47 void Visit(OperatorFunctionIdNode& operatorFunctionIdNode) override;
48 void Visit(ConversionFunctionIdNode& conversionFunctionIdNode) override;
49 void Visit(NestedIdNode& nestedIdNode) override;
50 void Visit(DtorIdNode& dDtorIdNode) override;
51 void Visit(SimpleDeclarationNode& simpleDeclarationNode) override;
52 void Visit(InitDeclaratorNode& initDeclaratorNode) override;
53 void Visit(FunctionDeclaratorNode& functionDeclaratorNode) override;
54 void Visit(FunctionPtrIdNode& functionPtrIdNode) override;
55 void Visit(MemberFunctionPtrIdNode& memberFunctionPtrIdNode) override;
56 void Visit(FunctionNode& functionNode) override;
57 void Visit(SpecialMemberFunctionNode& specialMemberFunctionNode) override;
58 void Visit(LabeledStatementNode& labeledStatementNode) override;
59 void Visit(CompoundStatementNode& compoundStatementNode) override;
60 void Visit(StatementSequenceNode& statementSequenceNode) override;
61 void Visit(DeclarationStatementNode& declarationStatementNode) override;
62 void Visit(IfStatementNode& ifStatementNode) override;
63 void Visit(SwitchStatementNode& switchStatementNode) override;
64 void Visit(CaseStatementNode& caseStatementNode) override;
65 void Visit(DefaultStatementNode& defaultStatementNode) override;
66 void Visit(WhileStatementNode& whileStatementNode) override;
67 void Visit(DoStatementNode& doStatementNode) override;
68 void Visit(RangeForStatementNode& rangeForStatementNode) override;
69 void Visit(ForStatementNode& forStatementNode) override;
70 void Visit(ReturnStatementNode& returnStatementNode) override;
71 void Visit(TryStatementNode& tryStatementNode) override;
72 void Visit(HandlerNode& handlerNode) override;
73 void Visit(HandlerSequenceNode& handlerSequenceNode) override;
74 void Visit(IdDeclaratorNode& idDeclaratorNode) override;
75 void Visit(ParameterNode& parameterNode) override;
76 void Visit(ParameterSequenceNode& parameterSequenceNode) override;
77 void Visit(ExpressionStatementNode& expressionStatementNode) override;
78 void Visit(CommaExpressionNode& commaExpressionNode) override;
79 void Visit(AssignmentExpressionNode& assignmentExpressionNode) override;
80 void Visit(ConditionalExpressionNode& conditionalExpressionNode) override;
81 void Visit(ThrowExpressionNode& throwExpressionNode) override;
82 void Visit(LogicalOrExpressionNode& logicalOrExpressionNode) override;
83 void Visit(LogicalAndExpressionNode& logicalAndExpressionNode) override;
84 void Visit(InclusiveOrExpressionNode& inclusiveOrExpressionNode) override;
85 void Visit(ExclusiveOrExpressionNode& exclusiveOrExpressionNode) override;
86 void Visit(AndExpressionNode& andExpressionNode) override;
87 void Visit(EqualityExpressionNode& equalityExpressionNode) override;
88 void Visit(RelationalExpressionNode& relationalExpressionNode) override;
89 void Visit(ShiftExpressionNode& shiftExpressionNode) override;
90 void Visit(AdditiveExpressionNode& additiveExpressionNode) override;
91 void Visit(MultiplicativeExpressionNode& multiplicativeExpressionNode) override;
92 void Visit(PMExpressionNode& pmExpressionNode) override;
93 void Visit(CastExpressionNode& castExpressionNode) override;
94 void Visit(UnaryExpressionNode& unaryExpressionNode) override;
95 void Visit(NewExpressionNode& newExpressionNode) override;
96 void Visit(DeleteExpressionNode& deleteExpressionNode) override;
97 void Visit(SubscriptExpressionNode& subscriptExpressionNode) override;
98 void Visit(DotNode& dotNode) override;
99 void Visit(ExpressionSequenceNode& expressionSequenceNode) override;
100 void Visit(InvokeExpressionNode& invokeExpressionNode) override;
101 void Visit(AssignmentInitializerNode& assignmentInitializerNode) override;
102 void Visit(ExpressionListInitializerNode& expressionListInitializerNode) override;
103 void Visit(ExpressionInitializerNode& expressionInitializerNode) override;
104 void Visit(BracedInitializerListNode& bracedInitializerListNode) override;
105 void Visit(LambdaExpressionNode& lambdaExpressionNode) override;
106 void Visit(CaptureSequenceNode& captureSequenceNode) override;
107 void Visit(IdentifierCaptureNode& identifierCaptureNode) override;
108 void SetCpp2CmMode() { cpp2cmMode = true; }
109 private:
110 SymbolTable& symbolTable;
111 std::u32string projectName;
112 std::vector<std::std::pair<std::u32string, int>>nameSequence;
113 std::vector<std::std::unique_ptr<TypeSymbol>>templateParameters;
114 std::u32string groupName;
115 bool functionBodyFollowsOrIsPureDeletedOrDefault;
116 int nameSequenceCount;
117 bool wasFunctionDeclaration;
118 bool wasArrayDeclaration;
119 bool skip;
120 bool processingTemplateArguments;
121 bool cpp2cmMode;
122 Specifier specifiers;
123 };
124
125 } }
126
127 #endif // SNGCPP_SYMBOLS_SYMBOL_CREATOR_INCLUDED
128