1
2
3
4
5
6 #include <sngcm/ast/Expression.hpp>
7 #include <sngcm/ast/Identifier.hpp>
8 #include <sngcm/ast/Visitor.hpp>
9
10 namespace sngcm { namespace ast {
11
12 DotNode::DotNode(const Span& span_, const boost::uuids::uuid& moduleId_) : UnaryNode(NodeType::dotNode, span_, moduleId_), memberId()
13 {
14 }
15
16 DotNode::DotNode(const Span& span_, const boost::uuids::uuid& moduleId_, Node* subject_, IdentifierNode* memberId_) : UnaryNode(NodeType::dotNode, span_, moduleId_, subject_), memberId(memberId_)
17 {
18 memberId->SetParent(this);
19 }
20
21 Node* DotNode::Clone(CloneContext& cloneContext) const
22 {
23 DotNode* clone = new DotNode(GetSpan(), ModuleId(), Subject()->Clone(cloneContext), static_cast<IdentifierNode*>(memberId->Clone(cloneContext)));
24 return clone;
25 }
26
27 void DotNode::Accept(Visitor& visitor)
28 {
29 visitor.Visit(*this);
30 }
31
32 void DotNode::Write(AstWriter& writer)
33 {
34 UnaryNode::Write(writer);
35 writer.Write(memberId.get());
36 }
37
38 void DotNode::Read(AstReader& reader)
39 {
40 UnaryNode::Read(reader);
41 memberId.reset(reader.ReadIdentifierNode());
42 memberId->SetParent(this);
43 }
44
45 std::string DotNode::ToString() const
46 {
47 return Subject()->ToString() + "." + memberId->ToString();
48 }
49
50 ArrowNode::ArrowNode(const Span& span_, const boost::uuids::uuid& moduleId_) : UnaryNode(NodeType::arrowNode, span_, moduleId_), memberId()
51 {
52 }
53
54 ArrowNode::ArrowNode(const Span& span_, const boost::uuids::uuid& moduleId_, Node* subject_, IdentifierNode* memberId_) :
55 UnaryNode(NodeType::arrowNode, span_, moduleId_, subject_), memberId(memberId_)
56 {
57 memberId->SetParent(this);
58 }
59
60 Node* ArrowNode::Clone(CloneContext& cloneContext) const
61 {
62 ArrowNode* clone = new ArrowNode(GetSpan(), ModuleId(), Subject()->Clone(cloneContext), static_cast<IdentifierNode*>(memberId->Clone(cloneContext)));
63 return clone;
64 }
65
66 void ArrowNode::Accept(Visitor& visitor)
67 {
68 visitor.Visit(*this);
69 }
70
71 void ArrowNode::Write(AstWriter& writer)
72 {
73 UnaryNode::Write(writer);
74 writer.Write(memberId.get());
75 }
76
77 void ArrowNode::Read(AstReader& reader)
78 {
79 UnaryNode::Read(reader);
80 memberId.reset(reader.ReadIdentifierNode());
81 memberId->SetParent(this);
82 }
83
84 std::string ArrowNode::ToString() const
85 {
86 return Subject()->ToString() + "->" + memberId->ToString();
87 }
88
89 EquivalenceNode::EquivalenceNode(const Span& span_, const boost::uuids::uuid& moduleId_) : BinaryNode(NodeType::equivalenceNode, span_, moduleId_)
90 {
91 }
92
93 EquivalenceNode::EquivalenceNode(const Span& span_, const boost::uuids::uuid& moduleId_, Node* left_, Node* right_) :
94 BinaryNode(NodeType::equivalenceNode, span_, moduleId_, left_, right_)
95 {
96 }
97
98 Node* EquivalenceNode::Clone(CloneContext& cloneContext) const
99 {
100 EquivalenceNode* clone = new EquivalenceNode(GetSpan(), ModuleId(), Left()->Clone(cloneContext), Right()->Clone(cloneContext));
101 return clone;
102 }
103
104 void EquivalenceNode::Accept(Visitor& visitor)
105 {
106 visitor.Visit(*this);
107 }
108
109 std::string EquivalenceNode::ToString() const
110 {
111 return Left()->ToString() + "<=>" + Right()->ToString();
112 }
113
114 ImplicationNode::ImplicationNode(const Span& span_, const boost::uuids::uuid& moduleId_) : BinaryNode(NodeType::implicationNode, span_, moduleId_)
115 {
116 }
117
118 ImplicationNode::ImplicationNode(const Span& span_, const boost::uuids::uuid& moduleId_, Node* left_, Node* right_) :
119 BinaryNode(NodeType::implicationNode, span_, moduleId_, left_, right_)
120 {
121 }
122
123 Node* ImplicationNode::Clone(CloneContext& cloneContext) const
124 {
125 ImplicationNode* clone = new ImplicationNode(GetSpan(), ModuleId(), Left()->Clone(cloneContext), Right()->Clone(cloneContext));
126 return clone;
127 }
128
129 void ImplicationNode::Accept(Visitor& visitor)
130 {
131 visitor.Visit(*this);
132 }
133
134 std::string ImplicationNode::ToString() const
135 {
136 return Left()->ToString() + "=>" + Right()->ToString();
137 }
138
139 DisjunctionNode::DisjunctionNode(const Span& span_, const boost::uuids::uuid& moduleId_) : BinaryNode(NodeType::disjunctionNode, span_, moduleId_)
140 {
141 }
142
143 DisjunctionNode::DisjunctionNode(const Span& span_, const boost::uuids::uuid& moduleId_, Node* left_, Node* right_) :
144 BinaryNode(NodeType::disjunctionNode, span_, moduleId_, left_, right_)
145 {
146 }
147
148 Node* DisjunctionNode::Clone(CloneContext& cloneContext) const
149 {
150 DisjunctionNode* clone = new DisjunctionNode(GetSpan(), ModuleId(), Left()->Clone(cloneContext), Right()->Clone(cloneContext));
151 return clone;
152 }
153
154 void DisjunctionNode::Accept(Visitor& visitor)
155 {
156 visitor.Visit(*this);
157 }
158
159 std::string DisjunctionNode::ToString() const
160 {
161 return Left()->ToString() + " || " + Right()->ToString();
162 }
163
164 ConjunctionNode::ConjunctionNode(const Span& span_, const boost::uuids::uuid& moduleId_) : BinaryNode(NodeType::conjunctionNode, span_, moduleId_)
165 {
166 }
167
168 ConjunctionNode::ConjunctionNode(const Span& span_, const boost::uuids::uuid& moduleId_, Node* left_, Node* right_) :
169 BinaryNode(NodeType::conjunctionNode, span_, moduleId_, left_, right_)
170 {
171 }
172
173 Node* ConjunctionNode::Clone(CloneContext& cloneContext) const
174 {
175 ConjunctionNode* clone = new ConjunctionNode(GetSpan(), ModuleId(), Left()->Clone(cloneContext), Right()->Clone(cloneContext));
176 return clone;
177 }
178
179 void ConjunctionNode::Accept(Visitor& visitor)
180 {
181 visitor.Visit(*this);
182 }
183
184 std::string ConjunctionNode::ToString() const
185 {
186 return Left()->ToString() + " && " + Right()->ToString();
187 }
188
189 BitOrNode::BitOrNode(const Span& span_, const boost::uuids::uuid& moduleId_) : BinaryNode(NodeType::bitOrNode, span_, moduleId_)
190 {
191 }
192
193 BitOrNode::BitOrNode(const Span& span_, const boost::uuids::uuid& moduleId_, Node* left_, Node* right_) : BinaryNode(NodeType::bitOrNode, span_, moduleId_, left_, right_)
194 {
195 }
196
197 Node* BitOrNode::Clone(CloneContext& cloneContext) const
198 {
199 BitOrNode* clone = new BitOrNode(GetSpan(), ModuleId(), Left()->Clone(cloneContext), Right()->Clone(cloneContext));
200 return clone;
201 }
202
203 void BitOrNode::Accept(Visitor& visitor)
204 {
205 visitor.Visit(*this);
206 }
207
208 std::string BitOrNode::ToString() const
209 {
210 return Left()->ToString() + " | " + Right()->ToString();
211 }
212
213 BitXorNode::BitXorNode(const Span& span_, const boost::uuids::uuid& moduleId_) : BinaryNode(NodeType::bitXorNode, span_, moduleId_)
214 {
215 }
216
217 BitXorNode::BitXorNode(const Span& span_, const boost::uuids::uuid& moduleId_, Node* left_, Node* right_) :
218 BinaryNode(NodeType::bitXorNode, span_, moduleId_, left_, right_)
219 {
220 }
221
222 Node* BitXorNode::Clone(CloneContext& cloneContext) const
223 {
224 BitXorNode* clone = new BitXorNode(GetSpan(), ModuleId(), Left()->Clone(cloneContext), Right()->Clone(cloneContext));
225 return clone;
226 }
227
228 void BitXorNode::Accept(Visitor& visitor)
229 {
230 visitor.Visit(*this);
231 }
232
233 std::string BitXorNode::ToString() const
234 {
235 return Left()->ToString() + " ^ " + Right()->ToString();
236 }
237
238 BitAndNode::BitAndNode(const Span& span_, const boost::uuids::uuid& moduleId_) : BinaryNode(NodeType::bitAndNode, span_, moduleId_)
239 {
240 }
241
242 BitAndNode::BitAndNode(const Span& span_, const boost::uuids::uuid& moduleId_, Node* left_, Node* right_) :
243 BinaryNode(NodeType::bitAndNode, span_, moduleId_, left_, right_)
244 {
245 }
246
247 Node* BitAndNode::Clone(CloneContext& cloneContext) const
248 {
249 BitAndNode* clone = new BitAndNode(GetSpan(), ModuleId(), Left()->Clone(cloneContext), Right()->Clone(cloneContext));
250 return clone;
251 }
252
253 void BitAndNode::Accept(Visitor& visitor)
254 {
255 visitor.Visit(*this);
256 }
257
258 std::string BitAndNode::ToString() const
259 {
260 return Left()->ToString() + " & " + Right()->ToString();
261 }
262
263 EqualNode::EqualNode(const Span& span_, const boost::uuids::uuid& moduleId_) : BinaryNode(NodeType::equalNode, span_, moduleId_)
264 {
265 }
266
267 EqualNode::EqualNode(const Span& span_, const boost::uuids::uuid& moduleId_, Node* left_, Node* right_) :
268 BinaryNode(NodeType::equalNode, span_, moduleId_, left_, right_)
269 {
270 }
271
272 Node* EqualNode::Clone(CloneContext& cloneContext) const
273 {
274 EqualNode* clone = new EqualNode(GetSpan(), ModuleId(), Left()->Clone(cloneContext), Right()->Clone(cloneContext));
275 return clone;
276 }
277
278 void EqualNode::Accept(Visitor& visitor)
279 {
280 visitor.Visit(*this);
281 }
282
283 std::string EqualNode::ToString() const
284 {
285 return Left()->ToString() + " == " + Right()->ToString();
286 }
287
288 NotEqualNode::NotEqualNode(const Span& span_, const boost::uuids::uuid& moduleId_) : BinaryNode(NodeType::notEqualNode, span_, moduleId_)
289 {
290 }
291
292 NotEqualNode::NotEqualNode(const Span& span_, const boost::uuids::uuid& moduleId_, Node* left_, Node* right_) : BinaryNode(NodeType::notEqualNode, span_, moduleId_, left_, right_)
293 {
294 }
295
296 Node* NotEqualNode::Clone(CloneContext& cloneContext) const
297 {
298 NotEqualNode* clone = new NotEqualNode(GetSpan(), ModuleId(), Left()->Clone(cloneContext), Right()->Clone(cloneContext));
299 return clone;
300 }
301
302 void NotEqualNode::Accept(Visitor& visitor)
303 {
304 visitor.Visit(*this);
305 }
306
307 std::string NotEqualNode::ToString() const
308 {
309 return Left()->ToString() + " != " + Right()->ToString();
310 }
311
312 LessNode::LessNode(const Span& span_, const boost::uuids::uuid& moduleId_) : BinaryNode(NodeType::lessNode, span_, moduleId_)
313 {
314 }
315
316 LessNode::LessNode(const Span& span_, const boost::uuids::uuid& moduleId_, Node* left_, Node* right_) : BinaryNode(NodeType::lessNode, span_, moduleId_, left_, right_)
317 {
318 }
319
320 Node* LessNode::Clone(CloneContext& cloneContext) const
321 {
322 LessNode* clone = new LessNode(GetSpan(), ModuleId(), Left()->Clone(cloneContext), Right()->Clone(cloneContext));
323 return clone;
324 }
325
326 void LessNode::Accept(Visitor& visitor)
327 {
328 visitor.Visit(*this);
329 }
330
331 std::string LessNode::ToString() const
332 {
333 return Left()->ToString() + " < " + Right()->ToString();
334 }
335
336 GreaterNode::GreaterNode(const Span& span_, const boost::uuids::uuid& moduleId_) : BinaryNode(NodeType::greaterNode, span_, moduleId_)
337 {
338 }
339
340 GreaterNode::GreaterNode(const Span& span_, const boost::uuids::uuid& moduleId_, Node* left_, Node* right_) : BinaryNode(NodeType::greaterNode, span_, moduleId_, left_, right_)
341 {
342 }
343
344 Node* GreaterNode::Clone(CloneContext& cloneContext) const
345 {
346 GreaterNode* clone = new GreaterNode(GetSpan(), ModuleId(), Left()->Clone(cloneContext), Right()->Clone(cloneContext));
347 return clone;
348 }
349
350 void GreaterNode::Accept(Visitor& visitor)
351 {
352 visitor.Visit(*this);
353 }
354
355 std::string GreaterNode::ToString() const
356 {
357 return Left()->ToString() + " > " + Right()->ToString();
358 }
359
360 LessOrEqualNode::LessOrEqualNode(const Span& span_, const boost::uuids::uuid& moduleId_) : BinaryNode(NodeType::lessOrEqualNode, span_, moduleId_)
361 {
362 }
363
364 LessOrEqualNode::LessOrEqualNode(const Span& span_, const boost::uuids::uuid& moduleId_, Node* left_, Node* right_) :
365 BinaryNode(NodeType::lessOrEqualNode, span_, moduleId_, left_, right_)
366 {
367 }
368
369 Node* LessOrEqualNode::Clone(CloneContext& cloneContext) const
370 {
371 LessOrEqualNode* clone = new LessOrEqualNode(GetSpan(), ModuleId(), Left()->Clone(cloneContext), Right()->Clone(cloneContext));
372 return clone;
373 }
374
375 void LessOrEqualNode::Accept(Visitor& visitor)
376 {
377 visitor.Visit(*this);
378 }
379
380 std::string LessOrEqualNode::ToString() const
381 {
382 return Left()->ToString() + " <= " + Right()->ToString();
383 }
384
385 GreaterOrEqualNode::GreaterOrEqualNode(const Span& span_, const boost::uuids::uuid& moduleId_) : BinaryNode(NodeType::greaterOrEqualNode, span_, moduleId_)
386 {
387 }
388
389 GreaterOrEqualNode::GreaterOrEqualNode(const Span& span_, const boost::uuids::uuid& moduleId_, Node* left_, Node* right_) :
390 BinaryNode(NodeType::greaterOrEqualNode, span_, moduleId_, left_, right_)
391 {
392 }
393
394 Node* GreaterOrEqualNode::Clone(CloneContext& cloneContext) const
395 {
396 GreaterOrEqualNode* clone = new GreaterOrEqualNode(GetSpan(), ModuleId(), Left()->Clone(cloneContext), Right()->Clone(cloneContext));
397 return clone;
398 }
399
400 void GreaterOrEqualNode::Accept(Visitor& visitor)
401 {
402 visitor.Visit(*this);
403 }
404
405 std::string GreaterOrEqualNode::ToString() const
406 {
407 return Left()->ToString() + " >= " + Right()->ToString();
408 }
409
410 ShiftLeftNode::ShiftLeftNode(const Span& span_, const boost::uuids::uuid& moduleId_) : BinaryNode(NodeType::shiftLeftNode, span_, moduleId_)
411 {
412 }
413
414 ShiftLeftNode::ShiftLeftNode(const Span& span_, const boost::uuids::uuid& moduleId_, Node* left_, Node* right_) :
415 BinaryNode(NodeType::shiftLeftNode, span_, moduleId_, left_, right_)
416 {
417 }
418
419 Node* ShiftLeftNode::Clone(CloneContext& cloneContext) const
420 {
421 ShiftLeftNode* clone = new ShiftLeftNode(GetSpan(), ModuleId(), Left()->Clone(cloneContext), Right()->Clone(cloneContext));
422 return clone;
423 }
424
425 void ShiftLeftNode::Accept(Visitor& visitor)
426 {
427 visitor.Visit(*this);
428 }
429
430 std::string ShiftLeftNode::ToString() const
431 {
432 return Left()->ToString() + " << " + Right()->ToString();
433 }
434
435 ShiftRightNode::ShiftRightNode(const Span& span_, const boost::uuids::uuid& moduleId_) : BinaryNode(NodeType::shiftRightNode, span_, moduleId_)
436 {
437 }
438
439 ShiftRightNode::ShiftRightNode(const Span& span_, const boost::uuids::uuid& moduleId_, Node* left_, Node* right_) :
440 BinaryNode(NodeType::shiftRightNode, span_, moduleId_, left_, right_)
441 {
442 }
443
444 Node* ShiftRightNode::Clone(CloneContext& cloneContext) const
445 {
446 ShiftRightNode* clone = new ShiftRightNode(GetSpan(), ModuleId(), Left()->Clone(cloneContext), Right()->Clone(cloneContext));
447 return clone;
448 }
449
450 void ShiftRightNode::Accept(Visitor& visitor)
451 {
452 visitor.Visit(*this);
453 }
454
455 std::string ShiftRightNode::ToString() const
456 {
457 return Left()->ToString() + " >> " + Right()->ToString();
458 }
459
460 AddNode::AddNode(const Span& span_, const boost::uuids::uuid& moduleId_) : BinaryNode(NodeType::addNode, span_, moduleId_)
461 {
462 }
463
464 AddNode::AddNode(const Span& span_, const boost::uuids::uuid& moduleId_, Node* left_, Node* right_) : BinaryNode(NodeType::addNode, span_, moduleId_, left_, right_)
465 {
466 }
467
468 Node* AddNode::Clone(CloneContext& cloneContext) const
469 {
470 AddNode* clone = new AddNode(GetSpan(), ModuleId(), Left()->Clone(cloneContext), Right()->Clone(cloneContext));
471 return clone;
472 }
473
474 void AddNode::Accept(Visitor& visitor)
475 {
476 visitor.Visit(*this);
477 }
478
479 std::string AddNode::ToString() const
480 {
481 return Left()->ToString() + " + " + Right()->ToString();
482 }
483
484 SubNode::SubNode(const Span& span_, const boost::uuids::uuid& moduleId_) : BinaryNode(NodeType::subNode, span_, moduleId_)
485 {
486 }
487
488 SubNode::SubNode(const Span& span_, const boost::uuids::uuid& moduleId_, Node* left_, Node* right_) :
489 BinaryNode(NodeType::subNode, span_, moduleId_, left_, right_)
490 {
491 }
492
493 Node* SubNode::Clone(CloneContext& cloneContext) const
494 {
495 SubNode* clone = new SubNode(GetSpan(), ModuleId(), Left()->Clone(cloneContext), Right()->Clone(cloneContext));
496 return clone;
497 }
498
499 void SubNode::Accept(Visitor& visitor)
500 {
501 visitor.Visit(*this);
502 }
503
504 std::string SubNode::ToString() const
505 {
506 return Left()->ToString() + " - " + Right()->ToString();
507 }
508
509 MulNode::MulNode(const Span& span_, const boost::uuids::uuid& moduleId_) : BinaryNode(NodeType::mulNode, span_, moduleId_)
510 {
511 }
512
513 MulNode::MulNode(const Span& span_, const boost::uuids::uuid& moduleId_, Node* left_, Node* right_) :
514 BinaryNode(NodeType::mulNode, span_, moduleId_, left_, right_)
515 {
516 }
517
518 Node* MulNode::Clone(CloneContext& cloneContext) const
519 {
520 MulNode* clone = new MulNode(GetSpan(), ModuleId(), Left()->Clone(cloneContext), Right()->Clone(cloneContext));
521 return clone;
522 }
523
524 void MulNode::Accept(Visitor& visitor)
525 {
526 visitor.Visit(*this);
527 }
528
529 std::string MulNode::ToString() const
530 {
531 return Left()->ToString() + " * " + Right()->ToString();
532 }
533
534 DivNode::DivNode(const Span& span_, const boost::uuids::uuid& moduleId_) : BinaryNode(NodeType::divNode, span_, moduleId_)
535 {
536 }
537
538 DivNode::DivNode(const Span& span_, const boost::uuids::uuid& moduleId_, Node* left_, Node* right_) :
539 BinaryNode(NodeType::divNode, span_, moduleId_, left_, right_)
540 {
541 }
542
543 Node* DivNode::Clone(CloneContext& cloneContext) const
544 {
545 DivNode* clone = new DivNode(GetSpan(), ModuleId(), Left()->Clone(cloneContext), Right()->Clone(cloneContext));
546 return clone;
547 }
548
549 void DivNode::Accept(Visitor& visitor)
550 {
551 visitor.Visit(*this);
552 }
553
554 std::string DivNode::ToString() const
555 {
556 return Left()->ToString() + " / " + Right()->ToString();
557 }
558
559 RemNode::RemNode(const Span& span_, const boost::uuids::uuid& moduleId_) : BinaryNode(NodeType::remNode, span_, moduleId_)
560 {
561 }
562
563 RemNode::RemNode(const Span& span_, const boost::uuids::uuid& moduleId_, Node* left_, Node* right_) : BinaryNode(NodeType::remNode, span_, moduleId_, left_, right_)
564 {
565 }
566
567 Node* RemNode::Clone(CloneContext& cloneContext) const
568 {
569 RemNode* clone = new RemNode(GetSpan(), ModuleId(), Left()->Clone(cloneContext), Right()->Clone(cloneContext));
570 return clone;
571 }
572
573 void RemNode::Accept(Visitor& visitor)
574 {
575 visitor.Visit(*this);
576 }
577
578 std::string RemNode::ToString() const
579 {
580 return Left()->ToString() + " % " + Right()->ToString();
581 }
582
583 NotNode::NotNode(const Span& span_, const boost::uuids::uuid& moduleId_) : UnaryNode(NodeType::notNode, span_, moduleId_)
584 {
585 }
586
587 NotNode::NotNode(const Span& span_, const boost::uuids::uuid& moduleId_, Node* subject_) : UnaryNode(NodeType::notNode, span_, moduleId_, subject_)
588 {
589 }
590
591 Node* NotNode::Clone(CloneContext& cloneContext) const
592 {
593 NotNode* clone = new NotNode(GetSpan(), ModuleId(), Subject()->Clone(cloneContext));
594 return clone;
595 }
596
597 void NotNode::Accept(Visitor& visitor)
598 {
599 visitor.Visit(*this);
600 }
601
602 std::string NotNode::ToString() const
603 {
604 return "!" + Subject()->ToString();
605 }
606
607 UnaryPlusNode::UnaryPlusNode(const Span& span_, const boost::uuids::uuid& moduleId_) : UnaryNode(NodeType::unaryPlusNode, span_, moduleId_)
608 {
609 }
610
611 UnaryPlusNode::UnaryPlusNode(const Span& span_, const boost::uuids::uuid& moduleId_, Node* subject_) : UnaryNode(NodeType::unaryPlusNode, span_, moduleId_, subject_)
612 {
613 }
614
615 Node* UnaryPlusNode::Clone(CloneContext& cloneContext) const
616 {
617 UnaryPlusNode* clone = new UnaryPlusNode(GetSpan(), ModuleId(), Subject()->Clone(cloneContext));
618 return clone;
619 }
620
621 void UnaryPlusNode::Accept(Visitor& visitor)
622 {
623 visitor.Visit(*this);
624 }
625
626 std::string UnaryPlusNode::ToString() const
627 {
628 return "+" + Subject()->ToString();
629 }
630
631 UnaryMinusNode::UnaryMinusNode(const Span& span_, const boost::uuids::uuid& moduleId_) : UnaryNode(NodeType::unaryMinusNode, span_, moduleId_)
632 {
633 }
634
635 UnaryMinusNode::UnaryMinusNode(const Span& span_, const boost::uuids::uuid& moduleId_, Node* subject_) : UnaryNode(NodeType::unaryMinusNode, span_, moduleId_, subject_)
636 {
637 }
638
639 Node* UnaryMinusNode::Clone(CloneContext& cloneContext) const
640 {
641 UnaryMinusNode* clone = new UnaryMinusNode(GetSpan(), ModuleId(), Subject()->Clone(cloneContext));
642 return clone;
643 }
644
645 void UnaryMinusNode::Accept(Visitor& visitor)
646 {
647 visitor.Visit(*this);
648 }
649
650 std::string UnaryMinusNode::ToString() const
651 {
652 return "-" + Subject()->ToString();
653 }
654
655 PrefixIncrementNode::PrefixIncrementNode(const Span& span_, const boost::uuids::uuid& moduleId_) : UnaryNode(NodeType::prefixIncrementNode, span_, moduleId_)
656 {
657 }
658
659 PrefixIncrementNode::PrefixIncrementNode(const Span& span_, const boost::uuids::uuid& moduleId_, Node* subject_) :
660 UnaryNode(NodeType::prefixIncrementNode, span_, moduleId_, subject_)
661 {
662 }
663
664 Node* PrefixIncrementNode::Clone(CloneContext& cloneContext) const
665 {
666 PrefixIncrementNode* clone = new PrefixIncrementNode(GetSpan(), ModuleId(), Subject()->Clone(cloneContext));
667 return clone;
668 }
669
670 void PrefixIncrementNode::Accept(Visitor& visitor)
671 {
672 visitor.Visit(*this);
673 }
674
675 std::string PrefixIncrementNode::ToString() const
676 {
677 return "++" + Subject()->ToString();
678 }
679
680 PrefixDecrementNode::PrefixDecrementNode(const Span& span_, const boost::uuids::uuid& moduleId_) : UnaryNode(NodeType::prefixDecrementNode, span_, moduleId_)
681 {
682 }
683
684 PrefixDecrementNode::PrefixDecrementNode(const Span& span_, const boost::uuids::uuid& moduleId_, Node* subject_) :
685 UnaryNode(NodeType::prefixDecrementNode, span_, moduleId_, subject_)
686 {
687 }
688
689 Node* PrefixDecrementNode::Clone(CloneContext& cloneContext) const
690 {
691 PrefixDecrementNode* clone = new PrefixDecrementNode(GetSpan(), ModuleId(), Subject()->Clone(cloneContext));
692 return clone;
693 }
694
695 void PrefixDecrementNode::Accept(Visitor& visitor)
696 {
697 visitor.Visit(*this);
698 }
699
700 std::string PrefixDecrementNode::ToString() const
701 {
702 return "--" + Subject()->ToString();
703 }
704
705 ComplementNode::ComplementNode(const Span& span_, const boost::uuids::uuid& moduleId_) : UnaryNode(NodeType::complementNode, span_, moduleId_)
706 {
707 }
708
709 ComplementNode::ComplementNode(const Span& span_, const boost::uuids::uuid& moduleId_, Node* subject_) : UnaryNode(NodeType::complementNode, span_, moduleId_, subject_)
710 {
711 }
712
713 Node* ComplementNode::Clone(CloneContext& cloneContext) const
714 {
715 ComplementNode* clone = new ComplementNode(GetSpan(), ModuleId(), Subject()->Clone(cloneContext));
716 return clone;
717 }
718
719 void ComplementNode::Accept(Visitor& visitor)
720 {
721 visitor.Visit(*this);
722 }
723
724 std::string ComplementNode::ToString() const
725 {
726 return "~" + Subject()->ToString();
727 }
728
729 DerefNode::DerefNode(const Span& span_, const boost::uuids::uuid& moduleId_) : UnaryNode(NodeType::derefNode, span_, moduleId_)
730 {
731 }
732
733 DerefNode::DerefNode(const Span& span_, const boost::uuids::uuid& moduleId_, Node* subject_) : UnaryNode(NodeType::derefNode, span_, moduleId_, subject_)
734 {
735 }
736
737 Node* DerefNode::Clone(CloneContext& cloneContext) const
738 {
739 DerefNode* clone = new DerefNode(GetSpan(), ModuleId(), Subject()->Clone(cloneContext));
740 return clone;
741 }
742
743 void DerefNode::Accept(Visitor& visitor)
744 {
745 visitor.Visit(*this);
746 }
747
748 std::string DerefNode::ToString() const
749 {
750 return "*" + Subject()->ToString();
751 }
752
753 AddrOfNode::AddrOfNode(const Span& span_, const boost::uuids::uuid& moduleId_) : UnaryNode(NodeType::addrOfNode, span_, moduleId_)
754 {
755 }
756
757 AddrOfNode::AddrOfNode(const Span& span_, const boost::uuids::uuid& moduleId_, Node* subject_) :
758 UnaryNode(NodeType::addrOfNode, span_, moduleId_, subject_)
759 {
760 }
761
762 Node* AddrOfNode::Clone(CloneContext& cloneContext) const
763 {
764 AddrOfNode* clone = new AddrOfNode(GetSpan(), ModuleId(), Subject()->Clone(cloneContext));
765 return clone;
766 }
767
768 void AddrOfNode::Accept(Visitor& visitor)
769 {
770 visitor.Visit(*this);
771 }
772
773 std::string AddrOfNode::ToString() const
774 {
775 return "&" + Subject()->ToString();
776 }
777
778 IsNode::IsNode(const Span& span_, const boost::uuids::uuid& moduleId_) : Node(NodeType::isNode, span_, moduleId_), expr(), targetTypeExpr()
779 {
780 }
781
782 IsNode::IsNode(const Span& span_, const boost::uuids::uuid& moduleId_, Node* expr_, Node* targetTypeExpr_) :
783 Node(NodeType::isNode, span_, moduleId_), expr(expr_), targetTypeExpr(targetTypeExpr_)
784 {
785 expr->SetParent(this);
786 targetTypeExpr->SetParent(this);
787 }
788
789 Node* IsNode::Clone(CloneContext& cloneContext) const
790 {
791 IsNode* clone = new IsNode(GetSpan(), ModuleId(), expr->Clone(cloneContext), targetTypeExpr->Clone(cloneContext));
792 return clone;
793 }
794
795 void IsNode::Accept(Visitor& visitor)
796 {
797 visitor.Visit(*this);
798 }
799
800 void IsNode::Write(AstWriter& writer)
801 {
802 Node::Write(writer);
803 writer.Write(expr.get());
804 writer.Write(targetTypeExpr.get());
805 }
806
807 void IsNode::Read(AstReader& reader)
808 {
809 Node::Read(reader);
810 expr.reset(reader.ReadNode());
811 expr->SetParent(this);
812 targetTypeExpr.reset(reader.ReadNode());
813 targetTypeExpr->SetParent(this);
814 }
815
816 std::string IsNode::ToString() const
817 {
818 return expr->ToString() + " is " + targetTypeExpr->ToString();
819 }
820
821 AsNode::AsNode(const Span& span_, const boost::uuids::uuid& moduleId_) : Node(NodeType::asNode, span_, moduleId_), expr(), targetTypeExpr()
822 {
823 }
824
825 AsNode::AsNode(const Span& span_, const boost::uuids::uuid& moduleId_, Node* expr_, Node* targetTypeExpr_) : Node(NodeType::asNode, span_, moduleId_), expr(expr_), targetTypeExpr(targetTypeExpr_)
826 {
827 expr->SetParent(this);
828 targetTypeExpr->SetParent(this);
829 }
830
831 Node* AsNode::Clone(CloneContext& cloneContext) const
832 {
833 AsNode* clone = new AsNode(GetSpan(), ModuleId(), expr->Clone(cloneContext), targetTypeExpr->Clone(cloneContext));
834 return clone;
835 }
836
837 void AsNode::Accept(Visitor& visitor)
838 {
839 visitor.Visit(*this);
840 }
841
842 void AsNode::Write(AstWriter& writer)
843 {
844 Node::Write(writer);
845 writer.Write(expr.get());
846 writer.Write(targetTypeExpr.get());
847 }
848
849 void AsNode::Read(AstReader& reader)
850 {
851 Node::Read(reader);
852 expr.reset(reader.ReadNode());
853 expr->SetParent(this);
854 targetTypeExpr.reset(reader.ReadNode());
855 targetTypeExpr->SetParent(this);
856 }
857
858 std::string AsNode::ToString() const
859 {
860 return expr->ToString() + " as " + targetTypeExpr->ToString();
861 }
862
863 IndexingNode::IndexingNode(const Span& span_, const boost::uuids::uuid& moduleId_) : Node(NodeType::indexingNode, span_, moduleId_), subject(), index()
864 {
865 }
866
867 IndexingNode::IndexingNode(const Span& span_, const boost::uuids::uuid& moduleId_, Node* subject_, Node* index_) :
868 Node(NodeType::indexingNode, span_, moduleId_), subject(subject_), index(index_)
869 {
870 subject->SetParent(this);
871 index->SetParent(this);
872 }
873
874 Node* IndexingNode::Clone(CloneContext& cloneContext) const
875 {
876 IndexingNode* clone = new IndexingNode(GetSpan(), ModuleId(), subject->Clone(cloneContext), index->Clone(cloneContext));
877 return clone;
878 }
879
880 void IndexingNode::Accept(Visitor& visitor)
881 {
882 visitor.Visit(*this);
883 }
884
885 void IndexingNode::Write(AstWriter& writer)
886 {
887 Node::Write(writer);
888 writer.Write(subject.get());
889 writer.Write(index.get());
890 }
891
892 void IndexingNode::Read(AstReader& reader)
893 {
894 Node::Read(reader);
895 subject.reset(reader.ReadNode());
896 subject->SetParent(this);
897 index.reset(reader.ReadNode());
898 index->SetParent(this);
899 }
900
901 std::string IndexingNode::ToString() const
902 {
903 return subject->ToString() + "[" + index->ToString() + "]";
904 }
905
906 InvokeNode::InvokeNode(const Span& span_, const boost::uuids::uuid& moduleId_) : Node(NodeType::invokeNode, span_, moduleId_), subject(), arguments()
907 {
908 }
909
910 InvokeNode::InvokeNode(const Span& span_, const boost::uuids::uuid& moduleId_, Node* subject_) :
911 Node(NodeType::invokeNode, span_, moduleId_), subject(subject_), arguments()
912 {
913 subject->SetParent(this);
914 }
915
916 Node* InvokeNode::Clone(CloneContext& cloneContext) const
917 {
918 InvokeNode* clone = new InvokeNode(GetSpan(), ModuleId(), subject->Clone(cloneContext));
919 int n = arguments.Count();
920 for (int i = 0; i < n; ++i)
921 {
922 Node* argument = arguments[i];
923 clone->AddArgument(argument->Clone(cloneContext));
924 }
925 return clone;
926 }
927
928 void InvokeNode::Accept(Visitor& visitor)
929 {
930 visitor.Visit(*this);
931 }
932
933 void InvokeNode::Write(AstWriter& writer)
934 {
935 Node::Write(writer);
936 writer.Write(subject.get());
937 arguments.Write(writer);
938 }
939
940 void InvokeNode::Read(AstReader& reader)
941 {
942 Node::Read(reader);
943 subject.reset(reader.ReadNode());
944 subject->SetParent(this);
945 arguments.Read(reader);
946 arguments.SetParent(this);
947 }
948
949 void InvokeNode::AddArgument(Node* argument)
950 {
951 argument->SetParent(this);
952 arguments.Add(argument);
953 }
954
955 std::string InvokeNode::ToString() const
956 {
957 std::string s = subject->ToString();
958 s.append("(");
959 int n = arguments.Count();
960 for (int i = 0; i < n; ++i)
961 {
962 if (i > 0)
963 {
964 s.append(", ");
965 }
966 s.append(arguments[i]->ToString());
967 }
968 s.append(")");
969 return s;
970 }
971
972 PostfixIncrementNode::PostfixIncrementNode(const Span& span_, const boost::uuids::uuid& moduleId_) : UnaryNode(NodeType::postfixIncrementNode, span_, moduleId_)
973 {
974 }
975
976 PostfixIncrementNode::PostfixIncrementNode(const Span& span_, const boost::uuids::uuid& moduleId_, Node* subject_) :
977 UnaryNode(NodeType::postfixIncrementNode, span_, moduleId_, subject_)
978 {
979 }
980
981 Node* PostfixIncrementNode::Clone(CloneContext& cloneContext) const
982 {
983 PostfixIncrementNode* clone = new PostfixIncrementNode(GetSpan(), ModuleId(), Subject()->Clone(cloneContext));
984 return clone;
985 }
986
987 void PostfixIncrementNode::Accept(Visitor& visitor)
988 {
989 visitor.Visit(*this);
990 }
991
992 std::string PostfixIncrementNode::ToString() const
993 {
994 return Subject()->ToString() + "++";
995 }
996
997 PostfixDecrementNode::PostfixDecrementNode(const Span& span_, const boost::uuids::uuid& moduleId_) : UnaryNode(NodeType::postfixDecrementNode, span_, moduleId_)
998 {
999 }
1000
1001 PostfixDecrementNode::PostfixDecrementNode(const Span& span_, const boost::uuids::uuid& moduleId_, Node* subject_) : UnaryNode(NodeType::postfixDecrementNode, span_, moduleId_, subject_)
1002 {
1003 }
1004
1005 Node* PostfixDecrementNode::Clone(CloneContext& cloneContext) const
1006 {
1007 PostfixDecrementNode* clone = new PostfixDecrementNode(GetSpan(), ModuleId(), Subject()->Clone(cloneContext));
1008 return clone;
1009 }
1010
1011 void PostfixDecrementNode::Accept(Visitor& visitor)
1012 {
1013 visitor.Visit(*this);
1014 }
1015
1016 std::string PostfixDecrementNode::ToString() const
1017 {
1018 return Subject()->ToString() + "--";
1019 }
1020
1021 SizeOfNode::SizeOfNode(const Span& span_, const boost::uuids::uuid& moduleId_) : Node(NodeType::sizeOfNode, span_, moduleId_), expression()
1022 {
1023 }
1024
1025 SizeOfNode::SizeOfNode(const Span& span_, const boost::uuids::uuid& moduleId_, Node* expression_) :
1026 Node(NodeType::sizeOfNode, span_, moduleId_), expression(expression_)
1027 {
1028 expression->SetParent(this);
1029 }
1030
1031 Node* SizeOfNode::Clone(CloneContext& cloneContext) const
1032 {
1033 SizeOfNode* clone = new SizeOfNode(GetSpan(), ModuleId(), expression->Clone(cloneContext));
1034 return clone;
1035 }
1036
1037 void SizeOfNode::Accept(Visitor& visitor)
1038 {
1039 visitor.Visit(*this);
1040 }
1041
1042 void SizeOfNode::Write(AstWriter& writer)
1043 {
1044 Node::Write(writer);
1045 writer.Write(expression.get());
1046 }
1047
1048 void SizeOfNode::Read(AstReader& reader)
1049 {
1050 Node::Read(reader);
1051 expression.reset(reader.ReadNode());
1052 expression->SetParent(this);
1053 }
1054
1055 std::string SizeOfNode::ToString() const
1056 {
1057 return "sizeof(" + expression->ToString() + ")";
1058 }
1059
1060 TypeNameNode::TypeNameNode(const Span& span_, const boost::uuids::uuid& moduleId_) : Node(NodeType::typeNameNode, span_, moduleId_), expression(), static_(false)
1061 {
1062 }
1063
1064 TypeNameNode::TypeNameNode(const Span& span_, const boost::uuids::uuid& moduleId_, Node* expression_) :
1065 Node(NodeType::typeNameNode, span_, moduleId_), expression(expression_), static_(false)
1066 {
1067 expression->SetParent(this);
1068 }
1069
1070 Node* TypeNameNode::Clone(CloneContext& cloneContext) const
1071 {
1072 TypeNameNode* clone = new TypeNameNode(GetSpan(), ModuleId(), expression->Clone(cloneContext));
1073 if (static_)
1074 {
1075 clone->SetStatic();
1076 }
1077 return clone;
1078 }
1079
1080 void TypeNameNode::Accept(Visitor& visitor)
1081 {
1082 visitor.Visit(*this);
1083 }
1084
1085 void TypeNameNode::Write(AstWriter& writer)
1086 {
1087 Node::Write(writer);
1088 writer.Write(expression.get());
1089 writer.GetBinaryWriter().Write(static_);
1090 }
1091
1092 void TypeNameNode::Read(AstReader& reader)
1093 {
1094 Node::Read(reader);
1095 expression.reset(reader.ReadNode());
1096 expression->SetParent(this);
1097 static_ = reader.GetBinaryReader().ReadBool();
1098 }
1099
1100 std::string TypeNameNode::ToString() const
1101 {
1102 return "typename(" + expression->ToString() + ")";
1103 }
1104
1105 TypeIdNode::TypeIdNode(const Span& span_, const boost::uuids::uuid& moduleId_) : Node(NodeType::typeIdNode, span_, moduleId_), expression()
1106 {
1107 }
1108
1109 TypeIdNode::TypeIdNode(const Span& span_, const boost::uuids::uuid& moduleId_, Node* expression_) : Node(NodeType::typeIdNode, span_, moduleId_), expression(expression_)
1110 {
1111 expression->SetParent(this);
1112 }
1113
1114 Node* TypeIdNode::Clone(CloneContext& cloneContext) const
1115 {
1116 TypeIdNode* clone = new TypeIdNode(GetSpan(), ModuleId(), expression->Clone(cloneContext));
1117 return clone;
1118 }
1119
1120 void TypeIdNode::Accept(Visitor& visitor)
1121 {
1122 visitor.Visit(*this);
1123 }
1124
1125 void TypeIdNode::Write(AstWriter& writer)
1126 {
1127 Node::Write(writer);
1128 writer.Write(expression.get());
1129 }
1130
1131 void TypeIdNode::Read(AstReader& reader)
1132 {
1133 Node::Read(reader);
1134 expression.reset(reader.ReadNode());
1135 expression->SetParent(this);
1136 }
1137
1138 std::string TypeIdNode::ToString() const
1139 {
1140 return "typeid(" + expression->ToString() + ")";
1141 }
1142
1143 CastNode::CastNode(const Span& span_, const boost::uuids::uuid& moduleId_) : Node(NodeType::castNode, span_, moduleId_), targetTypeExpr(), sourceExpr()
1144 {
1145 }
1146
1147 CastNode::CastNode(const Span& span_, const boost::uuids::uuid& moduleId_, Node* targetTypeExpr_, Node* sourceExpr_) :
1148 Node(NodeType::castNode, span_, moduleId_), targetTypeExpr(targetTypeExpr_), sourceExpr(sourceExpr_)
1149 {
1150 targetTypeExpr->SetParent(this);
1151 sourceExpr->SetParent(this);
1152 }
1153
1154 Node* CastNode::Clone(CloneContext& cloneContext) const
1155 {
1156 CastNode* clone = new CastNode(GetSpan(), ModuleId(), targetTypeExpr->Clone(cloneContext), sourceExpr->Clone(cloneContext));
1157 return clone;
1158 }
1159
1160 void CastNode::Accept(Visitor& visitor)
1161 {
1162 visitor.Visit(*this);
1163 }
1164
1165 void CastNode::Write(AstWriter& writer)
1166 {
1167 Node::Write(writer);
1168 writer.Write(targetTypeExpr.get());
1169 writer.Write(sourceExpr.get());
1170 }
1171
1172 void CastNode::Read(AstReader& reader)
1173 {
1174 Node::Read(reader);
1175 targetTypeExpr.reset(reader.ReadNode());
1176 targetTypeExpr->SetParent(this);
1177 sourceExpr.reset(reader.ReadNode());
1178 sourceExpr->SetParent(this);
1179 }
1180
1181 std::string CastNode::ToString() const
1182 {
1183 return "cast<" + targetTypeExpr->ToString() + ">(" + sourceExpr->ToString() + ")";
1184 }
1185
1186 ConstructNode::ConstructNode(const Span& span_, const boost::uuids::uuid& moduleId_) : Node(NodeType::constructNode, span_, moduleId_), typeExpr(), arguments()
1187 {
1188 }
1189
1190 ConstructNode::ConstructNode(const Span& span_, const boost::uuids::uuid& moduleId_, Node* typeExpr_) :
1191 Node(NodeType::constructNode, span_, moduleId_), typeExpr(typeExpr_), arguments()
1192 {
1193 typeExpr->SetParent(this);
1194 }
1195
1196 Node* ConstructNode::Clone(CloneContext& cloneContext) const
1197 {
1198 ConstructNode* clone = new ConstructNode(GetSpan(), ModuleId(), typeExpr->Clone(cloneContext));
1199 int n = arguments.Count();
1200 for (int i = 0; i < n; ++i)
1201 {
1202 Node* argument = arguments[i];
1203 clone->AddArgument(argument->Clone(cloneContext));
1204 }
1205 return clone;
1206 }
1207
1208 void ConstructNode::Accept(Visitor& visitor)
1209 {
1210 visitor.Visit(*this);
1211 }
1212
1213 void ConstructNode::Write(AstWriter& writer)
1214 {
1215 Node::Write(writer);
1216 writer.Write(typeExpr.get());
1217 arguments.Write(writer);
1218 }
1219
1220 void ConstructNode::Read(AstReader& reader)
1221 {
1222 Node::Read(reader);
1223 typeExpr.reset(reader.ReadNode());
1224 typeExpr->SetParent(this);
1225 arguments.Read(reader);
1226 arguments.SetParent(this);
1227 }
1228
1229 void ConstructNode::AddArgument(Node* argument)
1230 {
1231 argument->SetParent(this);
1232 arguments.Add(argument);
1233 }
1234
1235 std::string ConstructNode::ToString() const
1236 {
1237 std::string s = "construct<" + typeExpr->ToString() + ">(";
1238 int n = arguments.Count();
1239 for (int i = 0; i < n; ++i)
1240 {
1241 if (i > 0)
1242 {
1243 s.append(", ");
1244 }
1245 s.append(arguments[i]->ToString());
1246 }
1247 s.append(")");
1248 return s;
1249 }
1250
1251 NewNode::NewNode(const Span& span_, const boost::uuids::uuid& moduleId_) : Node(NodeType::newNode, span_, moduleId_), typeExpr(), arguments()
1252 {
1253 }
1254
1255 NewNode::NewNode(const Span& span_, const boost::uuids::uuid& moduleId_, Node* typeExpr_) :
1256 Node(NodeType::newNode, span_, moduleId_), typeExpr(typeExpr_), arguments()
1257 {
1258 typeExpr->SetParent(this);
1259 }
1260
1261 Node* NewNode::Clone(CloneContext& cloneContext) const
1262 {
1263 NewNode* clone = new NewNode(GetSpan(), ModuleId(), typeExpr->Clone(cloneContext));
1264 int n = arguments.Count();
1265 for (int i = 0; i < n; ++i)
1266 {
1267 Node* argument = arguments[i];
1268 clone->AddArgument(argument->Clone(cloneContext));
1269 }
1270 return clone;
1271 }
1272
1273 void NewNode::Accept(Visitor& visitor)
1274 {
1275 visitor.Visit(*this);
1276 }
1277
1278 void NewNode::Write(AstWriter& writer)
1279 {
1280 Node::Write(writer);
1281 writer.Write(typeExpr.get());
1282 arguments.Write(writer);
1283 }
1284
1285 void NewNode::Read(AstReader& reader)
1286 {
1287 Node::Read(reader);
1288 typeExpr.reset(reader.ReadNode());
1289 typeExpr->SetParent(this);
1290 arguments.Read(reader);
1291 arguments.SetParent(this);
1292 }
1293
1294 void NewNode::AddArgument(Node* argument)
1295 {
1296 argument->SetParent(this);
1297 arguments.Add(argument);
1298 }
1299
1300 std::string NewNode::ToString() const
1301 {
1302 std::string s = "new ";
1303 s.append(typeExpr->ToString()).append("(");
1304 int n = arguments.Count();
1305 for (int i = 0; i < n; ++i)
1306 {
1307 if (i > 0)
1308 {
1309 s.append(", ");
1310 }
1311 s.append(arguments[i]->ToString());
1312 }
1313 s.append(")");
1314 return s;
1315 }
1316
1317 ThisNode::ThisNode(const Span& span_, const boost::uuids::uuid& moduleId_) : Node(NodeType::thisNode, span_, moduleId_)
1318 {
1319 }
1320
1321 Node* ThisNode::Clone(CloneContext& cloneContext) const
1322 {
1323 ThisNode* clone = new ThisNode(GetSpan(), ModuleId());
1324 return clone;
1325 }
1326
1327 void ThisNode::Accept(Visitor& visitor)
1328 {
1329 visitor.Visit(*this);
1330 }
1331
1332 std::string ThisNode::ToString() const
1333 {
1334 return "this";
1335 }
1336
1337 BaseNode::BaseNode(const Span& span_, const boost::uuids::uuid& moduleId_) : Node(NodeType::baseNode, span_, moduleId_)
1338 {
1339 }
1340
1341 Node* BaseNode::Clone(CloneContext& cloneContext) const
1342 {
1343 BaseNode* clone = new BaseNode(GetSpan(), ModuleId());
1344 return clone;
1345 }
1346
1347 void BaseNode::Accept(Visitor& visitor)
1348 {
1349 visitor.Visit(*this);
1350 }
1351
1352 std::string BaseNode::ToString() const
1353 {
1354 return "base";
1355 }
1356
1357 ParenthesizedExpressionNode::ParenthesizedExpressionNode(const Span& span_, const boost::uuids::uuid& moduleId_) :
1358 UnaryNode(NodeType::parenthesizedExpressionNode, span_, moduleId_)
1359 {
1360 }
1361
1362 ParenthesizedExpressionNode::ParenthesizedExpressionNode(const Span& span_, const boost::uuids::uuid& moduleId_, Node* child_) :
1363 UnaryNode(NodeType::parenthesizedExpressionNode, span_, moduleId_, child_)
1364 {
1365 }
1366
1367 Node* ParenthesizedExpressionNode::Clone(CloneContext& cloneContext) const
1368 {
1369 ParenthesizedExpressionNode* clone = new ParenthesizedExpressionNode(GetSpan(), ModuleId(), Subject()->Clone(cloneContext));
1370 return clone;
1371 }
1372
1373 void ParenthesizedExpressionNode::Write(AstWriter& writer)
1374 {
1375 UnaryNode::Write(writer);
1376 }
1377
1378 void ParenthesizedExpressionNode::Read(AstReader& reader)
1379 {
1380 UnaryNode::Read(reader);
1381 }
1382
1383 void ParenthesizedExpressionNode::Accept(Visitor& visitor)
1384 {
1385 visitor.Visit(*this);
1386 }
1387
1388 std::string ParenthesizedExpressionNode::ToString() const
1389 {
1390 return "(" + Subject()->ToString() + ")";
1391 }
1392
1393 } }