]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: move Node.Vargen, Node.Iota into Node.Name
authorRuss Cox <rsc@golang.org>
Wed, 27 May 2015 03:56:14 +0000 (23:56 -0400)
committerRuss Cox <rsc@golang.org>
Wed, 3 Jun 2015 20:09:20 +0000 (20:09 +0000)
$ sizeof -p cmd/compile/internal/gc Node
Node 192
$

Change-Id: I8f0c1a3cc2bf9c8eff02bbd8d061ff98affc9eb0
Reviewed-on: https://go-review.googlesource.com/10529
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
src/cmd/compile/internal/gc/dcl.go
src/cmd/compile/internal/gc/esc.go
src/cmd/compile/internal/gc/fmt.go
src/cmd/compile/internal/gc/subr.go
src/cmd/compile/internal/gc/syntax.go
src/cmd/compile/internal/gc/typecheck.go

index 2a88861dab58975cc379ef8e49b3ef4457a26057..0c50cb4787fbb27187906179c5e8266c66f0e9a2 100644 (file)
@@ -229,7 +229,7 @@ func declare(n *Node, ctxt uint8) {
        s.Block = block
        s.Lastlineno = int32(parserline())
        s.Def = n
-       n.Vargen = int32(gen)
+       n.Name.Vargen = int32(gen)
        n.Funcdepth = Funcdepth
        n.Class = uint8(ctxt)
 
@@ -423,9 +423,8 @@ func oldname(s *Sym) *Node {
                // walkdef will check s->def again once
                // all the input source has been processed.
                n = newname(s)
-
                n.Op = ONONAME
-               n.Iota = iota_ // save current iota value in const declarations
+               n.Name.Iota = iota_ // save current iota value in const declarations
        }
 
        if Curfn != nil && n.Funcdepth > 0 && n.Funcdepth != Funcdepth && n.Op == ONAME {
@@ -624,7 +623,7 @@ func funcargs(nt *Node) {
                        declare(n.Left, PPARAM)
                        if dclcontext == PAUTO {
                                vargen++
-                               n.Left.Vargen = int32(vargen)
+                               n.Left.Name.Vargen = int32(vargen)
                        }
                }
        }
@@ -641,7 +640,7 @@ func funcargs(nt *Node) {
                        declare(n.Left, PPARAM)
                        if dclcontext == PAUTO {
                                vargen++
-                               n.Left.Vargen = int32(vargen)
+                               n.Left.Name.Vargen = int32(vargen)
                        }
                }
        }
@@ -688,7 +687,7 @@ func funcargs(nt *Node) {
                declare(n.Left, PPARAMOUT)
                if dclcontext == PAUTO {
                        i++
-                       n.Left.Vargen = int32(i)
+                       n.Left.Name.Vargen = int32(i)
                }
        }
 }
index 76fb4d1070914513fcc2100537ad35aa1b84a14c..9e1e1313ea56f912044b8a5506edbd47816b7daa 100644 (file)
@@ -1627,7 +1627,7 @@ func escwalk(e *EscState, level Level, dst *Node, src *Node) {
                if src.Esc&EscMask != EscReturn {
                        src.Esc = EscReturn | src.Esc&EscContentEscapes
                }
-               src.Esc = escNoteOutputParamFlow(src.Esc, dst.Vargen, level)
+               src.Esc = escNoteOutputParamFlow(src.Esc, dst.Name.Vargen, level)
                goto recurse
        }
 
index 95181ac357617ac0511aa058376763ce09d40e40..8cbae2b8b5fc904f1346182e77b3d25cbff4d5a9 100644 (file)
@@ -205,8 +205,8 @@ func Jconv(n *Node, flag int) string {
                fmt.Fprintf(&buf, " a(%v)", n.Addable)
        }
 
