Commit a8a2b38f authored by Michael Munday's avatar Michael Munday

cmd/compile/internal/gc: minor cleanup of init.go comments

Step 5 was deleted in f3575a95 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/23066Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
parent e54dfc2e
...@@ -31,21 +31,22 @@ func renameinit() *Sym { ...@@ -31,21 +31,22 @@ func renameinit() *Sym {
} }
// hand-craft the following initialization code // hand-craft the following initialization code
// var initdone· uint8 (1) // var initdone· uint8 (1)
// func init() (2) // func init() { (2)
// if initdone· > 1 { (3) // if initdone· > 1 { (3)
// return (3a) // return (3a)
// if initdone· == 1 { (4) // }
// throw(); (4a) // if initdone· == 1 { (4)
// } // throw() (4a)
// initdone· = 1; (6) // }
// // over all matching imported symbols // initdone· = 1 (5)
// <pkg>.init() (7) // // over all matching imported symbols
// { <init stmts> } (8) // <pkg>.init() (6)
// init.<n>() // if any (9) // { <init stmts> } (7)
// initdone· = 2; (10) // init.<n>() // if any (8)
// return (11) // initdone· = 2 (9)
// } // return (10)
// }
func anyinit(n []*Node) bool { func anyinit(n []*Node) bool {
// are there any interesting init statements // are there any interesting init statements
for _, ln := range n { for _, ln := range n {
...@@ -132,12 +133,12 @@ func fninit(n []*Node) { ...@@ -132,12 +133,12 @@ func fninit(n []*Node) {
// (4a) // (4a)
b.Nbody.Set1(Nod(OCALL, syslook("throwinit"), nil)) b.Nbody.Set1(Nod(OCALL, syslook("throwinit"), nil))
// (6) // (5)
a = Nod(OAS, gatevar, Nodintconst(1)) a = Nod(OAS, gatevar, Nodintconst(1))
r = append(r, a) r = append(r, a)
// (7) // (6)
for _, s := range initSyms { for _, s := range initSyms {
if s.Def != nil && s != initsym { if s.Def != nil && s != initsym {
// could check that it is fn of no args/returns // could check that it is fn of no args/returns
...@@ -146,10 +147,10 @@ func fninit(n []*Node) { ...@@ -146,10 +147,10 @@ func fninit(n []*Node) {
} }
} }
// (8) // (7)
r = append(r, nf...) r = append(r, nf...)
// (9) // (8)
// could check that it is fn of no args/returns // could check that it is fn of no args/returns
for i := 1; ; i++ { for i := 1; ; i++ {
s := LookupN("init.", i) s := LookupN("init.", i)
...@@ -160,12 +161,12 @@ func fninit(n []*Node) { ...@@ -160,12 +161,12 @@ func fninit(n []*Node) {
r = append(r, a) r = append(r, a)
} }
// (10) // (9)
a = Nod(OAS, gatevar, Nodintconst(2)) a = Nod(OAS, gatevar, Nodintconst(2))
r = append(r, a) r = append(r, a)
// (11) // (10)
a = Nod(ORETURN, nil, nil) a = Nod(ORETURN, nil, nil)
r = append(r, a) r = append(r, a)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment