[dev.regabi] cmd/compile: expand documentation for Func.Closure{Vars,Enter}

I keep getting these confused and having to look at how the code
actually uses them.

Change-Id: I86baf22b76e7dddada6830df0fac241092f716bf
Reviewed-on: https://go-review.googlesource.com/c/go/+/280993
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
This commit is contained in:
Matthew Dempsky 2021-01-01 01:46:55 -08:00
parent 6ddbc75efd
commit ece345aa69

View file

@ -65,9 +65,22 @@ type Func struct {
// include closurevars until transformclosure runs.
Dcl []*Name
ClosureEnter Nodes // list of ONAME nodes (or OADDR-of-ONAME nodes, for output parameters) of captured variables
ClosureType Ntype // closure representation type
ClosureVars []*Name // closure params; each has closurevar set
ClosureType Ntype // closure representation type
// ClosureVars lists the free variables that are used within a
// function literal, but formally declared in an enclosing
// function. The variables in this slice are the closure function's
// own copy of the variables, which are used within its function
// body. They will also each have IsClosureVar set, and will have
// Byval set if they're captured by value.
ClosureVars []*Name
// ClosureEnter holds the expressions that the enclosing function
// will use to initialize the closure's free variables. These
// correspond one-to-one with the variables in ClosureVars, and will
// be either an ONAME node (if the variable is captured by value) or
// an OADDR-of-ONAME node (if not).
ClosureEnter Nodes
// Parents records the parent scope of each scope within a
// function. The root scope (0) has no parent, so the i'th