1
0
mirror of https://github.com/golang/go synced 2024-11-18 00:14:47 -07:00

cmd/compile: convert externdecl to []*Node

This one of a set of changes to make the transition away from NodeList
easier by removing cases in which NodeList doesn't act semi-trivially like a
[]*Node.

This CL was originally prepared by Josh Bleecher Snyder <josharian@gmail.com>.

This change passes go build -toolexec 'toolstash -cmp' -a std.

Change-Id: Ifd73501e06e8ea5efd028b6d473b3e5d1b07a5ac
Reviewed-on: https://go-review.googlesource.com/14570
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
Dave Cheney 2015-09-10 15:57:39 +10:00
parent 1fd78e1f60
commit d5fe165ca0
6 changed files with 29 additions and 36 deletions

View File

@ -182,7 +182,7 @@ func declare(n *Node, ctxt uint8) {
gen := 0
if ctxt == PEXTERN {
externdcl = list(externdcl, n)
externdcl = append(externdcl, n)
if dflag() {
fmt.Printf("\t%v global decl %v %p\n", Ctxt.Line(int(lineno)), s, n)
}

View File

@ -584,7 +584,7 @@ var maxfltval [NTYPE]*Mpflt
var xtop *NodeList
var externdcl *NodeList
var externdcl []*Node
var exportlist []*Node

View File

@ -464,9 +464,9 @@ func Main() {
}
// Phase 9: Check external declarations.
for l := externdcl; l != nil; l = l.Next {
if l.N.Op == ONAME {
typecheck(&l.N, Erv)
for i, n := range externdcl {
if n.Op == ONAME {
typecheck(&externdcl[i], Erv)
}
}

View File

@ -72,10 +72,7 @@ func dumpobj() {
fmt.Fprintf(bout, "\n!\n")
var externs *NodeList
if externdcl != nil {
externs = externdcl.End
}
externs := len(externdcl)
dumpglobls()
dumptypestructs()
@ -83,8 +80,8 @@ func dumpobj() {
// Dump extra globals.
tmp := externdcl
if externs != nil {
externdcl = externs.Next
if externdcl != nil {
externdcl = externdcl[externs:]
}
dumpglobls()
externdcl = tmp
@ -110,8 +107,7 @@ func dumpglobls() {
var n *Node
// add globals
for l := externdcl; l != nil; l = l.Next {
n = l.N
for _, n := range externdcl {
if n.Op != ONAME {
continue
}
@ -126,7 +122,6 @@ func dumpglobls() {
continue
}
dowidth(n.Type)
ggloblnod(n)
}

View File

@ -1317,8 +1317,7 @@ func dumptypestructs() {
var n *Node
// copy types from externdcl list to signatlist
for l := externdcl; l != nil; l = l.Next {
n = l.N
for _, n := range externdcl {
if n.Op != OTYPE {
continue
}

View File

@ -1584,33 +1584,32 @@ func Ptrto(t *Type) *Type {
}
func frame(context int) {
var l *NodeList
if context != 0 {
fmt.Printf("--- external frame ---\n")
l = externdcl
} else if Curfn != nil {
fmt.Printf("--- %v frame ---\n", Curfn.Func.Nname.Sym)
l = Curfn.Func.Dcl
} else {
for _, n := range externdcl {
printframenode(n)
}
return
}
var n *Node
var w int64
for ; l != nil; l = l.Next {
n = l.N
w = -1
if n.Type != nil {
w = n.Type.Width
if Curfn != nil {
fmt.Printf("--- %v frame ---\n", Curfn.Func.Nname.Sym)
for l := Curfn.Func.Dcl; l != nil; l = l.Next {
printframenode(l.N)
}
switch n.Op {
case ONAME:
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)
}
func printframenode(n *Node) {
w := int64(-1)
if n.Type != nil {
w = n.Type.Width
}
switch n.Op {
case ONAME:
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)
}
}