/
astassignment.go
56 lines (44 loc) · 988 Bytes
/
astassignment.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package template
import "io"
type astAssignment struct {
operator string
operands1, operands2 *astList
}
func (n *astAssignment) GetImports() []string {
res := []string{}
res = append(res, n.operands1.GetImports()...)
res = append(res, n.operands2.GetImports()...)
return res
}
func (n *astAssignment) GetStrings() []string {
res := []string{}
res = append(res, n.operands1.GetStrings()...)
res = append(res, n.operands2.GetStrings()...)
return res
}
func (n *astAssignment) WriteGo(w io.Writer, opts *GenGoOpts) {
first := true
for _, child := range n.operands1.children {
if child != nil {
if first {
first = false
} else {
io.WriteString(w, ", ")
}
child.WriteGo(w, opts)
}
}
io.WriteString(w, n.operator)
first = true
for _, child := range n.operands2.children {
if child != nil {
if first {
first = false
} else {
io.WriteString(w, ", ")
}
child.WriteGo(w, opts)
}
}
io.WriteString(w, "\n")
}