cmd/compile: change Func.Cvars to the new Nodes type

Update #14473.

Change-Id: Iba1ecf42d9ab5a93144941439d5cc6b0b4f4a3ac
Reviewed-on: https://go-review.googlesource.com/19992
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
diff --git a/src/cmd/compile/internal/gc/closure.go b/src/cmd/compile/internal/gc/closure.go
index 401cd79..9a7a5c0 100644
--- a/src/cmd/compile/internal/gc/closure.go
+++ b/src/cmd/compile/internal/gc/closure.go
@@ -67,7 +67,7 @@
 	// ordinary ones in the symbol table; see oldname.
 	// unhook them.
 	// make the list of pointers for the closure call.
-	for _, v := range func_.Func.Cvars() {
+	for _, v := range func_.Func.Cvars.Slice() {
 		v.Name.Param.Closure.Name.Param.Closure = v.Name.Param.Outer
 		v.Name.Param.Outerexpr = oldname(v.Sym)
 	}
@@ -76,7 +76,7 @@
 }
 
 func typecheckclosure(func_ *Node, top int) {
-	for _, ln := range func_.Func.Cvars() {
+	for _, ln := range func_.Func.Cvars.Slice() {
 		n := ln.Name.Param.Closure
 		if !n.Name.Captured {
 			n.Name.Captured = true
@@ -224,7 +224,7 @@
 
 	func_ := xfunc.Func.Closure
 	func_.Func.Enter.Set(nil)
-	for _, v := range func_.Func.Cvars() {
+	for _, v := range func_.Func.Cvars.Slice() {
 		if v.Type == nil {
 			// if v->type is nil, it means v looked like it was
 			// going to be used in the closure but wasn't.
@@ -306,7 +306,7 @@
 
 		var addr *Node
 		var fld *Type
-		for _, v := range func_.Func.Cvars() {
+		for _, v := range func_.Func.Cvars.Slice() {
 			if v.Op == OXXX {
 				continue
 			}
@@ -354,7 +354,7 @@
 		offset := int64(Widthptr)
 		var addr *Node
 		var cv *Node
-		for _, v := range func_.Func.Cvars() {
+		for _, v := range func_.Func.Cvars.Slice() {
 			if v.Op == OXXX {
 				continue
 			}
@@ -406,7 +406,7 @@
 
 func walkclosure(func_ *Node, init **NodeList) *Node {
 	// If no closure vars, don't bother wrapping.
-	if len(func_.Func.Cvars()) == 0 {
+	if len(func_.Func.Cvars.Slice()) == 0 {
 		return func_.Func.Closure.Func.Nname
 	}
 
@@ -428,7 +428,7 @@
 
 	typ.List = list1(Nod(ODCLFIELD, newname(Lookup(".F")), typenod(Types[TUINTPTR])))
 	var typ1 *Node
-	for _, v := range func_.Func.Cvars() {
+	for _, v := range func_.Func.Cvars.Slice() {
 		if v.Op == OXXX {
 			continue
 		}
diff --git a/src/cmd/compile/internal/gc/dcl.go b/src/cmd/compile/internal/gc/dcl.go
index ab7af0e..33c04c5 100644
--- a/src/cmd/compile/internal/gc/dcl.go
+++ b/src/cmd/compile/internal/gc/dcl.go
@@ -426,7 +426,7 @@
 			n.Name.Param.Closure = c
 			c.Name.Param.Closure = n
 			c.Xoffset = 0
-			Curfn.Func.CvarAppend(c)
+			Curfn.Func.Cvars.Append(c)
 		}
 
 		// return ref to closure var, not original
diff --git a/src/cmd/compile/internal/gc/esc.go b/src/cmd/compile/internal/gc/esc.go
index fe20057..5745994 100644
--- a/src/cmd/compile/internal/gc/esc.go
+++ b/src/cmd/compile/internal/gc/esc.go
@@ -864,7 +864,7 @@
 		// Link addresses of captured variables to closure.
 	case OCLOSURE:
 		var a *Node
-		for _, v := range n.Func.Cvars() {
+		for _, v := range n.Func.Cvars.Slice() {
 			if v.Op == OXXX { // unnamed out argument; see dcl.go:/^funcargs
 				continue
 			}
diff --git a/src/cmd/compile/internal/gc/order.go b/src/cmd/compile/internal/gc/order.go
index b74b025..cc74ea5 100644
--- a/src/cmd/compile/internal/gc/order.go
+++ b/src/cmd/compile/internal/gc/order.go
@@ -1137,7 +1137,7 @@
 		}
 
 	case OCLOSURE:
-		if n.Noescape && len(n.Func.Cvars()) > 0 {
+		if n.Noescape && len(n.Func.Cvars.Slice()) > 0 {
 			prealloc[n] = ordertemp(Types[TUINT8], order, false) // walk will fill in correct type
 		}
 
diff --git a/src/cmd/compile/internal/gc/sinit.go b/src/cmd/compile/internal/gc/sinit.go
index 88ccb7e..f149c2c 100644
--- a/src/cmd/compile/internal/gc/sinit.go
+++ b/src/cmd/compile/internal/gc/sinit.go
@@ -475,7 +475,7 @@
 		break
 
 	case OCLOSURE:
-		if len(r.Func.Cvars()) == 0 {
+		if len(r.Func.Cvars.Slice()) == 0 {
 			// Closures with no captured variables are globals,
 			// so the assignment can be done at link time.
 			n := *l
diff --git a/src/cmd/compile/internal/gc/syntax.go b/src/cmd/compile/internal/gc/syntax.go
index 4e98836..7c34862 100644
--- a/src/cmd/compile/internal/gc/syntax.go
+++ b/src/cmd/compile/internal/gc/syntax.go
@@ -151,7 +151,7 @@
 	Shortname  *Node
 	Enter      Nodes
 	Exit       Nodes
-	cvars      *[]*Node // closure params
+	Cvars      Nodes    // closure params
 	Dcl        []*Node  // autodcl for this func/closure
 	Inldcl     *[]*Node // copy of dcl for use in inlining
 	Closgen    int
@@ -177,27 +177,6 @@
 	Needctxt bool   // function uses context register (has closure variables)
 }
 
-// Cvars returns the closure variables for this Func.
-// These are referenced variables that are defined in enclosing
-// functions.
-// The cvars field is a pointer to save space, since most Func values
-// have no cvars.
-func (f *Func) Cvars() []*Node {
-	if f.cvars == nil {
-		return nil
-	}
-	return *f.cvars
-}
-
-// AppendCvar appends a new closure variable.
-func (f *Func) CvarAppend(n *Node) {
-	if f.cvars == nil {
-		f.cvars = &[]*Node{n}
-	} else {
-		*f.cvars = append(*f.cvars, n)
-	}
-}
-
 type Op uint8
 
 // Node ops.