-       if c == 0 && n.Vargen != 0 {
-               fmt.Fprintf(&buf, " g(%d)", n.Vargen)
+       if c == 0 && n.Name != nil && n.Name.Vargen != 0 {
+               fmt.Fprintf(&buf, " g(%d)", n.Name.Vargen)
        }
 
        if n.Lineno != 0 {
@@ -1130,8 +1130,8 @@ func exprfmt(n *Node, prec int) string {
                if (fmtmode == FExp || fmtmode == FErr) && n.Sym != nil && n.Sym.Name[0] == '~' && n.Sym.Name[1] == 'b' {
                        return "_"
                }
-               if fmtmode == FExp && n.Sym != nil && !isblank(n) && n.Vargen > 0 {
-                       return fmt.Sprintf("%v·%d", n.Sym, n.Vargen)
+               if fmtmode == FExp && n.Sym != nil && !isblank(n) && n.Name.Vargen > 0 {
+                       return fmt.Sprintf("%v·%d", n.Sym, n.Name.Vargen)
                }
 
                // Special case: explicit name of func (*T) method(...) is turned into pkg.(*T).method,
@@ -1538,7 +1538,7 @@ func nodedump(n *Node, flag int) string {
        }
 
        if n.Sym != nil && n.Op != ONAME {
-               fmt.Fprintf(&buf, " %v G%d", n.Sym, n.Vargen)
+               fmt.Fprintf(&buf, " %v G%d", n.Sym, n.Name.Vargen)
        }
 
        if n.Type != nil {
index c674cc614f554f1476586c60f661209ca15c8715..5bd71848ddb52952eacf5823ee609926843f1f7f 100644 (file)
@@ -771,12 +771,13 @@ func treecopy(n *Node, lineno int32) *Node {
                        // so that all the copies of this const definition
                        // don't have the same iota value.
                        m = Nod(OXXX, nil, nil)
-
                        *m = *n
-                       m.Iota = iota_
                        if lineno != 0 {
                                m.Lineno = lineno
                        }
+                       m.Name = new(Name)
+                       *m.Name = *n.Name
+                       m.Name.Iota = iota_
                        break
                }
                fallthrough
@@ -1630,7 +1631,7 @@ func frame(context int) {
                }
                switch n.Op {
                case ONAME:
-                       fmt.Printf("%v %v G%d %v width=%d\n", Oconv(int(n.Op), 0), n.Sym, n.Vargen, n.Type, w)
+                       fmt.Printf("%v %v G%d %v width=%d\n", Oconv(int(n.Op), 0), n.Sym, n.Name.Vargen, n.Type, w)
 
                case OTYPE:
                        fmt.Printf("%v %v width=%d\n", Oconv(int(n.Op), 0), n.Type, w)
index a410cf4d3de78bab277fb178cc6ab4cef215e7c3..4f362e45a84c9840bb0be902c05628c56f2fa4ff 100644 (file)
@@ -42,9 +42,7 @@ type Node struct {
 
        Xoffset int64
 
-       Vargen  int32 // unique name for OTYPE/ONAME within a function.  Function outputs are numbered starting at one.
        Lineno  int32
-       Iota    int32
        Walkgen uint32
 
        Funcdepth int32
@@ -87,6 +85,8 @@ type Name struct {
        Inlvar    *Node // ONAME substitute while inlining
        Defn      *Node // initializing assignment
        Decldepth int32 // declaration loop depth, increased for every loop or label
+       Vargen    int32 // unique name for OTYPE/ONAME within a function.  Function outputs are numbered starting at one.
+       Iota      int32 // value if this name is iota
        Method    bool  // OCALLMETH name
        Readonly  bool
        Captured  bool // is the variable captured by a closure
index 36088e791a00fa3b894ad604c82697b31d7d591c..44501be7bb524594ac6122e74d580b8b4ee9b446 100644 (file)
@@ -29,8 +29,8 @@ func resolve(n *Node) *Node {
                if r != nil {
                        if r.Op != OIOTA {
                                n = r
-                       } else if n.Iota >= 0 {
-                               n = Nodintconst(int64(n.Iota))
+                       } else if n.Name.Iota >= 0 {
+                               n = Nodintconst(int64(n.Name.Iota))
                        }
                }
        }
@@ -3565,7 +3565,9 @@ func copytype(n *Node, t *Type) {
        t = n.Type
        t.Sym = n.Sym
        t.Local = n.Local
-       t.Vargen = n.Vargen
+       if n.Name != nil {
+               t.Vargen = n.Name.Vargen
+       }
        t.Siggen = 0
        t.Method = nil
        t.Xmethod = nil