blob: 89836a38acb0068130441f3a25e00e2445c02f14 [file] [log] [blame]
Ryan Brown998c8a1c12015-11-02 19:30:40 +00001//===-- GoAST.h -------------------------------------------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10// DO NOT EDIT.
11// Generated by gen_go_ast.py
12
13#ifndef liblldb_GoAST_h
14#define liblldb_GoAST_h
15
16#include "lldb/lldb-forward.h"
17#include "lldb/lldb-private.h"
18#include "llvm/Support/Casting.h"
19#include "Plugins/ExpressionParser/Go/GoLexer.h"
20
21namespace lldb_private
22{
23
24class GoASTNode
25{
26 public:
27 typedef GoLexer::TokenType TokenType;
28 typedef GoLexer::Token Token;
29 enum ChanDir
30 {
31 eChanBidir,
32 eChanSend,
33 eChanRecv,
34 };
35 enum NodeKind
36 {
37 eBadDecl,
38 eFuncDecl,
39 eGenDecl,
40 eArrayType,
41 eBadExpr,
42 eBasicLit,
43 eBinaryExpr,
44 eIdent,
45 eCallExpr,
46 eChanType,
47 eCompositeLit,
48 eEllipsis,
49 eFuncType,
50 eFuncLit,
51 eIndexExpr,
52 eInterfaceType,
53 eKeyValueExpr,
54 eMapType,
55 eParenExpr,
56 eSelectorExpr,
57 eSliceExpr,
58 eStarExpr,
59 eStructType,
60 eTypeAssertExpr,
61 eUnaryExpr,
62 eImportSpec,
63 eTypeSpec,
64 eValueSpec,
65 eAssignStmt,
66 eBadStmt,
67 eBlockStmt,
68 eBranchStmt,
69 eCaseClause,
70 eCommClause,
71 eDeclStmt,
72 eDeferStmt,
73 eEmptyStmt,
74 eExprStmt,
75 eForStmt,
76 eGoStmt,
77 eIfStmt,
78 eIncDecStmt,
79 eLabeledStmt,
80 eRangeStmt,
81 eReturnStmt,
82 eSelectStmt,
83 eSendStmt,
84 eSwitchStmt,
85 eTypeSwitchStmt,
86 eField,
87 eFieldList,
88 };
89
90 virtual ~GoASTNode() = default;
91
92 NodeKind
93 GetKind() const
94 {
95 return m_kind;
96 }
97
98 virtual const char *GetKindName() const = 0;
99
100 template <typename V> void WalkChildren(V &v);
101
102 protected:
103 explicit GoASTNode(NodeKind kind) : m_kind(kind) { }
104
105 private:
106 const NodeKind m_kind;
107
108 GoASTNode(const GoASTNode &) = delete;
109 const GoASTNode &operator=(const GoASTNode &) = delete;
110};
111
112
113class GoASTDecl : public GoASTNode
114{
115 public:
116 template <typename R, typename V> R Visit(V *v) const;
117
118 static bool
119 classof(const GoASTNode *n)
120 {
121 return n->GetKind() >= eBadDecl && n->GetKind() <= eGenDecl;
122 }
123
124 protected:
125 explicit GoASTDecl(NodeKind kind) : GoASTNode(kind) { }
126 private:
127
128 GoASTDecl(const GoASTDecl &) = delete;
129 const GoASTDecl &operator=(const GoASTDecl &) = delete;
130};
131
132class GoASTExpr : public GoASTNode
133{
134 public:
135 template <typename R, typename V> R Visit(V *v) const;
136
137 static bool
138 classof(const GoASTNode *n)
139 {
140 return n->GetKind() >= eArrayType && n->GetKind() <= eUnaryExpr;
141 }
142
143 protected:
144 explicit GoASTExpr(NodeKind kind) : GoASTNode(kind) { }
145 private:
146
147 GoASTExpr(const GoASTExpr &) = delete;
148 const GoASTExpr &operator=(const GoASTExpr &) = delete;
149};
150
151class GoASTSpec : public GoASTNode
152{
153 public:
154 template <typename R, typename V> R Visit(V *v) const;
155
156 static bool
157 classof(const GoASTNode *n)
158 {
159 return n->GetKind() >= eImportSpec && n->GetKind() <= eValueSpec;
160 }
161
162 protected:
163 explicit GoASTSpec(NodeKind kind) : GoASTNode(kind) { }
164 private:
165
166 GoASTSpec(const GoASTSpec &) = delete;
167 const GoASTSpec &operator=(const GoASTSpec &) = delete;
168};
169
170class GoASTStmt : public GoASTNode
171{
172 public:
173 template <typename R, typename V> R Visit(V *v) const;
174
175 static bool
176 classof(const GoASTNode *n)
177 {
178 return n->GetKind() >= eAssignStmt && n->GetKind() <= eTypeSwitchStmt;
179 }
180
181 protected:
182 explicit GoASTStmt(NodeKind kind) : GoASTNode(kind) { }
183 private:
184
185 GoASTStmt(const GoASTStmt &) = delete;
186 const GoASTStmt &operator=(const GoASTStmt &) = delete;
187};
188
189
190class GoASTArrayType : public GoASTExpr
191{
192 public:
193 GoASTArrayType(GoASTExpr *len, GoASTExpr *elt) : GoASTExpr(eArrayType), m_len_up(len), m_elt_up(elt) {}
194 ~GoASTArrayType() override = default;
195
196 const char *
197 GetKindName() const override
198 {
199 return "ArrayType";
200 }
201
202 static bool
203 classof(const GoASTNode *n)
204 {
205 return n->GetKind() == eArrayType;
206 }
207
208 const GoASTExpr *
209 GetLen() const
210 {
211 return m_len_up.get();
212 }
213 void
214 SetLen(GoASTExpr *len)
215 {
216 m_len_up.reset(len);
217 }
218
219 const GoASTExpr *
220 GetElt() const
221 {
222 return m_elt_up.get();
223 }
224 void
225 SetElt(GoASTExpr *elt)
226 {
227 m_elt_up.reset(elt);
228 }
229
230 private:
231 friend class GoASTNode;
232 std::unique_ptr<GoASTExpr> m_len_up;
233 std::unique_ptr<GoASTExpr> m_elt_up;
234
235 GoASTArrayType(const GoASTArrayType &) = delete;
236 const GoASTArrayType &operator=(const GoASTArrayType &) = delete;
237};
238
239class GoASTAssignStmt : public GoASTStmt
240{
241 public:
242 explicit GoASTAssignStmt(bool define) : GoASTStmt(eAssignStmt), m_define(define) {}
243 ~GoASTAssignStmt() override = default;
244
245 const char *
246 GetKindName() const override
247 {
248 return "AssignStmt";
249 }
250
251 static bool
252 classof(const GoASTNode *n)
253 {
254 return n->GetKind() == eAssignStmt;
255 }
256
257 size_t
258 NumLhs() const
259 {
260 return m_lhs.size();
261 }
262 const GoASTExpr *
263 GetLhs(int i) const
264 {
265 return m_lhs[i].get();
266 }
267 void
268 AddLhs(GoASTExpr *lhs)
269 {
270 m_lhs.push_back(std::unique_ptr<GoASTExpr>(lhs));
271 }
272
273 size_t
274 NumRhs() const
275 {
276 return m_rhs.size();
277 }
278 const GoASTExpr *
279 GetRhs(int i) const
280 {
281 return m_rhs[i].get();
282 }
283 void
284 AddRhs(GoASTExpr *rhs)
285 {
286 m_rhs.push_back(std::unique_ptr<GoASTExpr>(rhs));
287 }
288
289 bool
290 GetDefine() const
291 {
292 return m_define;
293 }
294 void
295 SetDefine(bool define)
296 {
297 m_define = define;
298 }
299
300 private:
301 friend class GoASTNode;
302 std::vector<std::unique_ptr<GoASTExpr> > m_lhs;
303 std::vector<std::unique_ptr<GoASTExpr> > m_rhs;
304 bool m_define;
305
306 GoASTAssignStmt(const GoASTAssignStmt &) = delete;
307 const GoASTAssignStmt &operator=(const GoASTAssignStmt &) = delete;
308};
309
310class GoASTBadDecl : public GoASTDecl
311{
312 public:
313 GoASTBadDecl() : GoASTDecl(eBadDecl) {}
314 ~GoASTBadDecl() override = default;
315
316 const char *
317 GetKindName() const override
318 {
319 return "BadDecl";
320 }
321
322 static bool
323 classof(const GoASTNode *n)
324 {
325 return n->GetKind() == eBadDecl;
326 }
327
328 GoASTBadDecl(const GoASTBadDecl &) = delete;
329 const GoASTBadDecl &operator=(const GoASTBadDecl &) = delete;
330};
331
332class GoASTBadExpr : public GoASTExpr
333{
334 public:
335 GoASTBadExpr() : GoASTExpr(eBadExpr) {}
336 ~GoASTBadExpr() override = default;
337
338 const char *
339 GetKindName() const override
340 {
341 return "BadExpr";
342 }
343
344 static bool
345 classof(const GoASTNode *n)
346 {
347 return n->GetKind() == eBadExpr;
348 }
349
350 GoASTBadExpr(const GoASTBadExpr &) = delete;
351 const GoASTBadExpr &operator=(const GoASTBadExpr &) = delete;
352};
353
354class GoASTBadStmt : public GoASTStmt
355{
356 public:
357 GoASTBadStmt() : GoASTStmt(eBadStmt) {}
358 ~GoASTBadStmt() override = default;
359
360 const char *
361 GetKindName() const override
362 {
363 return "BadStmt";
364 }
365
366 static bool
367 classof(const GoASTNode *n)
368 {
369 return n->GetKind() == eBadStmt;
370 }
371
372 GoASTBadStmt(const GoASTBadStmt &) = delete;
373 const GoASTBadStmt &operator=(const GoASTBadStmt &) = delete;
374};
375
376class GoASTBasicLit : public GoASTExpr
377{
378 public:
379 explicit GoASTBasicLit(Token value) : GoASTExpr(eBasicLit), m_value(value) {}
380 ~GoASTBasicLit() override = default;
381
382 const char *
383 GetKindName() const override
384 {
385 return "BasicLit";
386 }
387
388 static bool
389 classof(const GoASTNode *n)
390 {
391 return n->GetKind() == eBasicLit;
392 }
393
394 Token
395 GetValue() const
396 {
397 return m_value;
398 }
399 void
400 SetValue(Token value)
401 {
402 m_value = value;
403 }
404
405 private:
406 friend class GoASTNode;
407 Token m_value;
408
409 GoASTBasicLit(const GoASTBasicLit &) = delete;
410 const GoASTBasicLit &operator=(const GoASTBasicLit &) = delete;
411};
412
413class GoASTBinaryExpr : public GoASTExpr
414{
415 public:
416 GoASTBinaryExpr(GoASTExpr *x, GoASTExpr *y, TokenType op) : GoASTExpr(eBinaryExpr), m_x_up(x), m_y_up(y), m_op(op) {}
417 ~GoASTBinaryExpr() override = default;
418
419 const char *
420 GetKindName() const override
421 {
422 return "BinaryExpr";
423 }
424
425 static bool
426 classof(const GoASTNode *n)
427 {
428 return n->GetKind() == eBinaryExpr;
429 }
430
431 const GoASTExpr *
432 GetX() const
433 {
434 return m_x_up.get();
435 }
436 void
437 SetX(GoASTExpr *x)
438 {
439 m_x_up.reset(x);
440 }
441
442 const GoASTExpr *
443 GetY() const
444 {
445 return m_y_up.get();
446 }
447 void
448 SetY(GoASTExpr *y)
449 {
450 m_y_up.reset(y);
451 }
452
453 TokenType
454 GetOp() const
455 {
456 return m_op;
457 }
458 void
459 SetOp(TokenType op)
460 {
461 m_op = op;
462 }
463
464 private:
465 friend class GoASTNode;
466 std::unique_ptr<GoASTExpr> m_x_up;
467 std::unique_ptr<GoASTExpr> m_y_up;
468 TokenType m_op;
469
470 GoASTBinaryExpr(const GoASTBinaryExpr &) = delete;
471 const GoASTBinaryExpr &operator=(const GoASTBinaryExpr &) = delete;
472};
473
474class GoASTBlockStmt : public GoASTStmt
475{
476 public:
477 GoASTBlockStmt() : GoASTStmt(eBlockStmt) {}
478 ~GoASTBlockStmt() override = default;
479
480 const char *
481 GetKindName() const override
482 {
483 return "BlockStmt";
484 }
485
486 static bool
487 classof(const GoASTNode *n)
488 {
489 return n->GetKind() == eBlockStmt;
490 }
491
492 size_t
493 NumList() const
494 {
495 return m_list.size();
496 }
497 const GoASTStmt *
498 GetList(int i) const
499 {
500 return m_list[i].get();
501 }
502 void
503 AddList(GoASTStmt *list)
504 {
505 m_list.push_back(std::unique_ptr<GoASTStmt>(list));
506 }
507
508 private:
509 friend class GoASTNode;
510 std::vector<std::unique_ptr<GoASTStmt> > m_list;
511
512 GoASTBlockStmt(const GoASTBlockStmt &) = delete;
513 const GoASTBlockStmt &operator=(const GoASTBlockStmt &) = delete;
514};
515
516class GoASTIdent : public GoASTExpr
517{
518 public:
519 explicit GoASTIdent(Token name) : GoASTExpr(eIdent), m_name(name) {}
520 ~GoASTIdent() override = default;
521
522 const char *
523 GetKindName() const override
524 {
525 return "Ident";
526 }
527
528 static bool
529 classof(const GoASTNode *n)
530 {
531 return n->GetKind() == eIdent;
532 }
533
534 Token
535 GetName() const
536 {
537 return m_name;
538 }
539 void
540 SetName(Token name)
541 {
542 m_name = name;
543 }
544
545 private:
546 friend class GoASTNode;
547 Token m_name;
548
549 GoASTIdent(const GoASTIdent &) = delete;
550 const GoASTIdent &operator=(const GoASTIdent &) = delete;
551};
552
553class GoASTBranchStmt : public GoASTStmt
554{
555 public:
556 GoASTBranchStmt(GoASTIdent *label, TokenType tok) : GoASTStmt(eBranchStmt), m_label_up(label), m_tok(tok) {}
557 ~GoASTBranchStmt() override = default;
558
559 const char *
560 GetKindName() const override
561 {
562 return "BranchStmt";
563 }
564
565 static bool
566 classof(const GoASTNode *n)
567 {
568 return n->GetKind() == eBranchStmt;
569 }
570
571 const GoASTIdent *
572 GetLabel() const
573 {
574 return m_label_up.get();
575 }
576 void
577 SetLabel(GoASTIdent *label)
578 {
579 m_label_up.reset(label);
580 }
581
582 TokenType
583 GetTok() const
584 {
585 return m_tok;
586 }
587 void
588 SetTok(TokenType tok)
589 {
590 m_tok = tok;
591 }
592
593 private:
594 friend class GoASTNode;
595 std::unique_ptr<GoASTIdent> m_label_up;
596 TokenType m_tok;
597
598 GoASTBranchStmt(const GoASTBranchStmt &) = delete;
599 const GoASTBranchStmt &operator=(const GoASTBranchStmt &) = delete;
600};
601
602class GoASTCallExpr : public GoASTExpr
603{
604 public:
605 explicit GoASTCallExpr(bool ellipsis) : GoASTExpr(eCallExpr), m_ellipsis(ellipsis) {}
606 ~GoASTCallExpr() override = default;
607
608 const char *
609 GetKindName() const override
610 {
611 return "CallExpr";
612 }
613
614 static bool
615 classof(const GoASTNode *n)
616 {
617 return n->GetKind() == eCallExpr;
618 }
619
620 const GoASTExpr *
621 GetFun() const
622 {
623 return m_fun_up.get();
624 }
625 void
626 SetFun(GoASTExpr *fun)
627 {
628 m_fun_up.reset(fun);
629 }
630
631 size_t
632 NumArgs() const
633 {
634 return m_args.size();
635 }
636 const GoASTExpr *
637 GetArgs(int i) const
638 {
639 return m_args[i].get();
640 }
641 void
642 AddArgs(GoASTExpr *args)
643 {
644 m_args.push_back(std::unique_ptr<GoASTExpr>(args));
645 }
646
647 bool
648 GetEllipsis() const
649 {
650 return m_ellipsis;
651 }
652 void
653 SetEllipsis(bool ellipsis)
654 {
655 m_ellipsis = ellipsis;
656 }
657
658 private:
659 friend class GoASTNode;
660 std::unique_ptr<GoASTExpr> m_fun_up;
661 std::vector<std::unique_ptr<GoASTExpr> > m_args;
662 bool m_ellipsis;
663
664 GoASTCallExpr(const GoASTCallExpr &) = delete;
665 const GoASTCallExpr &operator=(const GoASTCallExpr &) = delete;
666};
667
668class GoASTCaseClause : public GoASTStmt
669{
670 public:
671 GoASTCaseClause() : GoASTStmt(eCaseClause) {}
672 ~GoASTCaseClause() override = default;
673
674 const char *
675 GetKindName() const override
676 {
677 return "CaseClause";
678 }
679
680 static bool
681 classof(const GoASTNode *n)
682 {
683 return n->GetKind() == eCaseClause;
684 }
685
686 size_t
687 NumList() const
688 {
689 return m_list.size();
690 }
691 const GoASTExpr *
692 GetList(int i) const
693 {
694 return m_list[i].get();
695 }
696 void
697 AddList(GoASTExpr *list)
698 {
699 m_list.push_back(std::unique_ptr<GoASTExpr>(list));
700 }
701
702 size_t
703 NumBody() const
704 {
705 return m_body.size();
706 }
707 const GoASTStmt *
708 GetBody(int i) const
709 {
710 return m_body[i].get();
711 }
712 void
713 AddBody(GoASTStmt *body)
714 {
715 m_body.push_back(std::unique_ptr<GoASTStmt>(body));
716 }
717
718 private:
719 friend class GoASTNode;
720 std::vector<std::unique_ptr<GoASTExpr> > m_list;
721 std::vector<std::unique_ptr<GoASTStmt> > m_body;
722
723 GoASTCaseClause(const GoASTCaseClause &) = delete;
724 const GoASTCaseClause &operator=(const GoASTCaseClause &) = delete;
725};
726
727class GoASTChanType : public GoASTExpr
728{
729 public:
730 GoASTChanType(ChanDir dir, GoASTExpr *value) : GoASTExpr(eChanType), m_dir(dir), m_value_up(value) {}
731 ~GoASTChanType() override = default;
732
733 const char *
734 GetKindName() const override
735 {
736 return "ChanType";
737 }
738
739 static bool
740 classof(const GoASTNode *n)
741 {
742 return n->GetKind() == eChanType;
743 }
744
745 ChanDir
746 GetDir() const
747 {
748 return m_dir;
749 }
750 void
751 SetDir(ChanDir dir)
752 {
753 m_dir = dir;
754 }
755
756 const GoASTExpr *
757 GetValue() const
758 {
759 return m_value_up.get();
760 }
761 void
762 SetValue(GoASTExpr *value)
763 {
764 m_value_up.reset(value);
765 }
766
767 private:
768 friend class GoASTNode;
769 ChanDir m_dir;
770 std::unique_ptr<GoASTExpr> m_value_up;
771
772 GoASTChanType(const GoASTChanType &) = delete;
773 const GoASTChanType &operator=(const GoASTChanType &) = delete;
774};
775
776class GoASTCommClause : public GoASTStmt
777{
778 public:
779 GoASTCommClause() : GoASTStmt(eCommClause) {}
780 ~GoASTCommClause() override = default;
781
782 const char *
783 GetKindName() const override
784 {
785 return "CommClause";
786 }
787
788 static bool
789 classof(const GoASTNode *n)
790 {
791 return n->GetKind() == eCommClause;
792 }
793
794 const GoASTStmt *
795 GetComm() const
796 {
797 return m_comm_up.get();
798 }
799 void
800 SetComm(GoASTStmt *comm)
801 {
802 m_comm_up.reset(comm);
803 }
804
805 size_t
806 NumBody() const
807 {
808 return m_body.size();
809 }
810 const GoASTStmt *
811 GetBody(int i) const
812 {
813 return m_body[i].get();
814 }
815 void
816 AddBody(GoASTStmt *body)
817 {
818 m_body.push_back(std::unique_ptr<GoASTStmt>(body));
819 }
820
821 private:
822 friend class GoASTNode;
823 std::unique_ptr<GoASTStmt> m_comm_up;
824 std::vector<std::unique_ptr<GoASTStmt> > m_body;
825
826 GoASTCommClause(const GoASTCommClause &) = delete;
827 const GoASTCommClause &operator=(const GoASTCommClause &) = delete;
828};
829
830class GoASTCompositeLit : public GoASTExpr
831{
832 public:
833 GoASTCompositeLit() : GoASTExpr(eCompositeLit) {}
834 ~GoASTCompositeLit() override = default;
835
836 const char *
837 GetKindName() const override
838 {
839 return "CompositeLit";
840 }
841
842 static bool
843 classof(const GoASTNode *n)
844 {
845 return n->GetKind() == eCompositeLit;
846 }
847
848 const GoASTExpr *
849 GetType() const
850 {
851 return m_type_up.get();
852 }
853 void
854 SetType(GoASTExpr *type)
855 {
856 m_type_up.reset(type);
857 }
858
859 size_t
860 NumElts() const
861 {
862 return m_elts.size();
863 }
864 const GoASTExpr *
865 GetElts(int i) const
866 {
867 return m_elts[i].get();
868 }
869 void
870 AddElts(GoASTExpr *elts)
871 {
872 m_elts.push_back(std::unique_ptr<GoASTExpr>(elts));
873 }
874
875 private:
876 friend class GoASTNode;
877 std::unique_ptr<GoASTExpr> m_type_up;
878 std::vector<std::unique_ptr<GoASTExpr> > m_elts;
879
880 GoASTCompositeLit(const GoASTCompositeLit &) = delete;
881 const GoASTCompositeLit &operator=(const GoASTCompositeLit &) = delete;
882};
883
884class GoASTDeclStmt : public GoASTStmt
885{
886 public:
887 explicit GoASTDeclStmt(GoASTDecl *decl) : GoASTStmt(eDeclStmt), m_decl_up(decl) {}
888 ~GoASTDeclStmt() override = default;
889
890 const char *
891 GetKindName() const override
892 {
893 return "DeclStmt";
894 }
895
896 static bool
897 classof(const GoASTNode *n)
898 {
899 return n->GetKind() == eDeclStmt;
900 }
901
902 const GoASTDecl *
903 GetDecl() const
904 {
905 return m_decl_up.get();
906 }
907 void
908 SetDecl(GoASTDecl *decl)
909 {
910 m_decl_up.reset(decl);
911 }
912
913 private:
914 friend class GoASTNode;
915 std::unique_ptr<GoASTDecl> m_decl_up;
916
917 GoASTDeclStmt(const GoASTDeclStmt &) = delete;
918 const GoASTDeclStmt &operator=(const GoASTDeclStmt &) = delete;
919};
920
921class GoASTDeferStmt : public GoASTStmt
922{
923 public:
924 explicit GoASTDeferStmt(GoASTCallExpr *call) : GoASTStmt(eDeferStmt), m_call_up(call) {}
925 ~GoASTDeferStmt() override = default;
926
927 const char *
928 GetKindName() const override
929 {
930 return "DeferStmt";
931 }
932
933 static bool
934 classof(const GoASTNode *n)
935 {
936 return n->GetKind() == eDeferStmt;
937 }
938
939 const GoASTCallExpr *
940 GetCall() const
941 {
942 return m_call_up.get();
943 }
944 void
945 SetCall(GoASTCallExpr *call)
946 {
947 m_call_up.reset(call);
948 }
949
950 private:
951 friend class GoASTNode;
952 std::unique_ptr<GoASTCallExpr> m_call_up;
953
954 GoASTDeferStmt(const GoASTDeferStmt &) = delete;
955 const GoASTDeferStmt &operator=(const GoASTDeferStmt &) = delete;
956};
957
958class GoASTEllipsis : public GoASTExpr
959{
960 public:
961 explicit GoASTEllipsis(GoASTExpr *elt) : GoASTExpr(eEllipsis), m_elt_up(elt) {}
962 ~GoASTEllipsis() override = default;
963
964 const char *
965 GetKindName() const override
966 {
967 return "Ellipsis";
968 }
969
970 static bool
971 classof(const GoASTNode *n)
972 {
973 return n->GetKind() == eEllipsis;
974 }
975
976 const GoASTExpr *
977 GetElt() const
978 {
979 return m_elt_up.get();
980 }
981 void
982 SetElt(GoASTExpr *elt)
983 {
984 m_elt_up.reset(elt);
985 }
986
987 private:
988 friend class GoASTNode;
989 std::unique_ptr<GoASTExpr> m_elt_up;
990
991 GoASTEllipsis(const GoASTEllipsis &) = delete;
992 const GoASTEllipsis &operator=(const GoASTEllipsis &) = delete;
993};
994
995class GoASTEmptyStmt : public GoASTStmt
996{
997 public:
998 GoASTEmptyStmt() : GoASTStmt(eEmptyStmt) {}
999 ~GoASTEmptyStmt() override = default;
1000
1001 const char *
1002 GetKindName() const override
1003 {
1004 return "EmptyStmt";
1005 }
1006
1007 static bool
1008 classof(const GoASTNode *n)
1009 {
1010 return n->GetKind() == eEmptyStmt;
1011 }
1012
1013 GoASTEmptyStmt(const GoASTEmptyStmt &) = delete;
1014 const GoASTEmptyStmt &operator=(const GoASTEmptyStmt &) = delete;
1015};
1016
1017class GoASTExprStmt : public GoASTStmt
1018{
1019 public:
1020 explicit GoASTExprStmt(GoASTExpr *x) : GoASTStmt(eExprStmt), m_x_up(x) {}
1021 ~GoASTExprStmt() override = default;
1022
1023 const char *
1024 GetKindName() const override
1025 {
1026 return "ExprStmt";
1027 }
1028
1029 static bool
1030 classof(const GoASTNode *n)
1031 {
1032 return n->GetKind() == eExprStmt;
1033 }
1034
1035 const GoASTExpr *
1036 GetX() const
1037 {
1038 return m_x_up.get();
1039 }
1040 void
1041 SetX(GoASTExpr *x)
1042 {
1043 m_x_up.reset(x);
1044 }
1045
1046 private:
1047 friend class GoASTNode;
1048 std::unique_ptr<GoASTExpr> m_x_up;
1049
1050 GoASTExprStmt(const GoASTExprStmt &) = delete;
1051 const GoASTExprStmt &operator=(const GoASTExprStmt &) = delete;
1052};
1053
1054class GoASTField : public GoASTNode
1055{
1056 public:
1057 GoASTField() : GoASTNode(eField) {}
1058 ~GoASTField() override = default;
1059
1060 const char *
1061 GetKindName() const override
1062 {
1063 return "Field";
1064 }
1065
1066 static bool
1067 classof(const GoASTNode *n)
1068 {
1069 return n->GetKind() == eField;
1070 }
1071
1072 size_t
1073 NumNames() const
1074 {
1075 return m_names.size();
1076 }
1077 const GoASTIdent *
1078 GetNames(int i) const
1079 {
1080 return m_names[i].get();
1081 }
1082 void
1083 AddNames(GoASTIdent *names)
1084 {
1085 m_names.push_back(std::unique_ptr<GoASTIdent>(names));
1086 }
1087
1088 const GoASTExpr *
1089 GetType() const
1090 {
1091 return m_type_up.get();
1092 }
1093 void
1094 SetType(GoASTExpr *type)
1095 {
1096 m_type_up.reset(type);
1097 }
1098
1099 const GoASTBasicLit *
1100 GetTag() const
1101 {
1102 return m_tag_up.get();
1103 }
1104 void
1105 SetTag(GoASTBasicLit *tag)
1106 {
1107 m_tag_up.reset(tag);
1108 }
1109
1110 private:
1111 friend class GoASTNode;
1112 std::vector<std::unique_ptr<GoASTIdent> > m_names;
1113 std::unique_ptr<GoASTExpr> m_type_up;
1114 std::unique_ptr<GoASTBasicLit> m_tag_up;
1115
1116 GoASTField(const GoASTField &) = delete;
1117 const GoASTField &operator=(const GoASTField &) = delete;
1118};
1119
1120class GoASTFieldList : public GoASTNode
1121{
1122 public:
1123 GoASTFieldList() : GoASTNode(eFieldList) {}
1124 ~GoASTFieldList() override = default;
1125
1126 const char *
1127 GetKindName() const override
1128 {
1129 return "FieldList";
1130 }
1131
1132 static bool
1133 classof(const GoASTNode *n)
1134 {
1135 return n->GetKind() == eFieldList;
1136 }
1137
1138 size_t
1139 NumList() const
1140 {
1141 return m_list.size();
1142 }
1143 const GoASTField *
1144 GetList(int i) const
1145 {
1146 return m_list[i].get();
1147 }
1148 void
1149 AddList(GoASTField *list)
1150 {
1151 m_list.push_back(std::unique_ptr<GoASTField>(list));
1152 }
1153
1154 private:
1155 friend class GoASTNode;
1156 std::vector<std::unique_ptr<GoASTField> > m_list;
1157
1158 GoASTFieldList(const GoASTFieldList &) = delete;
1159 const GoASTFieldList &operator=(const GoASTFieldList &) = delete;
1160};
1161
1162class GoASTForStmt : public GoASTStmt
1163{
1164 public:
1165 GoASTForStmt(GoASTStmt *init, GoASTExpr *cond, GoASTStmt *post, GoASTBlockStmt *body) : GoASTStmt(eForStmt), m_init_up(init), m_cond_up(cond), m_post_up(post), m_body_up(body) {}
1166 ~GoASTForStmt() override = default;
1167
1168 const char *
1169 GetKindName() const override
1170 {
1171 return "ForStmt";
1172 }
1173
1174 static bool
1175 classof(const GoASTNode *n)
1176 {
1177 return n->GetKind() == eForStmt;
1178 }
1179
1180 const GoASTStmt *
1181 GetInit() const
1182 {
1183 return m_init_up.get();
1184 }
1185 void
1186 SetInit(GoASTStmt *init)
1187 {
1188 m_init_up.reset(init);
1189 }
1190
1191 const GoASTExpr *
1192 GetCond() const
1193 {
1194 return m_cond_up.get();
1195 }
1196 void
1197 SetCond(GoASTExpr *cond)
1198 {
1199 m_cond_up.reset(cond);
1200 }
1201
1202 const GoASTStmt *
1203 GetPost() const
1204 {
1205 return m_post_up.get();
1206 }
1207 void
1208 SetPost(GoASTStmt *post)
1209 {
1210 m_post_up.reset(post);
1211 }
1212
1213 const GoASTBlockStmt *
1214 GetBody() const
1215 {
1216 return m_body_up.get();
1217 }
1218 void
1219 SetBody(GoASTBlockStmt *body)
1220 {
1221 m_body_up.reset(body);
1222 }
1223
1224 private:
1225 friend class GoASTNode;
1226 std::unique_ptr<GoASTStmt> m_init_up;
1227 std::unique_ptr<GoASTExpr> m_cond_up;
1228 std::unique_ptr<GoASTStmt> m_post_up;
1229 std::unique_ptr<GoASTBlockStmt> m_body_up;
1230
1231 GoASTForStmt(const GoASTForStmt &) = delete;
1232 const GoASTForStmt &operator=(const GoASTForStmt &) = delete;
1233};
1234
1235class GoASTFuncType : public GoASTExpr
1236{
1237 public:
1238 GoASTFuncType(GoASTFieldList *params, GoASTFieldList *results) : GoASTExpr(eFuncType), m_params_up(params), m_results_up(results) {}
1239 ~GoASTFuncType() override = default;
1240
1241 const char *
1242 GetKindName() const override
1243 {
1244 return "FuncType";
1245 }
1246
1247 static bool
1248 classof(const GoASTNode *n)
1249 {
1250 return n->GetKind() == eFuncType;
1251 }
1252
1253 const GoASTFieldList *
1254 GetParams() const
1255 {
1256 return m_params_up.get();
1257 }
1258 void
1259 SetParams(GoASTFieldList *params)
1260 {
1261 m_params_up.reset(params);
1262 }
1263
1264 const GoASTFieldList *
1265 GetResults() const
1266 {
1267 return m_results_up.get();
1268 }
1269 void
1270 SetResults(GoASTFieldList *results)
1271 {
1272 m_results_up.reset(results);
1273 }
1274
1275 private:
1276 friend class GoASTNode;
1277 std::unique_ptr<GoASTFieldList> m_params_up;
1278 std::unique_ptr<GoASTFieldList> m_results_up;
1279
1280 GoASTFuncType(const GoASTFuncType &) = delete;
1281 const GoASTFuncType &operator=(const GoASTFuncType &) = delete;
1282};
1283
1284class GoASTFuncDecl : public GoASTDecl
1285{
1286 public:
1287 GoASTFuncDecl(GoASTFieldList *recv, GoASTIdent *name, GoASTFuncType *type, GoASTBlockStmt *body) : GoASTDecl(eFuncDecl), m_recv_up(recv), m_name_up(name), m_type_up(type), m_body_up(body) {}
1288 ~GoASTFuncDecl() override = default;
1289
1290 const char *
1291 GetKindName() const override
1292 {
1293 return "FuncDecl";
1294 }
1295
1296 static bool
1297 classof(const GoASTNode *n)
1298 {
1299 return n->GetKind() == eFuncDecl;
1300 }
1301
1302 const GoASTFieldList *
1303 GetRecv() const
1304 {
1305 return m_recv_up.get();
1306 }
1307 void
1308 SetRecv(GoASTFieldList *recv)
1309 {
1310 m_recv_up.reset(recv);
1311 }
1312
1313 const GoASTIdent *
1314 GetName() const
1315 {
1316 return m_name_up.get();
1317 }
1318 void
1319 SetName(GoASTIdent *name)
1320 {
1321 m_name_up.reset(name);
1322 }
1323
1324 const GoASTFuncType *
1325 GetType() const
1326 {
1327 return m_type_up.get();
1328 }
1329 void
1330 SetType(GoASTFuncType *type)
1331 {
1332 m_type_up.reset(type);
1333 }
1334
1335 const GoASTBlockStmt *
1336 GetBody() const
1337 {
1338 return m_body_up.get();
1339 }
1340 void
1341 SetBody(GoASTBlockStmt *body)
1342 {
1343 m_body_up.reset(body);
1344 }
1345
1346 private:
1347 friend class GoASTNode;
1348 std::unique_ptr<GoASTFieldList> m_recv_up;
1349 std::unique_ptr<GoASTIdent> m_name_up;
1350 std::unique_ptr<GoASTFuncType> m_type_up;
1351 std::unique_ptr<GoASTBlockStmt> m_body_up;
1352
1353 GoASTFuncDecl(const GoASTFuncDecl &) = delete;
1354 const GoASTFuncDecl &operator=(const GoASTFuncDecl &) = delete;
1355};
1356
1357class GoASTFuncLit : public GoASTExpr
1358{
1359 public:
1360 GoASTFuncLit(GoASTFuncType *type, GoASTBlockStmt *body) : GoASTExpr(eFuncLit), m_type_up(type), m_body_up(body) {}
1361 ~GoASTFuncLit() override = default;
1362
1363 const char *
1364 GetKindName() const override
1365 {
1366 return "FuncLit";
1367 }
1368
1369 static bool
1370 classof(const GoASTNode *n)
1371 {
1372 return n->GetKind() == eFuncLit;
1373 }
1374
1375 const GoASTFuncType *
1376 GetType() const
1377 {
1378 return m_type_up.get();
1379 }
1380 void
1381 SetType(GoASTFuncType *type)
1382 {
1383 m_type_up.reset(type);
1384 }
1385
1386 const GoASTBlockStmt *
1387 GetBody() const
1388 {
1389 return m_body_up.get();
1390 }
1391 void
1392 SetBody(GoASTBlockStmt *body)
1393 {
1394 m_body_up.reset(body);
1395 }
1396
1397 private:
1398 friend class GoASTNode;
1399 std::unique_ptr<GoASTFuncType> m_type_up;
1400 std::unique_ptr<GoASTBlockStmt> m_body_up;
1401
1402 GoASTFuncLit(const GoASTFuncLit &) = delete;
1403 const GoASTFuncLit &operator=(const GoASTFuncLit &) = delete;
1404};
1405
1406class GoASTGenDecl : public GoASTDecl
1407{
1408 public:
1409 explicit GoASTGenDecl(TokenType tok) : GoASTDecl(eGenDecl), m_tok(tok) {}
1410 ~GoASTGenDecl() override = default;
1411
1412 const char *
1413 GetKindName() const override
1414 {
1415 return "GenDecl";
1416 }
1417
1418 static bool
1419 classof(const GoASTNode *n)
1420 {
1421 return n->GetKind() == eGenDecl;
1422 }
1423
1424 TokenType
1425 GetTok() const
1426 {
1427 return m_tok;
1428 }
1429 void
1430 SetTok(TokenType tok)
1431 {
1432 m_tok = tok;
1433 }
1434
1435 size_t
1436 NumSpecs() const
1437 {
1438 return m_specs.size();
1439 }
1440 const GoASTSpec *
1441 GetSpecs(int i) const
1442 {
1443 return m_specs[i].get();
1444 }
1445 void
1446 AddSpecs(GoASTSpec *specs)
1447 {
1448 m_specs.push_back(std::unique_ptr<GoASTSpec>(specs));
1449 }
1450
1451 private:
1452 friend class GoASTNode;
1453 TokenType m_tok;
1454 std::vector<std::unique_ptr<GoASTSpec> > m_specs;
1455
1456 GoASTGenDecl(const GoASTGenDecl &) = delete;
1457 const GoASTGenDecl &operator=(const GoASTGenDecl &) = delete;
1458};
1459
1460class GoASTGoStmt : public GoASTStmt
1461{
1462 public:
1463 explicit GoASTGoStmt(GoASTCallExpr *call) : GoASTStmt(eGoStmt), m_call_up(call) {}
1464 ~GoASTGoStmt() override = default;
1465
1466 const char *
1467 GetKindName() const override
1468 {
1469 return "GoStmt";
1470 }
1471
1472 static bool
1473 classof(const GoASTNode *n)
1474 {
1475 return n->GetKind() == eGoStmt;
1476 }
1477
1478 const GoASTCallExpr *
1479 GetCall() const
1480 {
1481 return m_call_up.get();
1482 }
1483 void
1484 SetCall(GoASTCallExpr *call)
1485 {
1486 m_call_up.reset(call);
1487 }
1488
1489 private:
1490 friend class GoASTNode;
1491 std::unique_ptr<GoASTCallExpr> m_call_up;
1492
1493 GoASTGoStmt(const GoASTGoStmt &) = delete;
1494 const GoASTGoStmt &operator=(const GoASTGoStmt &) = delete;
1495};
1496
1497class GoASTIfStmt : public GoASTStmt
1498{
1499 public:
1500 GoASTIfStmt(GoASTStmt *init, GoASTExpr *cond, GoASTBlockStmt *body, GoASTStmt *els) : GoASTStmt(eIfStmt), m_init_up(init), m_cond_up(cond), m_body_up(body), m_els_up(els) {}
1501 ~GoASTIfStmt() override = default;
1502
1503 const char *
1504 GetKindName() const override
1505 {
1506 return "IfStmt";
1507 }
1508
1509 static bool
1510 classof(const GoASTNode *n)
1511 {
1512 return n->GetKind() == eIfStmt;
1513 }
1514
1515 const GoASTStmt *
1516 GetInit() const
1517 {
1518 return m_init_up.get();
1519 }
1520 void
1521 SetInit(GoASTStmt *init)
1522 {
1523 m_init_up.reset(init);
1524 }
1525
1526 const GoASTExpr *
1527 GetCond() const
1528 {
1529 return m_cond_up.get();
1530 }
1531 void
1532 SetCond(GoASTExpr *cond)
1533 {
1534 m_cond_up.reset(cond);
1535 }
1536
1537 const GoASTBlockStmt *
1538 GetBody() const
1539 {
1540 return m_body_up.get();
1541 }
1542 void
1543 SetBody(GoASTBlockStmt *body)
1544 {
1545 m_body_up.reset(body);
1546 }
1547
1548 const GoASTStmt *
1549 GetEls() const
1550 {
1551 return m_els_up.get();
1552 }
1553 void
1554 SetEls(GoASTStmt *els)
1555 {
1556 m_els_up.reset(els);
1557 }
1558
1559 private:
1560 friend class GoASTNode;
1561 std::unique_ptr<GoASTStmt> m_init_up;
1562 std::unique_ptr<GoASTExpr> m_cond_up;
1563 std::unique_ptr<GoASTBlockStmt> m_body_up;
1564 std::unique_ptr<GoASTStmt> m_els_up;
1565
1566 GoASTIfStmt(const GoASTIfStmt &) = delete;
1567 const GoASTIfStmt &operator=(const GoASTIfStmt &) = delete;
1568};
1569
1570class GoASTImportSpec : public GoASTSpec
1571{
1572 public:
1573 GoASTImportSpec(GoASTIdent *name, GoASTBasicLit *path) : GoASTSpec(eImportSpec), m_name_up(name), m_path_up(path) {}
1574 ~GoASTImportSpec() override = default;
1575
1576 const char *
1577 GetKindName() const override
1578 {
1579 return "ImportSpec";
1580 }
1581
1582 static bool
1583 classof(const GoASTNode *n)
1584 {
1585 return n->GetKind() == eImportSpec;
1586 }
1587
1588 const GoASTIdent *
1589 GetName() const
1590 {
1591 return m_name_up.get();
1592 }
1593 void
1594 SetName(GoASTIdent *name)
1595 {
1596 m_name_up.reset(name);
1597 }
1598
1599 const GoASTBasicLit *
1600 GetPath() const
1601 {
1602 return m_path_up.get();
1603 }
1604 void
1605 SetPath(GoASTBasicLit *path)
1606 {
1607 m_path_up.reset(path);
1608 }
1609
1610 private:
1611 friend class GoASTNode;
1612 std::unique_ptr<GoASTIdent> m_name_up;
1613 std::unique_ptr<GoASTBasicLit> m_path_up;
1614
1615 GoASTImportSpec(const GoASTImportSpec &) = delete;
1616 const GoASTImportSpec &operator=(const GoASTImportSpec &) = delete;
1617};
1618
1619class GoASTIncDecStmt : public GoASTStmt
1620{
1621 public:
1622 GoASTIncDecStmt(GoASTExpr *x, TokenType tok) : GoASTStmt(eIncDecStmt), m_x_up(x), m_tok(tok) {}
1623 ~GoASTIncDecStmt() override = default;
1624
1625 const char *
1626 GetKindName() const override
1627 {
1628 return "IncDecStmt";
1629 }
1630
1631 static bool
1632 classof(const GoASTNode *n)
1633 {
1634 return n->GetKind() == eIncDecStmt;
1635 }
1636
1637 const GoASTExpr *
1638 GetX() const
1639 {
1640 return m_x_up.get();
1641 }
1642 void
1643 SetX(GoASTExpr *x)
1644 {
1645 m_x_up.reset(x);
1646 }
1647
1648 TokenType
1649 GetTok() const
1650 {
1651 return m_tok;
1652 }
1653 void
1654 SetTok(TokenType tok)
1655 {
1656 m_tok = tok;
1657 }
1658
1659 private:
1660 friend class GoASTNode;
1661 std::unique_ptr<GoASTExpr> m_x_up;
1662 TokenType m_tok;
1663
1664 GoASTIncDecStmt(const GoASTIncDecStmt &) = delete;
1665 const GoASTIncDecStmt &operator=(const GoASTIncDecStmt &) = delete;
1666};
1667
1668class GoASTIndexExpr : public GoASTExpr
1669{
1670 public:
1671 GoASTIndexExpr(GoASTExpr *x, GoASTExpr *index) : GoASTExpr(eIndexExpr), m_x_up(x), m_index_up(index) {}
1672 ~GoASTIndexExpr() override = default;
1673
1674 const char *
1675 GetKindName() const override
1676 {
1677 return "IndexExpr";
1678 }
1679
1680 static bool
1681 classof(const GoASTNode *n)
1682 {
1683 return n->GetKind() == eIndexExpr;
1684 }
1685
1686 const GoASTExpr *
1687 GetX() const
1688 {
1689 return m_x_up.get();
1690 }
1691 void
1692 SetX(GoASTExpr *x)
1693 {
1694 m_x_up.reset(x);
1695 }
1696
1697 const GoASTExpr *
1698 GetIndex() const
1699 {
1700 return m_index_up.get();
1701 }
1702 void
1703 SetIndex(GoASTExpr *index)
1704 {
1705 m_index_up.reset(index);
1706 }
1707
1708 private:
1709 friend class GoASTNode;
1710 std::unique_ptr<GoASTExpr> m_x_up;
1711 std::unique_ptr<GoASTExpr> m_index_up;
1712
1713 GoASTIndexExpr(const GoASTIndexExpr &) = delete;
1714 const GoASTIndexExpr &operator=(const GoASTIndexExpr &) = delete;
1715};
1716
1717class GoASTInterfaceType : public GoASTExpr
1718{
1719 public:
1720 explicit GoASTInterfaceType(GoASTFieldList *methods) : GoASTExpr(eInterfaceType), m_methods_up(methods) {}
1721 ~GoASTInterfaceType() override = default;
1722
1723 const char *
1724 GetKindName() const override
1725 {
1726 return "InterfaceType";
1727 }
1728
1729 static bool
1730 classof(const GoASTNode *n)
1731 {
1732 return n->GetKind() == eInterfaceType;
1733 }
1734
1735 const GoASTFieldList *
1736 GetMethods() const
1737 {
1738 return m_methods_up.get();
1739 }
1740 void
1741 SetMethods(GoASTFieldList *methods)
1742 {
1743 m_methods_up.reset(methods);
1744 }
1745
1746 private:
1747 friend class GoASTNode;
1748 std::unique_ptr<GoASTFieldList> m_methods_up;
1749
1750 GoASTInterfaceType(const GoASTInterfaceType &) = delete;
1751 const GoASTInterfaceType &operator=(const GoASTInterfaceType &) = delete;
1752};
1753
1754class GoASTKeyValueExpr : public GoASTExpr
1755{
1756 public:
1757 GoASTKeyValueExpr(GoASTExpr *key, GoASTExpr *value) : GoASTExpr(eKeyValueExpr), m_key_up(key), m_value_up(value) {}
1758 ~GoASTKeyValueExpr() override = default;
1759
1760 const char *
1761 GetKindName() const override
1762 {
1763 return "KeyValueExpr";
1764 }
1765
1766 static bool
1767 classof(const GoASTNode *n)
1768 {
1769 return n->GetKind() == eKeyValueExpr;
1770 }
1771
1772 const GoASTExpr *
1773 GetKey() const
1774 {
1775 return m_key_up.get();
1776 }
1777 void
1778 SetKey(GoASTExpr *key)
1779 {
1780 m_key_up.reset(key);
1781 }
1782
1783 const GoASTExpr *
1784 GetValue() const
1785 {
1786 return m_value_up.get();
1787 }
1788 void
1789 SetValue(GoASTExpr *value)
1790 {
1791 m_value_up.reset(value);
1792 }
1793
1794 private:
1795 friend class GoASTNode;
1796 std::unique_ptr<GoASTExpr> m_key_up;
1797 std::unique_ptr<GoASTExpr> m_value_up;
1798
1799 GoASTKeyValueExpr(const GoASTKeyValueExpr &) = delete;
1800 const GoASTKeyValueExpr &operator=(const GoASTKeyValueExpr &) = delete;
1801};
1802
1803class GoASTLabeledStmt : public GoASTStmt
1804{
1805 public:
1806 GoASTLabeledStmt(GoASTIdent *label, GoASTStmt *stmt) : GoASTStmt(eLabeledStmt), m_label_up(label), m_stmt_up(stmt) {}
1807 ~GoASTLabeledStmt() override = default;
1808
1809 const char *
1810 GetKindName() const override
1811 {
1812 return "LabeledStmt";
1813 }
1814
1815 static bool
1816 classof(const GoASTNode *n)
1817 {
1818 return n->GetKind() == eLabeledStmt;
1819 }
1820
1821 const GoASTIdent *
1822 GetLabel() const
1823 {
1824 return m_label_up.get();
1825 }
1826 void
1827 SetLabel(GoASTIdent *label)
1828 {
1829 m_label_up.reset(label);
1830 }
1831
1832 const GoASTStmt *
1833 GetStmt() const
1834 {
1835 return m_stmt_up.get();
1836 }
1837 void
1838 SetStmt(GoASTStmt *stmt)
1839 {
1840 m_stmt_up.reset(stmt);
1841 }
1842
1843 private:
1844 friend class GoASTNode;
1845 std::unique_ptr<GoASTIdent> m_label_up;
1846 std::unique_ptr<GoASTStmt> m_stmt_up;
1847
1848 GoASTLabeledStmt(const GoASTLabeledStmt &) = delete;
1849 const GoASTLabeledStmt &operator=(const GoASTLabeledStmt &) = delete;
1850};
1851
1852class GoASTMapType : public GoASTExpr
1853{
1854 public:
1855 GoASTMapType(GoASTExpr *key, GoASTExpr *value) : GoASTExpr(eMapType), m_key_up(key), m_value_up(value) {}
1856 ~GoASTMapType() override = default;
1857
1858 const char *
1859 GetKindName() const override
1860 {
1861 return "MapType";
1862 }
1863
1864 static bool
1865 classof(const GoASTNode *n)
1866 {
1867 return n->GetKind() == eMapType;
1868 }
1869
1870 const GoASTExpr *
1871 GetKey() const
1872 {
1873 return m_key_up.get();
1874 }
1875 void
1876 SetKey(GoASTExpr *key)
1877 {
1878 m_key_up.reset(key);
1879 }
1880
1881 const GoASTExpr *
1882 GetValue() const
1883 {
1884 return m_value_up.get();
1885 }
1886 void
1887 SetValue(GoASTExpr *value)
1888 {
1889 m_value_up.reset(value);
1890 }
1891
1892 private:
1893 friend class GoASTNode;
1894 std::unique_ptr<GoASTExpr> m_key_up;
1895 std::unique_ptr<GoASTExpr> m_value_up;
1896
1897 GoASTMapType(const GoASTMapType &) = delete;
1898 const GoASTMapType &operator=(const GoASTMapType &) = delete;
1899};
1900
1901class GoASTParenExpr : public GoASTExpr
1902{
1903 public:
1904 explicit GoASTParenExpr(GoASTExpr *x) : GoASTExpr(eParenExpr), m_x_up(x) {}
1905 ~GoASTParenExpr() override = default;
1906
1907 const char *
1908 GetKindName() const override
1909 {
1910 return "ParenExpr";
1911 }
1912
1913 static bool
1914 classof(const GoASTNode *n)
1915 {
1916 return n->GetKind() == eParenExpr;
1917 }
1918
1919 const GoASTExpr *
1920 GetX() const
1921 {
1922 return m_x_up.get();
1923 }
1924 void
1925 SetX(GoASTExpr *x)
1926 {
1927 m_x_up.reset(x);
1928 }
1929
1930 private:
1931 friend class GoASTNode;
1932 std::unique_ptr<GoASTExpr> m_x_up;
1933
1934 GoASTParenExpr(const GoASTParenExpr &) = delete;
1935 const GoASTParenExpr &operator=(const GoASTParenExpr &) = delete;
1936};
1937
1938class GoASTRangeStmt : public GoASTStmt
1939{
1940 public:
1941 GoASTRangeStmt(GoASTExpr *key, GoASTExpr *value, bool define, GoASTExpr *x, GoASTBlockStmt *body) : GoASTStmt(eRangeStmt), m_key_up(key), m_value_up(value), m_define(define), m_x_up(x), m_body_up(body) {}
1942 ~GoASTRangeStmt() override = default;
1943
1944 const char *
1945 GetKindName() const override
1946 {
1947 return "RangeStmt";
1948 }
1949
1950 static bool
1951 classof(const GoASTNode *n)
1952 {
1953 return n->GetKind() == eRangeStmt;
1954 }
1955
1956 const GoASTExpr *
1957 GetKey() const
1958 {
1959 return m_key_up.get();
1960 }
1961 void
1962 SetKey(GoASTExpr *key)
1963 {
1964 m_key_up.reset(key);
1965 }
1966
1967 const GoASTExpr *
1968 GetValue() const
1969 {
1970 return m_value_up.get();
1971 }
1972 void
1973 SetValue(GoASTExpr *value)
1974 {
1975 m_value_up.reset(value);
1976 }
1977
1978 bool
1979 GetDefine() const
1980 {
1981 return m_define;
1982 }
1983 void
1984 SetDefine(bool define)
1985 {
1986 m_define = define;
1987 }
1988
1989 const GoASTExpr *
1990 GetX() const
1991 {
1992 return m_x_up.get();
1993 }
1994 void
1995 SetX(GoASTExpr *x)
1996 {
1997 m_x_up.reset(x);
1998 }
1999
2000 const GoASTBlockStmt *
2001 GetBody() const
2002 {
2003 return m_body_up.get();
2004 }
2005 void
2006 SetBody(GoASTBlockStmt *body)
2007 {
2008 m_body_up.reset(body);
2009 }
2010
2011 private:
2012 friend class GoASTNode;
2013 std::unique_ptr<GoASTExpr> m_key_up;
2014 std::unique_ptr<GoASTExpr> m_value_up;
2015 bool m_define;
2016 std::unique_ptr<GoASTExpr> m_x_up;
2017 std::unique_ptr<GoASTBlockStmt> m_body_up;
2018
2019 GoASTRangeStmt(const GoASTRangeStmt &) = delete;
2020 const GoASTRangeStmt &operator=(const GoASTRangeStmt &) = delete;
2021};
2022
2023class GoASTReturnStmt : public GoASTStmt
2024{
2025 public:
2026 GoASTReturnStmt() : GoASTStmt(eReturnStmt) {}
2027 ~GoASTReturnStmt() override = default;
2028
2029 const char *
2030 GetKindName() const override
2031 {
2032 return "ReturnStmt";
2033 }
2034
2035 static bool
2036 classof(const GoASTNode *n)
2037 {
2038 return n->GetKind() == eReturnStmt;
2039 }
2040
2041 size_t
2042 NumResults() const
2043 {
2044 return m_results.size();
2045 }
2046 const GoASTExpr *
2047 GetResults(int i) const
2048 {
2049 return m_results[i].get();
2050 }
2051 void
2052 AddResults(GoASTExpr *results)
2053 {
2054 m_results.push_back(std::unique_ptr<GoASTExpr>(results));
2055 }
2056
2057 private:
2058 friend class GoASTNode;
2059 std::vector<std::unique_ptr<GoASTExpr> > m_results;
2060
2061 GoASTReturnStmt(const GoASTReturnStmt &) = delete;
2062 const GoASTReturnStmt &operator=(const GoASTReturnStmt &) = delete;
2063};
2064
2065class GoASTSelectStmt : public GoASTStmt
2066{
2067 public:
2068 explicit GoASTSelectStmt(GoASTBlockStmt *body) : GoASTStmt(eSelectStmt), m_body_up(body) {}
2069 ~GoASTSelectStmt() override = default;
2070
2071 const char *
2072 GetKindName() const override
2073 {
2074 return "SelectStmt";
2075 }
2076
2077 static bool
2078 classof(const GoASTNode *n)
2079 {
2080 return n->GetKind() == eSelectStmt;
2081 }
2082
2083 const GoASTBlockStmt *
2084 GetBody() const
2085 {
2086 return m_body_up.get();
2087 }
2088 void
2089 SetBody(GoASTBlockStmt *body)
2090 {
2091 m_body_up.reset(body);
2092 }
2093
2094 private:
2095 friend class GoASTNode;
2096 std::unique_ptr<GoASTBlockStmt> m_body_up;
2097
2098 GoASTSelectStmt(const GoASTSelectStmt &) = delete;
2099 const GoASTSelectStmt &operator=(const GoASTSelectStmt &) = delete;
2100};
2101
2102class GoASTSelectorExpr : public GoASTExpr
2103{
2104 public:
2105 GoASTSelectorExpr(GoASTExpr *x, GoASTIdent *sel) : GoASTExpr(eSelectorExpr), m_x_up(x), m_sel_up(sel) {}
2106 ~GoASTSelectorExpr() override = default;
2107
2108 const char *
2109 GetKindName() const override
2110 {
2111 return "SelectorExpr";
2112 }
2113
2114 static bool
2115 classof(const GoASTNode *n)
2116 {
2117 return n->GetKind() == eSelectorExpr;
2118 }
2119
2120 const GoASTExpr *
2121 GetX() const
2122 {
2123 return m_x_up.get();
2124 }
2125 void
2126 SetX(GoASTExpr *x)
2127 {
2128 m_x_up.reset(x);
2129 }
2130
2131 const GoASTIdent *
2132 GetSel() const
2133 {
2134 return m_sel_up.get();
2135 }
2136 void
2137 SetSel(GoASTIdent *sel)
2138 {
2139 m_sel_up.reset(sel);
2140 }
2141
2142 private:
2143 friend class GoASTNode;
2144 std::unique_ptr<GoASTExpr> m_x_up;
2145 std::unique_ptr<GoASTIdent> m_sel_up;
2146
2147 GoASTSelectorExpr(const GoASTSelectorExpr &) = delete;
2148 const GoASTSelectorExpr &operator=(const GoASTSelectorExpr &) = delete;
2149};
2150
2151class GoASTSendStmt : public GoASTStmt
2152{
2153 public:
2154 GoASTSendStmt(GoASTExpr *chan, GoASTExpr *value) : GoASTStmt(eSendStmt), m_chan_up(chan), m_value_up(value) {}
2155 ~GoASTSendStmt() override = default;
2156
2157 const char *
2158 GetKindName() const override
2159 {
2160 return "SendStmt";
2161 }
2162
2163 static bool
2164 classof(const GoASTNode *n)
2165 {
2166 return n->GetKind() == eSendStmt;
2167 }
2168
2169 const GoASTExpr *
2170 GetChan() const
2171 {
2172 return m_chan_up.get();
2173 }
2174 void
2175 SetChan(GoASTExpr *chan)
2176 {
2177 m_chan_up.reset(chan);
2178 }
2179
2180 const GoASTExpr *
2181 GetValue() const
2182 {
2183 return m_value_up.get();
2184 }
2185 void
2186 SetValue(GoASTExpr *value)
2187 {
2188 m_value_up.reset(value);
2189 }
2190
2191 private:
2192 friend class GoASTNode;
2193 std::unique_ptr<GoASTExpr> m_chan_up;
2194 std::unique_ptr<GoASTExpr> m_value_up;
2195
2196 GoASTSendStmt(const GoASTSendStmt &) = delete;
2197 const GoASTSendStmt &operator=(const GoASTSendStmt &) = delete;
2198};
2199
2200class GoASTSliceExpr : public GoASTExpr
2201{
2202 public:
2203 GoASTSliceExpr(GoASTExpr *x, GoASTExpr *low, GoASTExpr *high, GoASTExpr *max, bool slice3) : GoASTExpr(eSliceExpr), m_x_up(x), m_low_up(low), m_high_up(high), m_max_up(max), m_slice3(slice3) {}
2204 ~GoASTSliceExpr() override = default;
2205
2206 const char *
2207 GetKindName() const override
2208 {
2209 return "SliceExpr";
2210 }
2211
2212 static bool
2213 classof(const GoASTNode *n)
2214 {
2215 return n->GetKind() == eSliceExpr;
2216 }
2217
2218 const GoASTExpr *
2219 GetX() const
2220 {
2221 return m_x_up.get();
2222 }
2223 void
2224 SetX(GoASTExpr *x)
2225 {
2226 m_x_up.reset(x);
2227 }
2228
2229 const GoASTExpr *
2230 GetLow() const
2231 {
2232 return m_low_up.get();
2233 }
2234 void
2235 SetLow(GoASTExpr *low)
2236 {
2237 m_low_up.reset(low);
2238 }
2239
2240 const GoASTExpr *
2241 GetHigh() const
2242 {
2243 return m_high_up.get();
2244 }
2245 void
2246 SetHigh(GoASTExpr *high)
2247 {
2248 m_high_up.reset(high);
2249 }
2250
2251 const GoASTExpr *
2252 GetMax() const
2253 {
2254 return m_max_up.get();
2255 }
2256 void
2257 SetMax(GoASTExpr *max)
2258 {
2259 m_max_up.reset(max);
2260 }
2261
2262 bool
2263 GetSlice3() const
2264 {
2265 return m_slice3;
2266 }
2267 void
2268 SetSlice3(bool slice3)
2269 {
2270 m_slice3 = slice3;
2271 }
2272
2273 private:
2274 friend class GoASTNode;
2275 std::unique_ptr<GoASTExpr> m_x_up;
2276 std::unique_ptr<GoASTExpr> m_low_up;
2277 std::unique_ptr<GoASTExpr> m_high_up;
2278 std::unique_ptr<GoASTExpr> m_max_up;
2279 bool m_slice3;
2280
2281 GoASTSliceExpr(const GoASTSliceExpr &) = delete;
2282 const GoASTSliceExpr &operator=(const GoASTSliceExpr &) = delete;
2283};
2284
2285class GoASTStarExpr : public GoASTExpr
2286{
2287 public:
2288 explicit GoASTStarExpr(GoASTExpr *x) : GoASTExpr(eStarExpr), m_x_up(x) {}
2289 ~GoASTStarExpr() override = default;
2290
2291 const char *
2292 GetKindName() const override
2293 {
2294 return "StarExpr";
2295 }
2296
2297 static bool
2298 classof(const GoASTNode *n)
2299 {
2300 return n->GetKind() == eStarExpr;
2301 }
2302
2303 const GoASTExpr *
2304 GetX() const
2305 {
2306 return m_x_up.get();
2307 }
2308 void
2309 SetX(GoASTExpr *x)
2310 {
2311 m_x_up.reset(x);
2312 }
2313
2314 private:
2315 friend class GoASTNode;
2316 std::unique_ptr<GoASTExpr> m_x_up;
2317
2318 GoASTStarExpr(const GoASTStarExpr &) = delete;
2319 const GoASTStarExpr &operator=(const GoASTStarExpr &) = delete;
2320};
2321
2322class GoASTStructType : public GoASTExpr
2323{
2324 public:
2325 explicit GoASTStructType(GoASTFieldList *fields) : GoASTExpr(eStructType), m_fields_up(fields) {}
2326 ~GoASTStructType() override = default;
2327
2328 const char *
2329 GetKindName() const override
2330 {
2331 return "StructType";
2332 }
2333
2334 static bool
2335 classof(const GoASTNode *n)
2336 {
2337 return n->GetKind() == eStructType;
2338 }
2339
2340 const GoASTFieldList *
2341 GetFields() const
2342 {
2343 return m_fields_up.get();
2344 }
2345 void
2346 SetFields(GoASTFieldList *fields)
2347 {
2348 m_fields_up.reset(fields);
2349 }
2350
2351 private:
2352 friend class GoASTNode;
2353 std::unique_ptr<GoASTFieldList> m_fields_up;
2354
2355 GoASTStructType(const GoASTStructType &) = delete;
2356 const GoASTStructType &operator=(const GoASTStructType &) = delete;
2357};
2358
2359class GoASTSwitchStmt : public GoASTStmt
2360{
2361 public:
2362 GoASTSwitchStmt(GoASTStmt *init, GoASTExpr *tag, GoASTBlockStmt *body) : GoASTStmt(eSwitchStmt), m_init_up(init), m_tag_up(tag), m_body_up(body) {}
2363 ~GoASTSwitchStmt() override = default;
2364
2365 const char *
2366 GetKindName() const override
2367 {
2368 return "SwitchStmt";
2369 }
2370
2371 static bool
2372 classof(const GoASTNode *n)
2373 {
2374 return n->GetKind() == eSwitchStmt;
2375 }
2376
2377 const GoASTStmt *
2378 GetInit() const
2379 {
2380 return m_init_up.get();
2381 }
2382 void
2383 SetInit(GoASTStmt *init)
2384 {
2385 m_init_up.reset(init);
2386 }
2387
2388 const GoASTExpr *
2389 GetTag() const
2390 {
2391 return m_tag_up.get();
2392 }
2393 void
2394 SetTag(GoASTExpr *tag)
2395 {
2396 m_tag_up.reset(tag);
2397 }
2398
2399 const GoASTBlockStmt *
2400 GetBody() const
2401 {
2402 return m_body_up.get();
2403 }
2404 void
2405 SetBody(GoASTBlockStmt *body)
2406 {
2407 m_body_up.reset(body);
2408 }
2409
2410 private:
2411 friend class GoASTNode;
2412 std::unique_ptr<GoASTStmt> m_init_up;
2413 std::unique_ptr<GoASTExpr> m_tag_up;
2414 std::unique_ptr<GoASTBlockStmt> m_body_up;
2415
2416 GoASTSwitchStmt(const GoASTSwitchStmt &) = delete;
2417 const GoASTSwitchStmt &operator=(const GoASTSwitchStmt &) = delete;
2418};
2419
2420class GoASTTypeAssertExpr : public GoASTExpr
2421{
2422 public:
2423 GoASTTypeAssertExpr(GoASTExpr *x, GoASTExpr *type) : GoASTExpr(eTypeAssertExpr), m_x_up(x), m_type_up(type) {}
2424 ~GoASTTypeAssertExpr() override = default;
2425
2426 const char *
2427 GetKindName() const override
2428 {
2429 return "TypeAssertExpr";
2430 }
2431
2432 static bool
2433 classof(const GoASTNode *n)
2434 {
2435 return n->GetKind() == eTypeAssertExpr;
2436 }
2437
2438 const GoASTExpr *
2439 GetX() const
2440 {
2441 return m_x_up.get();
2442 }
2443 void
2444 SetX(GoASTExpr *x)
2445 {
2446 m_x_up.reset(x);
2447 }
2448
2449 const GoASTExpr *
2450 GetType() const
2451 {
2452 return m_type_up.get();
2453 }
2454 void
2455 SetType(GoASTExpr *type)
2456 {
2457 m_type_up.reset(type);
2458 }
2459
2460 private:
2461 friend class GoASTNode;
2462 std::unique_ptr<GoASTExpr> m_x_up;
2463 std::unique_ptr<GoASTExpr> m_type_up;
2464
2465 GoASTTypeAssertExpr(const GoASTTypeAssertExpr &) = delete;
2466 const GoASTTypeAssertExpr &operator=(const GoASTTypeAssertExpr &) = delete;
2467};
2468
2469class GoASTTypeSpec : public GoASTSpec
2470{
2471 public:
2472 GoASTTypeSpec(GoASTIdent *name, GoASTExpr *type) : GoASTSpec(eTypeSpec), m_name_up(name), m_type_up(type) {}
2473 ~GoASTTypeSpec() override = default;
2474
2475 const char *
2476 GetKindName() const override
2477 {
2478 return "TypeSpec";
2479 }
2480
2481 static bool
2482 classof(const GoASTNode *n)
2483 {
2484 return n->GetKind() == eTypeSpec;
2485 }
2486
2487 const GoASTIdent *
2488 GetName() const
2489 {
2490 return m_name_up.get();
2491 }
2492 void
2493 SetName(GoASTIdent *name)
2494 {
2495 m_name_up.reset(name);
2496 }
2497
2498 const GoASTExpr *
2499 GetType() const
2500 {
2501 return m_type_up.get();
2502 }
2503 void
2504 SetType(GoASTExpr *type)
2505 {
2506 m_type_up.reset(type);
2507 }
2508
2509 private:
2510 friend class GoASTNode;
2511 std::unique_ptr<GoASTIdent> m_name_up;
2512 std::unique_ptr<GoASTExpr> m_type_up;
2513
2514 GoASTTypeSpec(const GoASTTypeSpec &) = delete;
2515 const GoASTTypeSpec &operator=(const GoASTTypeSpec &) = delete;
2516};
2517
2518class GoASTTypeSwitchStmt : public GoASTStmt
2519{
2520 public:
2521 GoASTTypeSwitchStmt(GoASTStmt *init, GoASTStmt *assign, GoASTBlockStmt *body) : GoASTStmt(eTypeSwitchStmt), m_init_up(init), m_assign_up(assign), m_body_up(body) {}
2522 ~GoASTTypeSwitchStmt() override = default;
2523
2524 const char *
2525 GetKindName() const override
2526 {
2527 return "TypeSwitchStmt";
2528 }
2529
2530 static bool
2531 classof(const GoASTNode *n)
2532 {
2533 return n->GetKind() == eTypeSwitchStmt;
2534 }
2535
2536 const GoASTStmt *
2537 GetInit() const
2538 {
2539 return m_init_up.get();
2540 }
2541 void
2542 SetInit(GoASTStmt *init)
2543 {
2544 m_init_up.reset(init);
2545 }
2546
2547 const GoASTStmt *
2548 GetAssign() const
2549 {
2550 return m_assign_up.get();
2551 }
2552 void
2553 SetAssign(GoASTStmt *assign)
2554 {
2555 m_assign_up.reset(assign);
2556 }
2557
2558 const GoASTBlockStmt *
2559 GetBody() const
2560 {
2561 return m_body_up.get();
2562 }
2563 void
2564 SetBody(GoASTBlockStmt *body)
2565 {
2566 m_body_up.reset(body);
2567 }
2568
2569 private:
2570 friend class GoASTNode;
2571 std::unique_ptr<GoASTStmt> m_init_up;
2572 std::unique_ptr<GoASTStmt> m_assign_up;
2573 std::unique_ptr<GoASTBlockStmt> m_body_up;
2574
2575 GoASTTypeSwitchStmt(const GoASTTypeSwitchStmt &) = delete;
2576 const GoASTTypeSwitchStmt &operator=(const GoASTTypeSwitchStmt &) = delete;
2577};
2578
2579class GoASTUnaryExpr : public GoASTExpr
2580{
2581 public:
2582 GoASTUnaryExpr(TokenType op, GoASTExpr *x) : GoASTExpr(eUnaryExpr), m_op(op), m_x_up(x) {}
2583 ~GoASTUnaryExpr() override = default;
2584
2585 const char *
2586 GetKindName() const override
2587 {
2588 return "UnaryExpr";
2589 }
2590
2591 static bool
2592 classof(const GoASTNode *n)
2593 {
2594 return n->GetKind() == eUnaryExpr;
2595 }
2596
2597 TokenType
2598 GetOp() const
2599 {
2600 return m_op;
2601 }
2602 void
2603 SetOp(TokenType op)
2604 {
2605 m_op = op;
2606 }
2607
2608 const GoASTExpr *
2609 GetX() const
2610 {
2611 return m_x_up.get();
2612 }
2613 void
2614 SetX(GoASTExpr *x)
2615 {
2616 m_x_up.reset(x);
2617 }
2618
2619 private:
2620 friend class GoASTNode;
2621 TokenType m_op;
2622 std::unique_ptr<GoASTExpr> m_x_up;
2623
2624 GoASTUnaryExpr(const GoASTUnaryExpr &) = delete;
2625 const GoASTUnaryExpr &operator=(const GoASTUnaryExpr &) = delete;
2626};
2627
2628class GoASTValueSpec : public GoASTSpec
2629{
2630 public:
2631 GoASTValueSpec() : GoASTSpec(eValueSpec) {}
2632 ~GoASTValueSpec() override = default;
2633
2634 const char *
2635 GetKindName() const override
2636 {
2637 return "ValueSpec";
2638 }
2639
2640 static bool
2641 classof(const GoASTNode *n)
2642 {
2643 return n->GetKind() == eValueSpec;
2644 }
2645
2646 size_t
2647 NumNames() const
2648 {
2649 return m_names.size();
2650 }
2651 const GoASTIdent *
2652 GetNames(int i) const
2653 {
2654 return m_names[i].get();
2655 }
2656 void
2657 AddNames(GoASTIdent *names)
2658 {
2659 m_names.push_back(std::unique_ptr<GoASTIdent>(names));
2660 }
2661
2662 const GoASTExpr *
2663 GetType() const
2664 {
2665 return m_type_up.get();
2666 }
2667 void
2668 SetType(GoASTExpr *type)
2669 {
2670 m_type_up.reset(type);
2671 }
2672
2673 size_t
2674 NumValues() const
2675 {
2676 return m_values.size();
2677 }
2678 const GoASTExpr *
2679 GetValues(int i) const
2680 {
2681 return m_values[i].get();
2682 }
2683 void
2684 AddValues(GoASTExpr *values)
2685 {
2686 m_values.push_back(std::unique_ptr<GoASTExpr>(values));
2687 }
2688
2689 private:
2690 friend class GoASTNode;
2691 std::vector<std::unique_ptr<GoASTIdent> > m_names;
2692 std::unique_ptr<GoASTExpr> m_type_up;
2693 std::vector<std::unique_ptr<GoASTExpr> > m_values;
2694
2695 GoASTValueSpec(const GoASTValueSpec &) = delete;
2696 const GoASTValueSpec &operator=(const GoASTValueSpec &) = delete;
2697};
2698
2699
2700template <typename R, typename V>
2701R GoASTDecl::Visit(V* v) const
2702{
2703 switch(GetKind())
2704 {
2705 case eBadDecl:
2706 return v->VisitBadDecl(llvm::cast<const GoASTBadDecl>(this));
2707 case eFuncDecl:
2708 return v->VisitFuncDecl(llvm::cast<const GoASTFuncDecl>(this));
2709 case eGenDecl:
2710 return v->VisitGenDecl(llvm::cast<const GoASTGenDecl>(this));
2711 default:
2712 assert(false && "Invalid kind");
2713 }
2714}
2715
2716template <typename R, typename V>
2717R GoASTExpr::Visit(V* v) const
2718{
2719 switch(GetKind())
2720 {
2721 case eArrayType:
2722 return v->VisitArrayType(llvm::cast<const GoASTArrayType>(this));
2723 case eBadExpr:
2724 return v->VisitBadExpr(llvm::cast<const GoASTBadExpr>(this));
2725 case eBasicLit:
2726 return v->VisitBasicLit(llvm::cast<const GoASTBasicLit>(this));
2727 case eBinaryExpr:
2728 return v->VisitBinaryExpr(llvm::cast<const GoASTBinaryExpr>(this));
2729 case eIdent:
2730 return v->VisitIdent(llvm::cast<const GoASTIdent>(this));
2731 case eCallExpr:
2732 return v->VisitCallExpr(llvm::cast<const GoASTCallExpr>(this));
2733 case eChanType:
2734 return v->VisitChanType(llvm::cast<const GoASTChanType>(this));
2735 case eCompositeLit:
2736 return v->VisitCompositeLit(llvm::cast<const GoASTCompositeLit>(this));
2737 case eEllipsis:
2738 return v->VisitEllipsis(llvm::cast<const GoASTEllipsis>(this));
2739 case eFuncType:
2740 return v->VisitFuncType(llvm::cast<const GoASTFuncType>(this));
2741 case eFuncLit:
2742 return v->VisitFuncLit(llvm::cast<const GoASTFuncLit>(this));
2743 case eIndexExpr:
2744 return v->VisitIndexExpr(llvm::cast<const GoASTIndexExpr>(this));
2745 case eInterfaceType:
2746 return v->VisitInterfaceType(llvm::cast<const GoASTInterfaceType>(this));
2747 case eKeyValueExpr:
2748 return v->VisitKeyValueExpr(llvm::cast<const GoASTKeyValueExpr>(this));
2749 case eMapType:
2750 return v->VisitMapType(llvm::cast<const GoASTMapType>(this));
2751 case eParenExpr:
2752 return v->VisitParenExpr(llvm::cast<const GoASTParenExpr>(this));
2753 case eSelectorExpr:
2754 return v->VisitSelectorExpr(llvm::cast<const GoASTSelectorExpr>(this));
2755 case eSliceExpr:
2756 return v->VisitSliceExpr(llvm::cast<const GoASTSliceExpr>(this));
2757 case eStarExpr:
2758 return v->VisitStarExpr(llvm::cast<const GoASTStarExpr>(this));
2759 case eStructType:
2760 return v->VisitStructType(llvm::cast<const GoASTStructType>(this));
2761 case eTypeAssertExpr:
2762 return v->VisitTypeAssertExpr(llvm::cast<const GoASTTypeAssertExpr>(this));
2763 case eUnaryExpr:
2764 return v->VisitUnaryExpr(llvm::cast<const GoASTUnaryExpr>(this));
2765 default:
2766 assert(false && "Invalid kind");
Zachary Turnera505be42016-01-13 21:22:00 +00002767 return R();
Ryan Brown998c8a1c12015-11-02 19:30:40 +00002768 }
2769}
2770
2771template <typename R, typename V>
2772R GoASTSpec::Visit(V* v) const
2773{
2774 switch(GetKind())
2775 {
2776 case eImportSpec:
2777 return v->VisitImportSpec(llvm::cast<const GoASTImportSpec>(this));
2778 case eTypeSpec:
2779 return v->VisitTypeSpec(llvm::cast<const GoASTTypeSpec>(this));
2780 case eValueSpec:
2781 return v->VisitValueSpec(llvm::cast<const GoASTValueSpec>(this));
2782 default:
2783 assert(false && "Invalid kind");
2784 }
2785}
2786
2787template <typename R, typename V>
2788R GoASTStmt::Visit(V* v) const
2789{
2790 switch(GetKind())
2791 {
2792 case eAssignStmt:
2793 return v->VisitAssignStmt(llvm::cast<const GoASTAssignStmt>(this));
2794 case eBadStmt:
2795 return v->VisitBadStmt(llvm::cast<const GoASTBadStmt>(this));
2796 case eBlockStmt:
2797 return v->VisitBlockStmt(llvm::cast<const GoASTBlockStmt>(this));
2798 case eBranchStmt:
2799 return v->VisitBranchStmt(llvm::cast<const GoASTBranchStmt>(this));
2800 case eCaseClause:
2801 return v->VisitCaseClause(llvm::cast<const GoASTCaseClause>(this));
2802 case eCommClause:
2803 return v->VisitCommClause(llvm::cast<const GoASTCommClause>(this));
2804 case eDeclStmt:
2805 return v->VisitDeclStmt(llvm::cast<const GoASTDeclStmt>(this));
2806 case eDeferStmt:
2807 return v->VisitDeferStmt(llvm::cast<const GoASTDeferStmt>(this));
2808 case eEmptyStmt:
2809 return v->VisitEmptyStmt(llvm::cast<const GoASTEmptyStmt>(this));
2810 case eExprStmt:
2811 return v->VisitExprStmt(llvm::cast<const GoASTExprStmt>(this));
2812 case eForStmt:
2813 return v->VisitForStmt(llvm::cast<const GoASTForStmt>(this));
2814 case eGoStmt:
2815 return v->VisitGoStmt(llvm::cast<const GoASTGoStmt>(this));
2816 case eIfStmt:
2817 return v->VisitIfStmt(llvm::cast<const GoASTIfStmt>(this));
2818 case eIncDecStmt:
2819 return v->VisitIncDecStmt(llvm::cast<const GoASTIncDecStmt>(this));
2820 case eLabeledStmt:
2821 return v->VisitLabeledStmt(llvm::cast<const GoASTLabeledStmt>(this));
2822 case eRangeStmt:
2823 return v->VisitRangeStmt(llvm::cast<const GoASTRangeStmt>(this));
2824 case eReturnStmt:
2825 return v->VisitReturnStmt(llvm::cast<const GoASTReturnStmt>(this));
2826 case eSelectStmt:
2827 return v->VisitSelectStmt(llvm::cast<const GoASTSelectStmt>(this));
2828 case eSendStmt:
2829 return v->VisitSendStmt(llvm::cast<const GoASTSendStmt>(this));
2830 case eSwitchStmt:
2831 return v->VisitSwitchStmt(llvm::cast<const GoASTSwitchStmt>(this));
2832 case eTypeSwitchStmt:
2833 return v->VisitTypeSwitchStmt(llvm::cast<const GoASTTypeSwitchStmt>(this));
2834 default:
2835 assert(false && "Invalid kind");
2836 }
2837}
2838
2839template <typename V>
2840void GoASTNode::WalkChildren(V &v)
2841{
2842 switch (m_kind)
2843 {
2844
2845
2846 case eArrayType:
2847 {
2848 GoASTArrayType *n = llvm::cast<GoASTArrayType>(this);
2849 (void)n;
2850 v(n->m_len_up.get());
2851 v(n->m_elt_up.get());
2852 return;
2853 }
2854 case eAssignStmt:
2855 {
2856 GoASTAssignStmt *n = llvm::cast<GoASTAssignStmt>(this);
2857 (void)n;
2858 for (auto& e : n->m_lhs) { v(e.get()); }
2859 for (auto& e : n->m_rhs) { v(e.get()); }
2860 return;
2861 }
2862 case eBasicLit:
2863 {
2864 GoASTBasicLit *n = llvm::cast<GoASTBasicLit>(this);
2865 (void)n;
2866 return;
2867 }
2868 case eBinaryExpr:
2869 {
2870 GoASTBinaryExpr *n = llvm::cast<GoASTBinaryExpr>(this);
2871 (void)n;
2872 v(n->m_x_up.get());
2873 v(n->m_y_up.get());
2874 return;
2875 }
2876 case eBlockStmt:
2877 {
2878 GoASTBlockStmt *n = llvm::cast<GoASTBlockStmt>(this);
2879 (void)n;
2880 for (auto& e : n->m_list) { v(e.get()); }
2881 return;
2882 }
2883 case eIdent:
2884 {
2885 GoASTIdent *n = llvm::cast<GoASTIdent>(this);
2886 (void)n;
2887 return;
2888 }
2889 case eBranchStmt:
2890 {
2891 GoASTBranchStmt *n = llvm::cast<GoASTBranchStmt>(this);
2892 (void)n;
2893 v(n->m_label_up.get());
2894 return;
2895 }
2896 case eCallExpr:
2897 {
2898 GoASTCallExpr *n = llvm::cast<GoASTCallExpr>(this);
2899 (void)n;
2900 v(n->m_fun_up.get());
2901 for (auto& e : n->m_args) { v(e.get()); }
2902 return;
2903 }
2904 case eCaseClause:
2905 {
2906 GoASTCaseClause *n = llvm::cast<GoASTCaseClause>(this);
2907 (void)n;
2908 for (auto& e : n->m_list) { v(e.get()); }
2909 for (auto& e : n->m_body) { v(e.get()); }
2910 return;
2911 }
2912 case eChanType:
2913 {
2914 GoASTChanType *n = llvm::cast<GoASTChanType>(this);
2915 (void)n;
2916 v(n->m_value_up.get());
2917 return;
2918 }
2919 case eCommClause:
2920 {
2921 GoASTCommClause *n = llvm::cast<GoASTCommClause>(this);
2922 (void)n;
2923 v(n->m_comm_up.get());
2924 for (auto& e : n->m_body) { v(e.get()); }
2925 return;
2926 }
2927 case eCompositeLit:
2928 {
2929 GoASTCompositeLit *n = llvm::cast<GoASTCompositeLit>(this);
2930 (void)n;
2931 v(n->m_type_up.get());
2932 for (auto& e : n->m_elts) { v(e.get()); }
2933 return;
2934 }
2935 case eDeclStmt:
2936 {
2937 GoASTDeclStmt *n = llvm::cast<GoASTDeclStmt>(this);
2938 (void)n;
2939 v(n->m_decl_up.get());
2940 return;
2941 }
2942 case eDeferStmt:
2943 {
2944 GoASTDeferStmt *n = llvm::cast<GoASTDeferStmt>(this);
2945 (void)n;
2946 v(n->m_call_up.get());
2947 return;
2948 }
2949 case eEllipsis:
2950 {
2951 GoASTEllipsis *n = llvm::cast<GoASTEllipsis>(this);
2952 (void)n;
2953 v(n->m_elt_up.get());
2954 return;
2955 }
2956 case eExprStmt:
2957 {
2958 GoASTExprStmt *n = llvm::cast<GoASTExprStmt>(this);
2959 (void)n;
2960 v(n->m_x_up.get());
2961 return;
2962 }
2963 case eField:
2964 {
2965 GoASTField *n = llvm::cast<GoASTField>(this);
2966 (void)n;
2967 for (auto& e : n->m_names) { v(e.get()); }
2968 v(n->m_type_up.get());
2969 v(n->m_tag_up.get());
2970 return;
2971 }
2972 case eFieldList:
2973 {
2974 GoASTFieldList *n = llvm::cast<GoASTFieldList>(this);
2975 (void)n;
2976 for (auto& e : n->m_list) { v(e.get()); }
2977 return;
2978 }
2979 case eForStmt:
2980 {
2981 GoASTForStmt *n = llvm::cast<GoASTForStmt>(this);
2982 (void)n;
2983 v(n->m_init_up.get());
2984 v(n->m_cond_up.get());
2985 v(n->m_post_up.get());
2986 v(n->m_body_up.get());
2987 return;
2988 }
2989 case eFuncType:
2990 {
2991 GoASTFuncType *n = llvm::cast<GoASTFuncType>(this);
2992 (void)n;
2993 v(n->m_params_up.get());
2994 v(n->m_results_up.get());
2995 return;
2996 }
2997 case eFuncDecl:
2998 {
2999 GoASTFuncDecl *n = llvm::cast<GoASTFuncDecl>(this);
3000 (void)n;
3001 v(n->m_recv_up.get());
3002 v(n->m_name_up.get());
3003 v(n->m_type_up.get());
3004 v(n->m_body_up.get());
3005 return;
3006 }
3007 case eFuncLit:
3008 {
3009 GoASTFuncLit *n = llvm::cast<GoASTFuncLit>(this);
3010 (void)n;
3011 v(n->m_type_up.get());
3012 v(n->m_body_up.get());
3013 return;
3014 }
3015 case eGenDecl:
3016 {
3017 GoASTGenDecl *n = llvm::cast<GoASTGenDecl>(this);
3018 (void)n;
3019 for (auto& e : n->m_specs) { v(e.get()); }
3020 return;
3021 }
3022 case eGoStmt:
3023 {
3024 GoASTGoStmt *n = llvm::cast<GoASTGoStmt>(this);
3025 (void)n;
3026 v(n->m_call_up.get());
3027 return;
3028 }
3029 case eIfStmt:
3030 {
3031 GoASTIfStmt *n = llvm::cast<GoASTIfStmt>(this);
3032 (void)n;
3033 v(n->m_init_up.get());
3034 v(n->m_cond_up.get());
3035 v(n->m_body_up.get());
3036 v(n->m_els_up.get());
3037 return;
3038 }
3039 case eImportSpec:
3040 {
3041 GoASTImportSpec *n = llvm::cast<GoASTImportSpec>(this);
3042 (void)n;
3043 v(n->m_name_up.get());
3044 v(n->m_path_up.get());
3045 return;
3046 }
3047 case eIncDecStmt:
3048 {
3049 GoASTIncDecStmt *n = llvm::cast<GoASTIncDecStmt>(this);
3050 (void)n;
3051 v(n->m_x_up.get());
3052 return;
3053 }
3054 case eIndexExpr:
3055 {
3056 GoASTIndexExpr *n = llvm::cast<GoASTIndexExpr>(this);
3057 (void)n;
3058 v(n->m_x_up.get());
3059 v(n->m_index_up.get());
3060 return;
3061 }
3062 case eInterfaceType:
3063 {
3064 GoASTInterfaceType *n = llvm::cast<GoASTInterfaceType>(this);
3065 (void)n;
3066 v(n->m_methods_up.get());
3067 return;
3068 }
3069 case eKeyValueExpr:
3070 {
3071 GoASTKeyValueExpr *n = llvm::cast<GoASTKeyValueExpr>(this);
3072 (void)n;
3073 v(n->m_key_up.get());
3074 v(n->m_value_up.get());
3075 return;
3076 }
3077 case eLabeledStmt:
3078 {
3079 GoASTLabeledStmt *n = llvm::cast<GoASTLabeledStmt>(this);
3080 (void)n;
3081 v(n->m_label_up.get());
3082 v(n->m_stmt_up.get());
3083 return;
3084 }
3085 case eMapType:
3086 {
3087 GoASTMapType *n = llvm::cast<GoASTMapType>(this);
3088 (void)n;
3089 v(n->m_key_up.get());
3090 v(n->m_value_up.get());
3091 return;
3092 }
3093 case eParenExpr:
3094 {
3095 GoASTParenExpr *n = llvm::cast<GoASTParenExpr>(this);
3096 (void)n;
3097 v(n->m_x_up.get());
3098 return;
3099 }
3100 case eRangeStmt:
3101 {
3102 GoASTRangeStmt *n = llvm::cast<GoASTRangeStmt>(this);
3103 (void)n;
3104 v(n->m_key_up.get());
3105 v(n->m_value_up.get());
3106 v(n->m_x_up.get());
3107 v(n->m_body_up.get());
3108 return;
3109 }
3110 case eReturnStmt:
3111 {
3112 GoASTReturnStmt *n = llvm::cast<GoASTReturnStmt>(this);
3113 (void)n;
3114 for (auto& e : n->m_results) { v(e.get()); }
3115 return;
3116 }
3117 case eSelectStmt:
3118 {
3119 GoASTSelectStmt *n = llvm::cast<GoASTSelectStmt>(this);
3120 (void)n;
3121 v(n->m_body_up.get());
3122 return;
3123 }
3124 case eSelectorExpr:
3125 {
3126 GoASTSelectorExpr *n = llvm::cast<GoASTSelectorExpr>(this);
3127 (void)n;
3128 v(n->m_x_up.get());
3129 v(n->m_sel_up.get());
3130 return;
3131 }
3132 case eSendStmt:
3133 {
3134 GoASTSendStmt *n = llvm::cast<GoASTSendStmt>(this);
3135 (void)n;
3136 v(n->m_chan_up.get());
3137 v(n->m_value_up.get());
3138 return;
3139 }
3140 case eSliceExpr:
3141 {
3142 GoASTSliceExpr *n = llvm::cast<GoASTSliceExpr>(this);
3143 (void)n;
3144 v(n->m_x_up.get());
3145 v(n->m_low_up.get());
3146 v(n->m_high_up.get());
3147 v(n->m_max_up.get());
3148 return;
3149 }
3150 case eStarExpr:
3151 {
3152 GoASTStarExpr *n = llvm::cast<GoASTStarExpr>(this);
3153 (void)n;
3154 v(n->m_x_up.get());
3155 return;
3156 }
3157 case eStructType:
3158 {
3159 GoASTStructType *n = llvm::cast<GoASTStructType>(this);
3160 (void)n;
3161 v(n->m_fields_up.get());
3162 return;
3163 }
3164 case eSwitchStmt:
3165 {
3166 GoASTSwitchStmt *n = llvm::cast<GoASTSwitchStmt>(this);
3167 (void)n;
3168 v(n->m_init_up.get());
3169 v(n->m_tag_up.get());
3170 v(n->m_body_up.get());
3171 return;
3172 }
3173 case eTypeAssertExpr:
3174 {
3175 GoASTTypeAssertExpr *n = llvm::cast<GoASTTypeAssertExpr>(this);
3176 (void)n;
3177 v(n->m_x_up.get());
3178 v(n->m_type_up.get());
3179 return;
3180 }
3181 case eTypeSpec:
3182 {
3183 GoASTTypeSpec *n = llvm::cast<GoASTTypeSpec>(this);
3184 (void)n;
3185 v(n->m_name_up.get());
3186 v(n->m_type_up.get());
3187 return;
3188 }
3189 case eTypeSwitchStmt:
3190 {
3191 GoASTTypeSwitchStmt *n = llvm::cast<GoASTTypeSwitchStmt>(this);
3192 (void)n;
3193 v(n->m_init_up.get());
3194 v(n->m_assign_up.get());
3195 v(n->m_body_up.get());
3196 return;
3197 }
3198 case eUnaryExpr:
3199 {
3200 GoASTUnaryExpr *n = llvm::cast<GoASTUnaryExpr>(this);
3201 (void)n;
3202 v(n->m_x_up.get());
3203 return;
3204 }
3205 case eValueSpec:
3206 {
3207 GoASTValueSpec *n = llvm::cast<GoASTValueSpec>(this);
3208 (void)n;
3209 for (auto& e : n->m_names) { v(e.get()); }
3210 v(n->m_type_up.get());
3211 for (auto& e : n->m_values) { v(e.get()); }
3212 return;
3213 }
3214
3215 case eEmptyStmt:
3216 case eBadDecl:
3217 case eBadExpr:
3218 case eBadStmt:
3219 break;
3220 }
3221}
3222
3223} // namespace lldb_private
3224
3225#endif
3226