1
2
3 package ir
4
5 import "fmt"
6
7 func (n *AddStringExpr) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) }
8 func (n *AddStringExpr) copy() Node {
9 c := *n
10 c.init = copyNodes(c.init)
11 c.List = copyNodes(c.List)
12 return &c
13 }
14 func (n *AddStringExpr) doChildren(do func(Node) bool) bool {
15 if doNodes(n.init, do) {
16 return true
17 }
18 if doNodes(n.List, do) {
19 return true
20 }
21 if n.Prealloc != nil && do(n.Prealloc) {
22 return true
23 }
24 return false
25 }
26 func (n *AddStringExpr) editChildren(edit func(Node) Node) {
27 editNodes(n.init, edit)
28 editNodes(n.List, edit)
29 if n.Prealloc != nil {
30 n.Prealloc = edit(n.Prealloc).(*Name)
31 }
32 }
33
34 func (n *AddrExpr) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) }
35 func (n *AddrExpr) copy() Node {
36 c := *n
37 c.init = copyNodes(c.init)
38 return &c
39 }
40 func (n *AddrExpr) doChildren(do func(Node) bool) bool {
41 if doNodes(n.init, do) {
42 return true
43 }
44 if n.X != nil && do(n.X) {
45 return true
46 }
47 if n.Prealloc != nil && do(n.Prealloc) {
48 return true
49 }
50 return false
51 }
52 func (n *AddrExpr) editChildren(edit func(Node) Node) {
53 editNodes(n.init, edit)
54 if n.X != nil {
55 n.X = edit(n.X).(Node)
56 }
57 if n.Prealloc != nil {
58 n.Prealloc = edit(n.Prealloc).(*Name)
59 }
60 }
61
62 func (n *ArrayType) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) }
63 func (n *ArrayType) copy() Node {
64 c := *n
65 return &c
66 }
67 func (n *ArrayType) doChildren(do func(Node) bool) bool {
68 if n.Len != nil && do(n.Len) {
69 return true
70 }
71 if n.Elem != nil && do(n.Elem) {
72 return true
73 }
74 return false
75 }
76 func (n *ArrayType) editChildren(edit func(Node) Node) {
77 if n.Len != nil {
78 n.Len = edit(n.Len).(Node)
79 }
80 if n.Elem != nil {
81 n.Elem = edit(n.Elem).(Ntype)
82 }
83 }
84
85 func (n *AssignListStmt) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) }
86 func (n *AssignListStmt) copy() Node {
87 c := *n
88 c.init = copyNodes(c.init)
89 c.Lhs = copyNodes(c.Lhs)
90 c.Rhs = copyNodes(c.Rhs)
91 return &c
92 }
93 func (n *AssignListStmt) doChildren(do func(Node) bool) bool {
94 if doNodes(n.init, do) {
95 return true
96 }
97 if doNodes(n.Lhs, do) {
98 return true
99 }
100 if doNodes(n.Rhs, do) {
101 return true
102 }
103 return false
104 }
105 func (n *AssignListStmt) editChildren(edit func(Node) Node) {
106 editNodes(n.init, edit)
107 editNodes(n.Lhs, edit)
108 editNodes(n.Rhs, edit)
109 }
110
111 func (n *AssignOpStmt) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) }
112 func (n *AssignOpStmt) copy() Node {
113 c := *n
114 c.init = copyNodes(c.init)
115 return &c
116 }
117 func (n *AssignOpStmt) doChildren(do func(Node) bool) bool {
118 if doNodes(n.init, do) {
119 return true
120 }
121 if n.X != nil && do(n.X) {
122 return true
123 }
124 if n.Y != nil && do(n.Y) {
125 return true
126 }
127 return false
128 }
129 func (n *AssignOpStmt) editChildren(edit func(Node) Node) {
130 editNodes(n.init, edit)
131 if n.X != nil {
132 n.X = edit(n.X).(Node)
133 }
134 if n.Y != nil {
135 n.Y = edit(n.Y).(Node)
136 }
137 }
138
139 func (n *AssignStmt) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) }
140 func (n *AssignStmt) copy() Node {
141 c := *n
142 c.init = copyNodes(c.init)
143 return &c
144 }
145 func (n *AssignStmt) doChildren(do func(Node) bool) bool {
146 if doNodes(n.init, do) {
147 return true
148 }
149 if n.X != nil && do(n.X) {
150 return true
151 }
152 if n.Y != nil && do(n.Y) {
153 return true
154 }
155 return false
156 }
157 func (n *AssignStmt) editChildren(edit func(Node) Node) {
158 editNodes(n.init, edit)
159 if n.X != nil {
160 n.X = edit(n.X).(Node)
161 }
162 if n.Y != nil {
163 n.Y = edit(n.Y).(Node)
164 }
165 }
166
167 func (n *BasicLit) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) }
168 func (n *BasicLit) copy() Node {
169 c := *n
170 c.init = copyNodes(c.init)
171 return &c
172 }
173 func (n *BasicLit) doChildren(do func(Node) bool) bool {
174 if doNodes(n.init, do) {
175 return true
176 }
177 return false
178 }
179 func (n *BasicLit) editChildren(edit func(Node) Node) {
180 editNodes(n.init, edit)
181 }
182
183 func (n *BinaryExpr) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) }
184 func (n *BinaryExpr) copy() Node {
185 c := *n
186 c.init = copyNodes(c.init)
187 return &c
188 }
189 func (n *BinaryExpr) doChildren(do func(Node) bool) bool {
190 if doNodes(n.init, do) {
191 return true
192 }
193 if n.X != nil && do(n.X) {
194 return true
195 }
196 if n.Y != nil && do(n.Y) {
197 return true
198 }
199 return false
200 }
201 func (n *BinaryExpr) editChildren(edit func(Node) Node) {
202 editNodes(n.init, edit)
203 if n.X != nil {
204 n.X = edit(n.X).(Node)
205 }
206 if n.Y != nil {
207 n.Y = edit(n.Y).(Node)
208 }
209 }
210
211 func (n *BlockStmt) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) }
212 func (n *BlockStmt) copy() Node {
213 c := *n
214 c.init = copyNodes(c.init)
215 c.List = copyNodes(c.List)
216 return &c
217 }
218 func (n *BlockStmt) doChildren(do func(Node) bool) bool {
219 if doNodes(n.init, do) {
220 return true
221 }
222 if doNodes(n.List, do) {
223 return true
224 }
225 return false
226 }
227 func (n *BlockStmt) editChildren(edit func(Node) Node) {
228 editNodes(n.init, edit)
229 editNodes(n.List, edit)
230 }
231
232 func (n *BranchStmt) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) }
233 func (n *BranchStmt) copy() Node {
234 c := *n
235 c.init = copyNodes(c.init)
236 return &c
237 }
238 func (n *BranchStmt) doChildren(do func(Node) bool) bool {
239 if doNodes(n.init, do) {
240 return true
241 }
242 return false
243 }
244 func (n *BranchStmt) editChildren(edit func(Node) Node) {
245 editNodes(n.init, edit)
246 }
247
248 func (n *CallExpr) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) }
249 func (n *CallExpr) copy() Node {
250 c := *n
251 c.init = copyNodes(c.init)
252 c.Args = copyNodes(c.Args)
253 c.KeepAlive = copyNames(c.KeepAlive)
254 return &c
255 }
256 func (n *CallExpr) doChildren(do func(Node) bool) bool {
257 if doNodes(n.init, do) {
258 return true
259 }
260 if n.X != nil && do(n.X) {
261 return true
262 }
263 if doNodes(n.Args, do) {
264 return true
265 }
266 if doNames(n.KeepAlive, do) {
267 return true
268 }
269 return false
270 }
271 func (n *CallExpr) editChildren(edit func(Node) Node) {
272 editNodes(n.init, edit)
273 if n.X != nil {
274 n.X = edit(n.X).(Node)
275 }
276 editNodes(n.Args, edit)
277 editNames(n.KeepAlive, edit)
278 }
279
280 func (n *CaseClause) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) }
281 func (n *CaseClause) copy() Node {
282 c := *n
283 c.init = copyNodes(c.init)
284 c.List = copyNodes(c.List)
285 c.Body = copyNodes(c.Body)
286 return &c
287 }
288 func (n *CaseClause) doChildren(do func(Node) bool) bool {
289 if doNodes(n.init, do) {
290 return true
291 }
292 if n.Var != nil && do(n.Var) {
293 return true
294 }
295 if doNodes(n.List, do) {
296 return true
297 }
298 if doNodes(n.Body, do) {
299 return true
300 }
301 return false
302 }
303 func (n *CaseClause) editChildren(edit func(Node) Node) {
304 editNodes(n.init, edit)
305 if n.Var != nil {
306 n.Var = edit(n.Var).(*Name)
307 }
308 editNodes(n.List, edit)
309 editNodes(n.Body, edit)
310 }
311
312 func (n *ChanType) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) }
313 func (n *ChanType) copy() Node {
314 c := *n
315 return &c
316 }
317 func (n *ChanType) doChildren(do func(Node) bool) bool {
318 if n.Elem != nil && do(n.Elem) {
319 return true
320 }
321 return false
322 }
323 func (n *ChanType) editChildren(edit func(Node) Node) {
324 if n.Elem != nil {
325 n.Elem = edit(n.Elem).(Ntype)
326 }
327 }
328
329 func (n *ClosureExpr) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) }
330 func (n *ClosureExpr) copy() Node {
331 c := *n
332 c.init = copyNodes(c.init)
333 return &c
334 }
335 func (n *ClosureExpr) doChildren(do func(Node) bool) bool {
336 if doNodes(n.init, do) {
337 return true
338 }
339 if n.Prealloc != nil && do(n.Prealloc) {
340 return true
341 }
342 return false
343 }
344 func (n *ClosureExpr) editChildren(edit func(Node) Node) {
345 editNodes(n.init, edit)
346 if n.Prealloc != nil {
347 n.Prealloc = edit(n.Prealloc).(*Name)
348 }
349 }
350
351 func (n *CommClause) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) }
352 func (n *CommClause) copy() Node {
353 c := *n
354 c.init = copyNodes(c.init)
355 c.Body = copyNodes(c.Body)
356 return &c
357 }
358 func (n *CommClause) doChildren(do func(Node) bool) bool {
359 if doNodes(n.init, do) {
360 return true
361 }
362 if n.Comm != nil && do(n.Comm) {
363 return true
364 }
365 if doNodes(n.Body, do) {
366 return true
367 }
368 return false
369 }
370 func (n *CommClause) editChildren(edit func(Node) Node) {
371 editNodes(n.init, edit)
372 if n.Comm != nil {
373 n.Comm = edit(n.Comm).(Node)
374 }
375 editNodes(n.Body, edit)
376 }
377
378 func (n *CompLitExpr) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) }
379 func (n *CompLitExpr) copy() Node {
380 c := *n
381 c.init = copyNodes(c.init)
382 c.List = copyNodes(c.List)
383 return &c
384 }
385 func (n *CompLitExpr) doChildren(do func(Node) bool) bool {
386 if doNodes(n.init, do) {
387 return true
388 }
389 if n.Ntype != nil && do(n.Ntype) {
390 return true
391 }
392 if doNodes(n.List, do) {
393 return true
394 }
395 if n.Prealloc != nil && do(n.Prealloc) {
396 return true
397 }
398 return false
399 }
400 func (n *CompLitExpr) editChildren(edit func(Node) Node) {
401 editNodes(n.init, edit)
402 if n.Ntype != nil {
403 n.Ntype = edit(n.Ntype).(Ntype)
404 }
405 editNodes(n.List, edit)
406 if n.Prealloc != nil {
407 n.Prealloc = edit(n.Prealloc).(*Name)
408 }
409 }
410
411 func (n *ConstExpr) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) }
412 func (n *ConstExpr) copy() Node {
413 c := *n
414 c.init = copyNodes(c.init)
415 return &c
416 }
417 func (n *ConstExpr) doChildren(do func(Node) bool) bool {
418 if doNodes(n.init, do) {
419 return true
420 }
421 return false
422 }
423 func (n *ConstExpr) editChildren(edit func(Node) Node) {
424 editNodes(n.init, edit)
425 }
426
427 func (n *ConvExpr) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) }
428 func (n *ConvExpr) copy() Node {
429 c := *n
430 c.init = copyNodes(c.init)
431 return &c
432 }
433 func (n *ConvExpr) doChildren(do func(Node) bool) bool {
434 if doNodes(n.init, do) {
435 return true
436 }
437 if n.X != nil && do(n.X) {
438 return true
439 }
440 return false
441 }
442 func (n *ConvExpr) editChildren(edit func(Node) Node) {
443 editNodes(n.init, edit)
444 if n.X != nil {
445 n.X = edit(n.X).(Node)
446 }
447 }
448
449 func (n *Decl) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) }
450 func (n *Decl) copy() Node {
451 c := *n
452 return &c
453 }
454 func (n *Decl) doChildren(do func(Node) bool) bool {
455 if n.X != nil && do(n.X) {
456 return true
457 }
458 return false
459 }
460 func (n *Decl) editChildren(edit func(Node) Node) {
461 if n.X != nil {
462 n.X = edit(n.X).(*Name)
463 }
464 }
465
466 func (n *DynamicType) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) }
467 func (n *DynamicType) copy() Node {
468 c := *n
469 c.init = copyNodes(c.init)
470 return &c
471 }
472 func (n *DynamicType) doChildren(do func(Node) bool) bool {
473 if doNodes(n.init, do) {
474 return true
475 }
476 if n.X != nil && do(n.X) {
477 return true
478 }
479 if n.ITab != nil && do(n.ITab) {
480 return true
481 }
482 return false
483 }
484 func (n *DynamicType) editChildren(edit func(Node) Node) {
485 editNodes(n.init, edit)
486 if n.X != nil {
487 n.X = edit(n.X).(Node)
488 }
489 if n.ITab != nil {
490 n.ITab = edit(n.ITab).(Node)
491 }
492 }
493
494 func (n *DynamicTypeAssertExpr) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) }
495 func (n *DynamicTypeAssertExpr) copy() Node {
496 c := *n
497 c.init = copyNodes(c.init)
498 return &c
499 }
500 func (n *DynamicTypeAssertExpr) doChildren(do func(Node) bool) bool {
501 if doNodes(n.init, do) {
502 return true
503 }
504 if n.X != nil && do(n.X) {
505 return true
506 }
507 if n.T != nil && do(n.T) {
508 return true
509 }
510 return false
511 }
512 func (n *DynamicTypeAssertExpr) editChildren(edit func(Node) Node) {
513 editNodes(n.init, edit)
514 if n.X != nil {
515 n.X = edit(n.X).(Node)
516 }
517 if n.T != nil {
518 n.T = edit(n.T).(Node)
519 }
520 }
521
522 func (n *ForStmt) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) }
523 func (n *ForStmt) copy() Node {
524 c := *n
525 c.init = copyNodes(c.init)
526 c.Late = copyNodes(c.Late)
527 c.Body = copyNodes(c.Body)
528 return &c
529 }
530 func (n *ForStmt) doChildren(do func(Node) bool) bool {
531 if doNodes(n.init, do) {
532 return true
533 }
534 if n.Cond != nil && do(n.Cond) {
535 return true
536 }
537 if doNodes(n.Late, do) {
538 return true
539 }
540 if n.Post != nil && do(n.Post) {
541 return true
542 }
543 if doNodes(n.Body, do) {
544 return true
545 }
546 return false
547 }
548 func (n *ForStmt) editChildren(edit func(Node) Node) {
549 editNodes(n.init, edit)
550 if n.Cond != nil {
551 n.Cond = edit(n.Cond).(Node)
552 }
553 editNodes(n.Late, edit)
554 if n.Post != nil {
555 n.Post = edit(n.Post).(Node)
556 }
557 editNodes(n.Body, edit)
558 }
559
560 func (n *Func) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) }
561
562 func (n *FuncType) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) }
563 func (n *FuncType) copy() Node {
564 c := *n
565 c.Recv = copyField(c.Recv)
566 c.Params = copyFields(c.Params)
567 c.Results = copyFields(c.Results)
568 return &c
569 }
570 func (n *FuncType) doChildren(do func(Node) bool) bool {
571 if doField(n.Recv, do) {
572 return true
573 }
574 if doFields(n.Params, do) {
575 return true
576 }
577 if doFields(n.Results, do) {
578 return true
579 }
580 return false
581 }
582 func (n *FuncType) editChildren(edit func(Node) Node) {
583 editField(n.Recv, edit)
584 editFields(n.Params, edit)
585 editFields(n.Results, edit)
586 }
587
588 func (n *GoDeferStmt) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) }
589 func (n *GoDeferStmt) copy() Node {
590 c := *n
591 c.init = copyNodes(c.init)
592 return &c
593 }
594 func (n *GoDeferStmt) doChildren(do func(Node) bool) bool {
595 if doNodes(n.init, do) {
596 return true
597 }
598 if n.Call != nil && do(n.Call) {
599 return true
600 }
601 return false
602 }
603 func (n *GoDeferStmt) editChildren(edit func(Node) Node) {
604 editNodes(n.init, edit)
605 if n.Call != nil {
606 n.Call = edit(n.Call).(Node)
607 }
608 }
609
610 func (n *Ident) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) }
611 func (n *Ident) copy() Node {
612 c := *n
613 c.init = copyNodes(c.init)
614 return &c
615 }
616 func (n *Ident) doChildren(do func(Node) bool) bool {
617 if doNodes(n.init, do) {
618 return true
619 }
620 return false
621 }
622 func (n *Ident) editChildren(edit func(Node) Node) {
623 editNodes(n.init, edit)
624 }
625
626 func (n *IfStmt) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) }
627 func (n *IfStmt) copy() Node {
628 c := *n
629 c.init = copyNodes(c.init)
630 c.Body = copyNodes(c.Body)
631 c.Else = copyNodes(c.Else)
632 return &c
633 }
634 func (n *IfStmt) doChildren(do func(Node) bool) bool {
635 if doNodes(n.init, do) {
636 return true
637 }
638 if n.Cond != nil && do(n.Cond) {
639 return true
640 }
641 if doNodes(n.Body, do) {
642 return true
643 }
644 if doNodes(n.Else, do) {
645 return true
646 }
647 return false
648 }
649 func (n *IfStmt) editChildren(edit func(Node) Node) {
650 editNodes(n.init, edit)
651 if n.Cond != nil {
652 n.Cond = edit(n.Cond).(Node)
653 }
654 editNodes(n.Body, edit)
655 editNodes(n.Else, edit)
656 }
657
658 func (n *IndexExpr) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) }
659 func (n *IndexExpr) copy() Node {
660 c := *n
661 c.init = copyNodes(c.init)
662 return &c
663 }
664 func (n *IndexExpr) doChildren(do func(Node) bool) bool {
665 if doNodes(n.init, do) {
666 return true
667 }
668 if n.X != nil && do(n.X) {
669 return true
670 }
671 if n.Index != nil && do(n.Index) {
672 return true
673 }
674 return false
675 }
676 func (n *IndexExpr) editChildren(edit func(Node) Node) {
677 editNodes(n.init, edit)
678 if n.X != nil {
679 n.X = edit(n.X).(Node)
680 }
681 if n.Index != nil {
682 n.Index = edit(n.Index).(Node)
683 }
684 }
685
686 func (n *InlineMarkStmt) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) }
687 func (n *InlineMarkStmt) copy() Node {
688 c := *n
689 c.init = copyNodes(c.init)
690 return &c
691 }
692 func (n *InlineMarkStmt) doChildren(do func(Node) bool) bool {
693 if doNodes(n.init, do) {
694 return true
695 }
696 return false
697 }
698 func (n *InlineMarkStmt) editChildren(edit func(Node) Node) {
699 editNodes(n.init, edit)
700 }
701
702 func (n *InlinedCallExpr) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) }
703 func (n *InlinedCallExpr) copy() Node {
704 c := *n
705 c.init = copyNodes(c.init)
706 c.Body = copyNodes(c.Body)
707 c.ReturnVars = copyNodes(c.ReturnVars)
708 return &c
709 }
710 func (n *InlinedCallExpr) doChildren(do func(Node) bool) bool {
711 if doNodes(n.init, do) {
712 return true
713 }
714 if doNodes(n.Body, do) {
715 return true
716 }
717 if doNodes(n.ReturnVars, do) {
718 return true
719 }
720 return false
721 }
722 func (n *InlinedCallExpr) editChildren(edit func(Node) Node) {
723 editNodes(n.init, edit)
724 editNodes(n.Body, edit)
725 editNodes(n.ReturnVars, edit)
726 }
727
728 func (n *InstExpr) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) }
729 func (n *InstExpr) copy() Node {
730 c := *n
731 c.init = copyNodes(c.init)
732 c.Targs = copyNodes(c.Targs)
733 return &c
734 }
735 func (n *InstExpr) doChildren(do func(Node) bool) bool {
736 if doNodes(n.init, do) {
737 return true
738 }
739 if n.X != nil && do(n.X) {
740 return true
741 }
742 if doNodes(n.Targs, do) {
743 return true
744 }
745 return false
746 }
747 func (n *InstExpr) editChildren(edit func(Node) Node) {
748 editNodes(n.init, edit)
749 if n.X != nil {
750 n.X = edit(n.X).(Node)
751 }
752 editNodes(n.Targs, edit)
753 }
754
755 func (n *InterfaceType) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) }
756 func (n *InterfaceType) copy() Node {
757 c := *n
758 c.Methods = copyFields(c.Methods)
759 return &c
760 }
761 func (n *InterfaceType) doChildren(do func(Node) bool) bool {
762 if doFields(n.Methods, do) {
763 return true
764 }
765 return false
766 }
767 func (n *InterfaceType) editChildren(edit func(Node) Node) {
768 editFields(n.Methods, edit)
769 }
770
771 func (n *KeyExpr) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) }
772 func (n *KeyExpr) copy() Node {
773 c := *n
774 c.init = copyNodes(c.init)
775 return &c
776 }
777 func (n *KeyExpr) doChildren(do func(Node) bool) bool {
778 if doNodes(n.init, do) {
779 return true
780 }
781 if n.Key != nil && do(n.Key) {
782 return true
783 }
784 if n.Value != nil && do(n.Value) {
785 return true
786 }
787 return false
788 }
789 func (n *KeyExpr) editChildren(edit func(Node) Node) {
790 editNodes(n.init, edit)
791 if n.Key != nil {
792 n.Key = edit(n.Key).(Node)
793 }
794 if n.Value != nil {
795 n.Value = edit(n.Value).(Node)
796 }
797 }
798
799 func (n *LabelStmt) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) }
800 func (n *LabelStmt) copy() Node {
801 c := *n
802 c.init = copyNodes(c.init)
803 return &c
804 }
805 func (n *LabelStmt) doChildren(do func(Node) bool) bool {
806 if doNodes(n.init, do) {
807 return true
808 }
809 return false
810 }
811 func (n *LabelStmt) editChildren(edit func(Node) Node) {
812 editNodes(n.init, edit)
813 }
814
815 func (n *LinksymOffsetExpr) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) }
816 func (n *LinksymOffsetExpr) copy() Node {
817 c := *n
818 c.init = copyNodes(c.init)
819 return &c
820 }
821 func (n *LinksymOffsetExpr) doChildren(do func(Node) bool) bool {
822 if doNodes(n.init, do) {
823 return true
824 }
825 return false
826 }
827 func (n *LinksymOffsetExpr) editChildren(edit func(Node) Node) {
828 editNodes(n.init, edit)
829 }
830
831 func (n *LogicalExpr) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) }
832 func (n *LogicalExpr) copy() Node {
833 c := *n
834 c.init = copyNodes(c.init)
835 return &c
836 }
837 func (n *LogicalExpr) doChildren(do func(Node) bool) bool {
838 if doNodes(n.init, do) {
839 return true
840 }
841 if n.X != nil && do(n.X) {
842 return true
843 }
844 if n.Y != nil && do(n.Y) {
845 return true
846 }
847 return false
848 }
849 func (n *LogicalExpr) editChildren(edit func(Node) Node) {
850 editNodes(n.init, edit)
851 if n.X != nil {
852 n.X = edit(n.X).(Node)
853 }
854 if n.Y != nil {
855 n.Y = edit(n.Y).(Node)
856 }
857 }
858
859 func (n *MakeExpr) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) }
860 func (n *MakeExpr) copy() Node {
861 c := *n
862 c.init = copyNodes(c.init)
863 return &c
864 }
865 func (n *MakeExpr) doChildren(do func(Node) bool) bool {
866 if doNodes(n.init, do) {
867 return true
868 }
869 if n.Len != nil && do(n.Len) {
870 return true
871 }
872 if n.Cap != nil && do(n.Cap) {
873 return true
874 }
875 return false
876 }
877 func (n *MakeExpr) editChildren(edit func(Node) Node) {
878 editNodes(n.init, edit)
879 if n.Len != nil {
880 n.Len = edit(n.Len).(Node)
881 }
882 if n.Cap != nil {
883 n.Cap = edit(n.Cap).(Node)
884 }
885 }
886
887 func (n *MapType) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) }
888 func (n *MapType) copy() Node {
889 c := *n
890 return &c
891 }
892 func (n *MapType) doChildren(do func(Node) bool) bool {
893 if n.Key != nil && do(n.Key) {
894 return true
895 }
896 if n.Elem != nil && do(n.Elem) {
897 return true
898 }
899 return false
900 }
901 func (n *MapType) editChildren(edit func(Node) Node) {
902 if n.Key != nil {
903 n.Key = edit(n.Key).(Ntype)
904 }
905 if n.Elem != nil {
906 n.Elem = edit(n.Elem).(Ntype)
907 }
908 }
909
910 func (n *Name) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) }
911
912 func (n *NilExpr) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) }
913 func (n *NilExpr) copy() Node {
914 c := *n
915 c.init = copyNodes(c.init)
916 return &c
917 }
918 func (n *NilExpr) doChildren(do func(Node) bool) bool {
919 if doNodes(n.init, do) {
920 return true
921 }
922 return false
923 }
924 func (n *NilExpr) editChildren(edit func(Node) Node) {
925 editNodes(n.init, edit)
926 }
927
928 func (n *ParenExpr) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) }
929 func (n *ParenExpr) copy() Node {
930 c := *n
931 c.init = copyNodes(c.init)
932 return &c
933 }
934 func (n *ParenExpr) doChildren(do func(Node) bool) bool {
935 if doNodes(n.init, do) {
936 return true
937 }
938 if n.X != nil && do(n.X) {
939 return true
940 }
941 return false
942 }
943 func (n *ParenExpr) editChildren(edit func(Node) Node) {
944 editNodes(n.init, edit)
945 if n.X != nil {
946 n.X = edit(n.X).(Node)
947 }
948 }
949
950 func (n *PkgName) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) }
951 func (n *PkgName) copy() Node {
952 c := *n
953 return &c
954 }
955 func (n *PkgName) doChildren(do func(Node) bool) bool {
956 return false
957 }
958 func (n *PkgName) editChildren(edit func(Node) Node) {
959 }
960
961 func (n *RangeStmt) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) }
962 func (n *RangeStmt) copy() Node {
963 c := *n
964 c.init = copyNodes(c.init)
965 c.Body = copyNodes(c.Body)
966 return &c
967 }
968 func (n *RangeStmt) doChildren(do func(Node) bool) bool {
969 if doNodes(n.init, do) {
970 return true
971 }
972 if n.X != nil && do(n.X) {
973 return true
974 }
975 if n.Key != nil && do(n.Key) {
976 return true
977 }
978 if n.Value != nil && do(n.Value) {
979 return true
980 }
981 if doNodes(n.Body, do) {
982 return true
983 }
984 if n.Prealloc != nil && do(n.Prealloc) {
985 return true
986 }
987 return false
988 }
989 func (n *RangeStmt) editChildren(edit func(Node) Node) {
990 editNodes(n.init, edit)
991 if n.X != nil {
992 n.X = edit(n.X).(Node)
993 }
994 if n.Key != nil {
995 n.Key = edit(n.Key).(Node)
996 }
997 if n.Value != nil {
998 n.Value = edit(n.Value).(Node)
999 }
1000 editNodes(n.Body, edit)
1001 if n.Prealloc != nil {
1002 n.Prealloc = edit(n.Prealloc).(*Name)
1003 }
1004 }
1005
1006 func (n *RawOrigExpr) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) }
1007 func (n *RawOrigExpr) copy() Node {
1008 c := *n
1009 c.init = copyNodes(c.init)
1010 return &c
1011 }
1012 func (n *RawOrigExpr) doChildren(do func(Node) bool) bool {
1013 if doNodes(n.init, do) {
1014 return true
1015 }
1016 return false
1017 }
1018 func (n *RawOrigExpr) editChildren(edit func(Node) Node) {
1019 editNodes(n.init, edit)
1020 }
1021
1022 func (n *ResultExpr) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) }
1023 func (n *ResultExpr) copy() Node {
1024 c := *n
1025 c.init = copyNodes(c.init)
1026 return &c
1027 }
1028 func (n *ResultExpr) doChildren(do func(Node) bool) bool {
1029 if doNodes(n.init, do) {
1030 return true
1031 }
1032 return false
1033 }
1034 func (n *ResultExpr) editChildren(edit func(Node) Node) {
1035 editNodes(n.init, edit)
1036 }
1037
1038 func (n *ReturnStmt) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) }
1039 func (n *ReturnStmt) copy() Node {
1040 c := *n
1041 c.init = copyNodes(c.init)
1042 c.Results = copyNodes(c.Results)
1043 return &c
1044 }
1045 func (n *ReturnStmt) doChildren(do func(Node) bool) bool {
1046 if doNodes(n.init, do) {
1047 return true
1048 }
1049 if doNodes(n.Results, do) {
1050 return true
1051 }
1052 return false
1053 }
1054 func (n *ReturnStmt) editChildren(edit func(Node) Node) {
1055 editNodes(n.init, edit)
1056 editNodes(n.Results, edit)
1057 }
1058
1059 func (n *SelectStmt) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) }
1060 func (n *SelectStmt) copy() Node {
1061 c := *n
1062 c.init = copyNodes(c.init)
1063 c.Cases = copyCommClauses(c.Cases)
1064 c.Compiled = copyNodes(c.Compiled)
1065 return &c
1066 }
1067 func (n *SelectStmt) doChildren(do func(Node) bool) bool {
1068 if doNodes(n.init, do) {
1069 return true
1070 }
1071 if doCommClauses(n.Cases, do) {
1072 return true
1073 }
1074 if doNodes(n.Compiled, do) {
1075 return true
1076 }
1077 return false
1078 }
1079 func (n *SelectStmt) editChildren(edit func(Node) Node) {
1080 editNodes(n.init, edit)
1081 editCommClauses(n.Cases, edit)
1082 editNodes(n.Compiled, edit)
1083 }
1084
1085 func (n *SelectorExpr) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) }
1086 func (n *SelectorExpr) copy() Node {
1087 c := *n
1088 c.init = copyNodes(c.init)
1089 return &c
1090 }
1091 func (n *SelectorExpr) doChildren(do func(Node) bool) bool {
1092 if doNodes(n.init, do) {
1093 return true
1094 }
1095 if n.X != nil && do(n.X) {
1096 return true
1097 }
1098 if n.Prealloc != nil && do(n.Prealloc) {
1099 return true
1100 }
1101 return false
1102 }
1103 func (n *SelectorExpr) editChildren(edit func(Node) Node) {
1104 editNodes(n.init, edit)
1105 if n.X != nil {
1106 n.X = edit(n.X).(Node)
1107 }
1108 if n.Prealloc != nil {
1109 n.Prealloc = edit(n.Prealloc).(*Name)
1110 }
1111 }
1112
1113 func (n *SendStmt) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) }
1114 func (n *SendStmt) copy() Node {
1115 c := *n
1116 c.init = copyNodes(c.init)
1117 return &c
1118 }
1119 func (n *SendStmt) doChildren(do func(Node) bool) bool {
1120 if doNodes(n.init, do) {
1121 return true
1122 }
1123 if n.Chan != nil && do(n.Chan) {
1124 return true
1125 }
1126 if n.Value != nil && do(n.Value) {
1127 return true
1128 }
1129 return false
1130 }
1131 func (n *SendStmt) editChildren(edit func(Node) Node) {
1132 editNodes(n.init, edit)
1133 if n.Chan != nil {
1134 n.Chan = edit(n.Chan).(Node)
1135 }
1136 if n.Value != nil {
1137 n.Value = edit(n.Value).(Node)
1138 }
1139 }
1140
1141 func (n *SliceExpr) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) }
1142 func (n *SliceExpr) copy() Node {
1143 c := *n
1144 c.init = copyNodes(c.init)
1145 return &c
1146 }
1147 func (n *SliceExpr) doChildren(do func(Node) bool) bool {
1148 if doNodes(n.init, do) {
1149 return true
1150 }
1151 if n.X != nil && do(n.X) {
1152 return true
1153 }
1154 if n.Low != nil && do(n.Low) {
1155 return true
1156 }
1157 if n.High != nil && do(n.High) {
1158 return true
1159 }
1160 if n.Max != nil && do(n.Max) {
1161 return true
1162 }
1163 return false
1164 }
1165 func (n *SliceExpr) editChildren(edit func(Node) Node) {
1166 editNodes(n.init, edit)
1167 if n.X != nil {
1168 n.X = edit(n.X).(Node)
1169 }
1170 if n.Low != nil {
1171 n.Low = edit(n.Low).(Node)
1172 }
1173 if n.High != nil {
1174 n.High = edit(n.High).(Node)
1175 }
1176 if n.Max != nil {
1177 n.Max = edit(n.Max).(Node)
1178 }
1179 }
1180
1181 func (n *SliceHeaderExpr) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) }
1182 func (n *SliceHeaderExpr) copy() Node {
1183 c := *n
1184 c.init = copyNodes(c.init)
1185 return &c
1186 }
1187 func (n *SliceHeaderExpr) doChildren(do func(Node) bool) bool {
1188 if doNodes(n.init, do) {
1189 return true
1190 }
1191 if n.Ptr != nil && do(n.Ptr) {
1192 return true
1193 }
1194 if n.Len != nil && do(n.Len) {
1195 return true
1196 }
1197 if n.Cap != nil && do(n.Cap) {
1198 return true
1199 }
1200 return false
1201 }
1202 func (n *SliceHeaderExpr) editChildren(edit func(Node) Node) {
1203 editNodes(n.init, edit)
1204 if n.Ptr != nil {
1205 n.Ptr = edit(n.Ptr).(Node)
1206 }
1207 if n.Len != nil {
1208 n.Len = edit(n.Len).(Node)
1209 }
1210 if n.Cap != nil {
1211 n.Cap = edit(n.Cap).(Node)
1212 }
1213 }
1214
1215 func (n *SliceType) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) }
1216 func (n *SliceType) copy() Node {
1217 c := *n
1218 return &c
1219 }
1220 func (n *SliceType) doChildren(do func(Node) bool) bool {
1221 if n.Elem != nil && do(n.Elem) {
1222 return true
1223 }
1224 return false
1225 }
1226 func (n *SliceType) editChildren(edit func(Node) Node) {
1227 if n.Elem != nil {
1228 n.Elem = edit(n.Elem).(Ntype)
1229 }
1230 }
1231
1232 func (n *StarExpr) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) }
1233 func (n *StarExpr) copy() Node {
1234 c := *n
1235 c.init = copyNodes(c.init)
1236 return &c
1237 }
1238 func (n *StarExpr) doChildren(do func(Node) bool) bool {
1239 if doNodes(n.init, do) {
1240 return true
1241 }
1242 if n.X != nil && do(n.X) {
1243 return true
1244 }
1245 return false
1246 }
1247 func (n *StarExpr) editChildren(edit func(Node) Node) {
1248 editNodes(n.init, edit)
1249 if n.X != nil {
1250 n.X = edit(n.X).(Node)
1251 }
1252 }
1253
1254 func (n *StructKeyExpr) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) }
1255 func (n *StructKeyExpr) copy() Node {
1256 c := *n
1257 c.init = copyNodes(c.init)
1258 return &c
1259 }
1260 func (n *StructKeyExpr) doChildren(do func(Node) bool) bool {
1261 if doNodes(n.init, do) {
1262 return true
1263 }
1264 if n.Value != nil && do(n.Value) {
1265 return true
1266 }
1267 return false
1268 }
1269 func (n *StructKeyExpr) editChildren(edit func(Node) Node) {
1270 editNodes(n.init, edit)
1271 if n.Value != nil {
1272 n.Value = edit(n.Value).(Node)
1273 }
1274 }
1275
1276 func (n *StructType) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) }
1277 func (n *StructType) copy() Node {
1278 c := *n
1279 c.Fields = copyFields(c.Fields)
1280 return &c
1281 }
1282 func (n *StructType) doChildren(do func(Node) bool) bool {
1283 if doFields(n.Fields, do) {
1284 return true
1285 }
1286 return false
1287 }
1288 func (n *StructType) editChildren(edit func(Node) Node) {
1289 editFields(n.Fields, edit)
1290 }
1291
1292 func (n *SwitchStmt) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) }
1293 func (n *SwitchStmt) copy() Node {
1294 c := *n
1295 c.init = copyNodes(c.init)
1296 c.Cases = copyCaseClauses(c.Cases)
1297 c.Compiled = copyNodes(c.Compiled)
1298 return &c
1299 }
1300 func (n *SwitchStmt) doChildren(do func(Node) bool) bool {
1301 if doNodes(n.init, do) {
1302 return true
1303 }
1304 if n.Tag != nil && do(n.Tag) {
1305 return true
1306 }
1307 if doCaseClauses(n.Cases, do) {
1308 return true
1309 }
1310 if doNodes(n.Compiled, do) {
1311 return true
1312 }
1313 return false
1314 }
1315 func (n *SwitchStmt) editChildren(edit func(Node) Node) {
1316 editNodes(n.init, edit)
1317 if n.Tag != nil {
1318 n.Tag = edit(n.Tag).(Node)
1319 }
1320 editCaseClauses(n.Cases, edit)
1321 editNodes(n.Compiled, edit)
1322 }
1323
1324 func (n *TailCallStmt) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) }
1325 func (n *TailCallStmt) copy() Node {
1326 c := *n
1327 c.init = copyNodes(c.init)
1328 return &c
1329 }
1330 func (n *TailCallStmt) doChildren(do func(Node) bool) bool {
1331 if doNodes(n.init, do) {
1332 return true
1333 }
1334 if n.Call != nil && do(n.Call) {
1335 return true
1336 }
1337 return false
1338 }
1339 func (n *TailCallStmt) editChildren(edit func(Node) Node) {
1340 editNodes(n.init, edit)
1341 if n.Call != nil {
1342 n.Call = edit(n.Call).(*CallExpr)
1343 }
1344 }
1345
1346 func (n *TypeAssertExpr) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) }
1347 func (n *TypeAssertExpr) copy() Node {
1348 c := *n
1349 c.init = copyNodes(c.init)
1350 return &c
1351 }
1352 func (n *TypeAssertExpr) doChildren(do func(Node) bool) bool {
1353 if doNodes(n.init, do) {
1354 return true
1355 }
1356 if n.X != nil && do(n.X) {
1357 return true
1358 }
1359 if n.Ntype != nil && do(n.Ntype) {
1360 return true
1361 }
1362 return false
1363 }
1364 func (n *TypeAssertExpr) editChildren(edit func(Node) Node) {
1365 editNodes(n.init, edit)
1366 if n.X != nil {
1367 n.X = edit(n.X).(Node)
1368 }
1369 if n.Ntype != nil {
1370 n.Ntype = edit(n.Ntype).(Ntype)
1371 }
1372 }
1373
1374 func (n *TypeSwitchGuard) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) }
1375 func (n *TypeSwitchGuard) copy() Node {
1376 c := *n
1377 return &c
1378 }
1379 func (n *TypeSwitchGuard) doChildren(do func(Node) bool) bool {
1380 if n.Tag != nil && do(n.Tag) {
1381 return true
1382 }
1383 if n.X != nil && do(n.X) {
1384 return true
1385 }
1386 return false
1387 }
1388 func (n *TypeSwitchGuard) editChildren(edit func(Node) Node) {
1389 if n.Tag != nil {
1390 n.Tag = edit(n.Tag).(*Ident)
1391 }
1392 if n.X != nil {
1393 n.X = edit(n.X).(Node)
1394 }
1395 }
1396
1397 func (n *UnaryExpr) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) }
1398 func (n *UnaryExpr) copy() Node {
1399 c := *n
1400 c.init = copyNodes(c.init)
1401 return &c
1402 }
1403 func (n *UnaryExpr) doChildren(do func(Node) bool) bool {
1404 if doNodes(n.init, do) {
1405 return true
1406 }
1407 if n.X != nil && do(n.X) {
1408 return true
1409 }
1410 return false
1411 }
1412 func (n *UnaryExpr) editChildren(edit func(Node) Node) {
1413 editNodes(n.init, edit)
1414 if n.X != nil {
1415 n.X = edit(n.X).(Node)
1416 }
1417 }
1418
1419 func (n *typeNode) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) }
1420 func (n *typeNode) copy() Node {
1421 c := *n
1422 return &c
1423 }
1424 func (n *typeNode) doChildren(do func(Node) bool) bool {
1425 return false
1426 }
1427 func (n *typeNode) editChildren(edit func(Node) Node) {
1428 }
1429
1430 func copyCaseClauses(list []*CaseClause) []*CaseClause {
1431 if list == nil {
1432 return nil
1433 }
1434 c := make([]*CaseClause, len(list))
1435 copy(c, list)
1436 return c
1437 }
1438 func doCaseClauses(list []*CaseClause, do func(Node) bool) bool {
1439 for _, x := range list {
1440 if x != nil && do(x) {
1441 return true
1442 }
1443 }
1444 return false
1445 }
1446 func editCaseClauses(list []*CaseClause, edit func(Node) Node) {
1447 for i, x := range list {
1448 if x != nil {
1449 list[i] = edit(x).(*CaseClause)
1450 }
1451 }
1452 }
1453
1454 func copyCommClauses(list []*CommClause) []*CommClause {
1455 if list == nil {
1456 return nil
1457 }
1458 c := make([]*CommClause, len(list))
1459 copy(c, list)
1460 return c
1461 }
1462 func doCommClauses(list []*CommClause, do func(Node) bool) bool {
1463 for _, x := range list {
1464 if x != nil && do(x) {
1465 return true
1466 }
1467 }
1468 return false
1469 }
1470 func editCommClauses(list []*CommClause, edit func(Node) Node) {
1471 for i, x := range list {
1472 if x != nil {
1473 list[i] = edit(x).(*CommClause)
1474 }
1475 }
1476 }
1477
1478 func copyNames(list []*Name) []*Name {
1479 if list == nil {
1480 return nil
1481 }
1482 c := make([]*Name, len(list))
1483 copy(c, list)
1484 return c
1485 }
1486 func doNames(list []*Name, do func(Node) bool) bool {
1487 for _, x := range list {
1488 if x != nil && do(x) {
1489 return true
1490 }
1491 }
1492 return false
1493 }
1494 func editNames(list []*Name, edit func(Node) Node) {
1495 for i, x := range list {
1496 if x != nil {
1497 list[i] = edit(x).(*Name)
1498 }
1499 }
1500 }
1501
1502 func copyNodes(list []Node) []Node {
1503 if list == nil {
1504 return nil
1505 }
1506 c := make([]Node, len(list))
1507 copy(c, list)
1508 return c
1509 }
1510 func doNodes(list []Node, do func(Node) bool) bool {
1511 for _, x := range list {
1512 if x != nil && do(x) {
1513 return true
1514 }
1515 }
1516 return false
1517 }
1518 func editNodes(list []Node, edit func(Node) Node) {
1519 for i, x := range list {
1520 if x != nil {
1521 list[i] = edit(x).(Node)
1522 }
1523 }
1524 }
1525
View as plain text