]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: change Func.Cvars to the new Nodes type
authorIan Lance Taylor <iant@golang.org>
Sat, 27 Feb 2016 01:03:58 +0000 (17:03 -0800)
committerIan Lance Taylor <iant@golang.org>
Sat, 27 Feb 2016 22:43:26 +0000 (22:43 +0000)
Update #14473.

Change-Id: Iba1ecf42d9ab5a93144941439d5cc6b0b4f4a3ac
Reviewed-on: https://go-review.googlesource.com/19992
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/cmd/compile/internal/gc/closure.go
src/cmd/compile/internal/gc/dcl.go
src/cmd/compile/internal/gc/esc.go
src/cmd/compile/internal/gc/order.go
src/cmd/compile/internal/gc/sinit.go
src/cmd/compile/internal/gc/syntax.go

index 401cd797dc3cee7322cda28f33a45a7e6bc96376..9a7a5c0c277d1af5a64f6d1e789d3b82a1cf207d 100644 (file)
@@ -67,7 +67,7 @@ func closurebody(body *NodeList) *Node {
        // 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 closurebody(body *NodeList) *Node {
 }
 
 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 capturevars(xfunc *Node) {
 
        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 @@ func transformclosure(xfunc *Node) {
 
                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 @@ func transformclosure(xfunc *Node) {
                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 transformclosure(xfunc *Node) {
 
 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 @@ func walkclosure(func_ *Node, init **NodeList) *Node {
 
        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
                }
index ab7af0ecc395a5648354e5d34ff2c96287191a32..33c04c501d81b47b4af7964738a4530bb2ce01ba 100644 (file)
@@ -426,7 +426,7 @@ func oldname(s *Sym) *Node {
                        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
index fe200577031d42d0e33f6cfcf20d30ce1ee7dd36..57459947853e7dbe9b0639f07122bfc13f10039a 100644 (file)
@@ -864,7 +864,7 @@ func esc(e *EscState, n *Node, up *Node) {
                // 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
                        }
index b74b025505deeaaede460ec7efc38fe174058673..cc74ea553b4a175b2712d8cc703aad5a0a09fdd7 100644 (file)
@@ -1137,7 +1137,7 @@ func orderexpr(np **Node, order *Order, lhs *Node) {
                }
 
        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
                }
 
index 88ccb7e2b0340a6b18a348e250c13c7e406f41f1..f149c2cd74771ad21bca208f3b291b7f7fce70a4 100644 (file)
@@ -475,7 +475,7 @@ func staticassign(l *Node, r *Node, out **NodeList) bool {
                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
index 4e988360f10b85e39f31a96cb99dd5d7b1656611..7c34862a63114d91b2288b15ee7b37d035431d99 100644 (file)
@@ -151,7 +151,7 @@ type Func struct {
        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 @@ type Func struct {
        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.