Skip to content

Commit a8a2b38

Browse files
committed
cmd/compile/internal/gc: minor cleanup of init.go comments
Step 5 was deleted in f3575a9 however the numbering of the other steps wasn't adjusted accordingly. While we're here: clean up the whitespace, add curly braces where appropriate and delete semicolons. Change-Id: I4e77b2d3ee8460abe4bfb993674f83e35be8ff17 Reviewed-on: https://go-review.googlesource.com/23066 Reviewed-by: Brad Fitzpatrick <[email protected]>
1 parent e54dfc2 commit a8a2b38

File tree

1 file changed

+20
-19
lines changed

1 file changed

+20
-19
lines changed

src/cmd/compile/internal/gc/init.go

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,22 @@ func renameinit() *Sym {
3131
}
3232

3333
// hand-craft the following initialization code
34-
// var initdone· uint8 (1)
35-
// func init() (2)
34+
// var initdone· uint8 (1)
35+
// func init() { (2)
3636
// if initdone· > 1 { (3)
3737
// return (3a)
38-
// if initdone· == 1 { (4)
39-
// throw(); (4a)
40-
// }
41-
// initdone· = 1; (6)
42-
// // over all matching imported symbols
43-
// <pkg>.init() (7)
44-
// { <init stmts> } (8)
45-
// init.<n>() // if any (9)
46-
// initdone· = 2; (10)
47-
// return (11)
48-
// }
38+
// }
39+
// if initdone· == 1 { (4)
40+
// throw() (4a)
41+
// }
42+
// initdone· = 1 (5)
43+
// // over all matching imported symbols
44+
// <pkg>.init() (6)
45+
// { <init stmts> } (7)
46+
// init.<n>() // if any (8)
47+
// initdone· = 2 (9)
48+
// return (10)
49+
// }
4950
func anyinit(n []*Node) bool {
5051
// are there any interesting init statements
5152
for _, ln := range n {
@@ -132,12 +133,12 @@ func fninit(n []*Node) {
132133
// (4a)
133134
b.Nbody.Set1(Nod(OCALL, syslook("throwinit"), nil))
134135

135-
// (6)
136+
// (5)
136137
a = Nod(OAS, gatevar, Nodintconst(1))
137138

138139
r = append(r, a)
139140

140-
// (7)
141+
// (6)
141142
for _, s := range initSyms {
142143
if s.Def != nil && s != initsym {
143144
// could check that it is fn of no args/returns
@@ -146,10 +147,10 @@ func fninit(n []*Node) {
146147
}
147148
}
148149

149-
// (8)
150+
// (7)
150151
r = append(r, nf...)
151152

152-
// (9)
153+
// (8)
153154
// could check that it is fn of no args/returns
154155
for i := 1; ; i++ {
155156
s := LookupN("init.", i)
@@ -160,12 +161,12 @@ func fninit(n []*Node) {
160161
r = append(r, a)
161162
}
162163

163-
// (10)
164+
// (9)
164165
a = Nod(OAS, gatevar, Nodintconst(2))
165166

166167
r = append(r, a)
167168

168-
// (11)
169+
// (10)
169170
a = Nod(ORETURN, nil, nil)
170171

171172
r = append(r, a)

0 commit comments

Comments
 (0)