1
2
3
4
5
6 #include <sngcpp/ast/Node.hpp>
7 #include <sngcpp/ast/Class.hpp>
8 #include <sngcpp/ast/Declaration.hpp>
9 #include <sngcpp/ast/Enumeration.hpp>
10 #include <sngcpp/ast/Expression.hpp>
11 #include <sngcpp/ast/Function.hpp>
12 #include <sngcpp/ast/Namespace.hpp>
13 #include <sngcpp/ast/SourceFile.hpp>
14 #include <sngcpp/ast/Template.hpp>
15 #include <sngcpp/ast/TypeExpr.hpp>
16 #include <sngcpp/ast/Writer.hpp>
17 #include <sngcpp/ast/Reader.hpp>
18 #include <algorithm>
19
20 namespace sngcpp { namespace ast {
21
22 NodeCreator::~NodeCreator()
23 {
24 }
25
26 template<class T>
27 class ConcreteNodeCreator : public NodeCreator
28 {
29 public:
30 Node* Create() override
31 {
32 return new T();
33 }
34 };
35
36 Node::Node(NodeType nodeType_) : nodeType(nodeType_), parent(nullptr)
37 {
38 }
39
40 Node::Node(NodeType nodeType_, const Span& span_) : nodeType(nodeType_), span(span_), parent(nullptr)
41 {
42 }
43
44 void Node::Write(Writer& writer)
45 {
46 writer.Write(nodeType);
47 writer.Write(span);
48 }
49
50 void Node::Read(Reader& reader)
51 {
52 reader.Read(span);
53 }
54
55 void Node::SetFullSpan()
56 {
57 }
58
59 Node::~Node()
60 {
61 }
62
63 UnaryNode::UnaryNode(NodeType nodeType_) : Node(nodeType_)
64 {
65 }
66
67 UnaryNode::UnaryNode(NodeType nodeType_, const Span& span_) : Node(nodeType_, span_)
68 {
69 }
70
71 UnaryNode::UnaryNode(NodeType nodeType_, const Span& span_, Node* child_) : Node(nodeType_, span_), child(child_)
72 {
73 if (child)
74 {
75 child->SetParent(this);
76 }
77 }
78
79 void UnaryNode::Write(Writer& writer)
80 {
81 Node::Write(writer);
82 writer.GetBinaryWriter().Write(child != nullptr);
83 if (child)
84 {
85 child->Write(writer);
86 }
87 }
88
89 void UnaryNode::Read(Reader& reader)
90 {
91 Node::Read(reader);
92 bool hasChild = reader.GetBinaryReader().ReadBool();
93 if (hasChild)
94 {
95 child.reset(reader.ReadNode());
96 child->SetParent(this);
97 }
98 }
99
100 void UnaryNode::SetFullSpan()
101 {
102 if (child)
103 {
104 const Span& thisSpan = GetSpan();
105 child->SetFullSpan();
106 const Span& childSpan = child->GetSpan();
107 SetSpanStart(std::min(thisSpan.start, childSpan.start));
108 SetSpanEnd(std::max(thisSpan.end, childSpan.end));
109 }
110 }
111
112 BinaryNode::BinaryNode(NodeType nodeType_) : Node(nodeType_)
113 {
114 }
115
116 BinaryNode::BinaryNode(NodeType nodeType_, const Span& span_, Node* left_, Node* right_) : Node(nodeType_, span_), left(left_), right(right_)
117 {
118 if (left)
119 {
120 left->SetParent(this);
121 }
122 right->SetParent(this);
123 }
124
125 void BinaryNode::Write(Writer& writer)
126 {
127 Node::Write(writer);
128 bool hasLeft = left != nullptr;
129 writer.GetBinaryWriter().Write(hasLeft);
130 if (hasLeft)
131 {
132 left->Write(writer);
133 }
134 right->Write(writer);
135 }
136
137 void BinaryNode::Read(Reader& reader)
138 {
139 Node::Read(reader);
140 bool hasLeft = reader.GetBinaryReader().ReadBool();
141 if (hasLeft)
142 {
143 left.reset(reader.ReadNode());
144 left->SetParent(this);
145 }
146 right.reset(reader.ReadNode());
147 right->SetParent(this);
148 }
149
150 void BinaryNode::SetFullSpan()
151 {
152 if (!left) return;
153 const Span& thisSpan = GetSpan();
154 left->SetFullSpan();
155 right->SetFullSpan();
156 const Span& leftSpan = left->GetSpan();
157 const Span& rightSpan = right->GetSpan();
158 SetSpanStart(std::min(thisSpan.start, std::min(leftSpan.start, rightSpan.start)));
159 SetSpanEnd(std::max(thisSpan.end, std::max(leftSpan.end, rightSpan.end)));
160 }
161
162 std::unique_ptr<NodeFactory> NodeFactory::instance;
163
164 void NodeFactory::Init()
165 {
166 instance.reset(new NodeFactory());
167 }
168
169 void NodeFactory::Done()
170 {
171 instance.reset();
172 }
173
174 NodeFactory& NodeFactory::Instance()
175 {
176 return *instance;
177 }
178
179 NodeFactory::NodeFactory()
180 {
181 creators.resize(static_cast<int>(NodeType::max));
182 creators[static_cast<int>(NodeType::baseClassSpecifierNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<BaseClassSpecifierNode>());
183 creators[static_cast<int>(NodeType::baseClassSpecifierSequenceNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<BaseClassSpecifierSequenceNode>());
184 creators[static_cast<int>(NodeType::forwardClassDeclarationNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<ForwardClassDeclarationNode>());
185 creators[static_cast<int>(NodeType::elaborateClassNameNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<ElaborateClassNameNode>());
186 creators[static_cast<int>(NodeType::classNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<ClassNode>());
187 creators[static_cast<int>(NodeType::memberAccessDeclarationNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<MemberAccessDeclarationNode>());
188 creators[static_cast<int>(NodeType::memberDeclarationNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<MemberDeclarationNode>());
189 creators[static_cast<int>(NodeType::specialMemberFunctionNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<SpecialMemberFunctionNode>());
190 creators[static_cast<int>(NodeType::ctorInitializerNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<CtorInitializerNode>());
191 creators[static_cast<int>(NodeType::memberInitializerNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<MemberInitializerNode>());
192 creators[static_cast<int>(NodeType::memberInitializerSequenceNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<MemberInitializerSequenceNode>());
193 creators[static_cast<int>(NodeType::simpleDeclarationNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<SimpleDeclarationNode>());
194 creators[static_cast<int>(NodeType::aliasDeclarationNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<AliasDeclarationNode>());
195 creators[static_cast<int>(NodeType::usingDirectiveNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<UsingDirectiveNode>());
196 creators[static_cast<int>(NodeType::usingDeclarationNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<UsingDeclarationNode>());
197 creators[static_cast<int>(NodeType::typedefNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<TypedefNode>());
198 creators[static_cast<int>(NodeType::declarationSequenceNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<DeclarationSequenceNode>());
199 creators[static_cast<int>(NodeType::linkageSpecificationNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<LinkageSpecificationNode>());
200 creators[static_cast<int>(NodeType::idDeclaratorNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<IdDeclaratorNode>());
201 creators[static_cast<int>(NodeType::arrayDeclaratorNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<ArrayDeclaratorNode>());
202 creators[static_cast<int>(NodeType::functionDeclaratorNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<FunctionDeclaratorNode>());
203 creators[static_cast<int>(NodeType::functionPtrIdNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<FunctionPtrIdNode>());
204 creators[static_cast<int>(NodeType::memberFunctionPtrIdNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<MemberFunctionPtrIdNode>());
205 creators[static_cast<int>(NodeType::initDeclaratorNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<InitDeclaratorNode>());
206 creators[static_cast<int>(NodeType::assignmentInitializerNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<AssignmentInitializerNode>());
207 creators[static_cast<int>(NodeType::expressionListInitializerNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<ExpressionListInitializerNode>());
208 creators[static_cast<int>(NodeType::expressionInitializerNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<ExpressionInitializerNode>());
209 creators[static_cast<int>(NodeType::bracedInitializerListNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<BracedInitializerListNode>());
210 creators[static_cast<int>(NodeType::enumTypeNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<EnumTypeNode>());
211 creators[static_cast<int>(NodeType::enumeratorNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<EnumeratorNode>());
212 creators[static_cast<int>(NodeType::enumeratorSequenceNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<EnumeratorSequenceNode>());
213 creators[static_cast<int>(NodeType::expressionSequenceNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<ExpressionSequenceNode>());
214 creators[static_cast<int>(NodeType::commaExpressionNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<CommaExpressionNode>());
215 creators[static_cast<int>(NodeType::assignmentExpressionNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<AssignmentExpressionNode>());
216 creators[static_cast<int>(NodeType::conditionalExpressionNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<ConditionalExpressionNode>());
217 creators[static_cast<int>(NodeType::throwExpressionNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<ThrowExpressionNode>());
218 creators[static_cast<int>(NodeType::logicalOrExpressionNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<LogicalOrExpressionNode>());
219 creators[static_cast<int>(NodeType::logicalAndExpressionNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<LogicalAndExpressionNode>());
220 creators[static_cast<int>(NodeType::inclusiveOrExpressionNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<InclusiveOrExpressionNode>());
221 creators[static_cast<int>(NodeType::exclusiveOrExpressionNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<ExclusiveOrExpressionNode>());
222 creators[static_cast<int>(NodeType::andExpressionNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<AndExpressionNode>());
223 creators[static_cast<int>(NodeType::equalityExpressionNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<EqualityExpressionNode>());
224 creators[static_cast<int>(NodeType::relationalExpressionNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<RelationalExpressionNode>());
225 creators[static_cast<int>(NodeType::shiftExpressionNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<ShiftExpressionNode>());
226 creators[static_cast<int>(NodeType::additiveExpressionNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<AdditiveExpressionNode>());
227 creators[static_cast<int>(NodeType::multiplicativeExpressionNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<MultiplicativeExpressionNode>());
228 creators[static_cast<int>(NodeType::pmExpressionNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<PMExpressionNode>());
229 creators[static_cast<int>(NodeType::castExpressionNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<CastExpressionNode>());
230 creators[static_cast<int>(NodeType::unaryExpressionNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<UnaryExpressionNode>());
231 creators[static_cast<int>(NodeType::newExpressionNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<NewExpressionNode>());
232 creators[static_cast<int>(NodeType::deleteExpressionNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<DeleteExpressionNode>());
233 creators[static_cast<int>(NodeType::subscriptExpressionNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<SubscriptExpressionNode>());
234 creators[static_cast<int>(NodeType::invokeExpressionNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<InvokeExpressionNode>());
235 creators[static_cast<int>(NodeType::dotNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<DotNode>());
236 creators[static_cast<int>(NodeType::arrowNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<ArrowNode>());
237 creators[static_cast<int>(NodeType::postfixIncNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<PostfixIncNode>());
238 creators[static_cast<int>(NodeType::postfixDecNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<PostfixDecNode>());
239 creators[static_cast<int>(NodeType::cppCastExpressionNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<CppCastExpressionNode>());
240 creators[static_cast<int>(NodeType::typeIdExpressionNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<TypeIdExpressionNode>());
241 creators[static_cast<int>(NodeType::thisNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<ThisNode>());
242 creators[static_cast<int>(NodeType::identifierNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<IdentifierNode>());
243 creators[static_cast<int>(NodeType::operatorFunctionIdNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<OperatorFunctionIdNode>());
244 creators[static_cast<int>(NodeType::conversionFunctionIdNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<ConversionFunctionIdNode>());
245 creators[static_cast<int>(NodeType::dtorIdNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<DtorIdNode>());
246 creators[static_cast<int>(NodeType::nestedIdNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<NestedIdNode>());
247 creators[static_cast<int>(NodeType::parenthesizedExprNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<ParenthesizedExprNode>());
248 creators[static_cast<int>(NodeType::lambdaExpressionNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<LambdaExpressionNode>());
249 creators[static_cast<int>(NodeType::captureSequenceNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<CaptureSequenceNode>());
250 creators[static_cast<int>(NodeType::assignCaptureNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<AssignCaptureNode>());
251 creators[static_cast<int>(NodeType::refCaptureNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<RefCaptureNode>());
252 creators[static_cast<int>(NodeType::thisCaptureNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<ThisCaptureNode>());
253 creators[static_cast<int>(NodeType::identifierCaptureNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<IdentifierCaptureNode>());
254 creators[static_cast<int>(NodeType::parameterNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<ParameterNode>());
255 creators[static_cast<int>(NodeType::parameterSequenceNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<ParameterSequenceNode>());
256 creators[static_cast<int>(NodeType::functionNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<FunctionNode>());
257 creators[static_cast<int>(NodeType::floatingLiteralNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<FloatingLiteralNode>());
258 creators[static_cast<int>(NodeType::integerLiteralNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<IntegerLiteralNode>());
259 creators[static_cast<int>(NodeType::characterLiteralNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<CharacterLiteralNode>());
260 creators[static_cast<int>(NodeType::stringLiteralNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<StringLiteralNode>());
261 creators[static_cast<int>(NodeType::booleanLiteralNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<BooleanLiteralNode>());
262 creators[static_cast<int>(NodeType::nullPtrLiteralNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<NullPtrLiteralNode>());
263 creators[static_cast<int>(NodeType::namespaceNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<NamespaceNode>());
264 creators[static_cast<int>(NodeType::simpleTypeNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<SimpleTypeNode>());
265 creators[static_cast<int>(NodeType::sourceFileNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<SourceFileNode>());
266 creators[static_cast<int>(NodeType::sourceFileSequenceNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<SourceFileSequenceNode>());
267 creators[static_cast<int>(NodeType::labeledStatementNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<LabeledStatementNode>());
268 creators[static_cast<int>(NodeType::caseStatementNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<CaseStatementNode>());
269 creators[static_cast<int>(NodeType::defaultStatementNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<DefaultStatementNode>());
270 creators[static_cast<int>(NodeType::expressionStatementNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<ExpressionStatementNode>());
271 creators[static_cast<int>(NodeType::compoundStatementNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<CompoundStatementNode>());
272 creators[static_cast<int>(NodeType::statementSequenceNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<StatementSequenceNode>());
273 creators[static_cast<int>(NodeType::ifStatementNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<IfStatementNode>());
274 creators[static_cast<int>(NodeType::switchStatementNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<SwitchStatementNode>());
275 creators[static_cast<int>(NodeType::whileStatementNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<WhileStatementNode>());
276 creators[static_cast<int>(NodeType::doStatementNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<DoStatementNode>());
277 creators[static_cast<int>(NodeType::rangeForStatementNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<RangeForStatementNode>());
278 creators[static_cast<int>(NodeType::forStatementNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<ForStatementNode>());
279 creators[static_cast<int>(NodeType::breakStatementNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<BreakStatementNode>());
280 creators[static_cast<int>(NodeType::continueStatementNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<ContinueStatementNode>());
281 creators[static_cast<int>(NodeType::returnStatementNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<ReturnStatementNode>());
282 creators[static_cast<int>(NodeType::gotoStatementNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<GotoStatementNode>());
283 creators[static_cast<int>(NodeType::declarationStatementNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<DeclarationStatementNode>());
284 creators[static_cast<int>(NodeType::tryStatementNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<TryStatementNode>());
285 creators[static_cast<int>(NodeType::handlerNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<HandlerNode>());
286 creators[static_cast<int>(NodeType::handlerSequenceNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<HandlerSequenceNode>());
287 creators[static_cast<int>(NodeType::catchAllNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<CatchAllNode>());
288 creators[static_cast<int>(NodeType::typeParameterNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<TypeParameterNode>());
289 creators[static_cast<int>(NodeType::templateParameterSequenceNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<TemplateParameterSequenceNode>());
290 creators[static_cast<int>(NodeType::templateDeclarationNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<TemplateDeclarationNode>());
291 creators[static_cast<int>(NodeType::templateArgumentSequenceNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<TemplateArgumentSequenceNode>());
292 creators[static_cast<int>(NodeType::templateIdNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<TemplateIdNode>());
293 creators[static_cast<int>(NodeType::templateArgumentNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<TemplateArgumentNode>());
294 creators[static_cast<int>(NodeType::explicitInstantiationNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<ExplicitInstantiationNode>());
295 creators[static_cast<int>(NodeType::explicitSpecializationNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<ExplicitSpecializationNode>());
296 creators[static_cast<int>(NodeType::constNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<ConstNode>());
297 creators[static_cast<int>(NodeType::volatileNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<VolatileNode>());
298 creators[static_cast<int>(NodeType::pointerNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<PointerNode>());
299 creators[static_cast<int>(NodeType::rValueRefNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<RValueRefNode>());
300 creators[static_cast<int>(NodeType::lValueRefNode)] = std::unique_ptr<NodeCreator>(new ConcreteNodeCreator<LValueRefNode>());
301 }
302
303 Node* NodeFactory::CreateNode(NodeType nodeType)
304 {
305 NodeCreator* creator = creators[static_cast<int>(nodeType)].get();
306 return creator->Create();
307 }
308
309 void NodeInit()
310 {
311 NodeFactory::Init();
312 }
313
314 void NodeDone()
315 {
316 NodeFactory::Done();
317 }
318
319 } }
320