summaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/gc/init.go
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2020-11-28 07:31:18 -0500
committerRuss Cox <rsc@golang.org>2020-11-30 18:34:01 +0000
commite84b27bec587e4393533e83e3ea1cbf1ed548425 (patch)
tree6b858504b1a1e485e9405a956b874808cd6fba8c /src/cmd/compile/internal/gc/init.go
parentc4bd0b7474f169a60acf66306a4a721f790e36c9 (diff)
downloadgo-git-e84b27bec587e4393533e83e3ea1cbf1ed548425.tar.gz
[dev.regabi] cmd/compile: clean up Name and Func uses
Now that we have specific types for ONAME and ODCLFUNC nodes (*Name and *Func), use them throughout the compiler to be more precise about what data is being operated on. This is a somewhat large CL, but once you start applying the types in a few places, you end up needing to apply them to many other places to keep everything type-checking. A lot of code also melts away as types are added. Passes buildall w/ toolstash -cmp. Change-Id: I21dd9b945d701c470332bac5394fca744a5b232d Reviewed-on: https://go-review.googlesource.com/c/go/+/274097 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Diffstat (limited to 'src/cmd/compile/internal/gc/init.go')
-rw-r--r--src/cmd/compile/internal/gc/init.go12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/cmd/compile/internal/gc/init.go b/src/cmd/compile/internal/gc/init.go
index 2b7ecd1d05..7f2a39ff46 100644
--- a/src/cmd/compile/internal/gc/init.go
+++ b/src/cmd/compile/internal/gc/init.go
@@ -19,7 +19,7 @@ var renameinitgen int
// Function collecting autotmps generated during typechecking,
// to be included in the package-level init function.
-var initTodo = ir.Nod(ir.ODCLFUNC, nil, nil)
+var initTodo = ir.NewFunc(base.Pos)
func renameinit() *types.Sym {
s := lookupN("init.", renameinitgen)
@@ -49,23 +49,23 @@ func fninit(n []ir.Node) {
base.Pos = nf[0].Pos() // prolog/epilog gets line number of first init stmt
initializers := lookup("init")
fn := dclfunc(initializers, ir.Nod(ir.OTFUNC, nil, nil))
- for _, dcl := range initTodo.Func().Dcl {
+ for _, dcl := range initTodo.Dcl {
dcl.Name().Curfn = fn
}
- fn.Func().Dcl = append(fn.Func().Dcl, initTodo.Func().Dcl...)
- initTodo.Func().Dcl = nil
+ fn.Dcl = append(fn.Dcl, initTodo.Dcl...)
+ initTodo.Dcl = nil
fn.PtrBody().Set(nf)
funcbody()
- fn = typecheck(fn, ctxStmt)
+ typecheckFunc(fn)
Curfn = fn
typecheckslice(nf, ctxStmt)
Curfn = nil
xtop = append(xtop, fn)
fns = append(fns, initializers.Linksym())
}
- if initTodo.Func().Dcl != nil {
+ if initTodo.Dcl != nil {
// We only generate temps using initTodo if there
// are package-scope initialization statements, so
// something's weird if we get here.