Commit bab01a0b authored by Dave Cheney's avatar Dave Cheney

cmd/compile: convert typecheckdefstack 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: Ie02d2cf35f1e8438c6e9dc1d5fba51e8adde1bc0
Reviewed-on: https://go-review.googlesource.com/14480Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 1cf05ee6
...@@ -18,7 +18,7 @@ import ( ...@@ -18,7 +18,7 @@ import (
* marks variables that escape the local frame. * marks variables that escape the local frame.
* rewrites n->op to be more specific in some cases. * rewrites n->op to be more specific in some cases.
*/ */
var typecheckdefstack *NodeList var typecheckdefstack []*Node
/* /*
* resolve ONONAME to definition, if any. * resolve ONONAME to definition, if any.
...@@ -3679,16 +3679,13 @@ func typecheckdef(n *Node) *Node { ...@@ -3679,16 +3679,13 @@ func typecheckdef(n *Node) *Node {
return n return n
} }
l := new(NodeList) typecheckdefstack = append(typecheckdefstack, n)
l.N = n
l.Next = typecheckdefstack
typecheckdefstack = l
if n.Walkdef == 2 { if n.Walkdef == 2 {
Flusherrors() Flusherrors()
fmt.Printf("typecheckdef loop:") fmt.Printf("typecheckdef loop:")
for l := typecheckdefstack; l != nil; l = l.Next { for i := len(typecheckdefstack) - 1; i >= 0; i-- {
fmt.Printf(" %v", l.N.Sym) n := typecheckdefstack[i]
fmt.Printf(" %v", n.Sym)
} }
fmt.Printf("\n") fmt.Printf("\n")
Fatalf("typecheckdef loop") Fatalf("typecheckdef loop")
...@@ -3824,11 +3821,12 @@ ret: ...@@ -3824,11 +3821,12 @@ ret:
if n.Op != OLITERAL && n.Type != nil && isideal(n.Type) { if n.Op != OLITERAL && n.Type != nil && isideal(n.Type) {
Fatalf("got %v for %v", n.Type, n) Fatalf("got %v for %v", n.Type, n)
} }
if typecheckdefstack.N != n { last := len(typecheckdefstack) - 1
if typecheckdefstack[last] != n {
Fatalf("typecheckdefstack mismatch") Fatalf("typecheckdefstack mismatch")
} }
l = typecheckdefstack typecheckdefstack[last] = nil
typecheckdefstack = l.Next typecheckdefstack = typecheckdefstack[:last]
lineno = int32(lno) lineno = int32(lno)
n.Walkdef = 1 n.Walkdef = 1
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment