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: 's 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 (
* marks variables that escape the local frame.
* rewrites n->op to be more specific in some cases.
*/
var typecheckdefstack *NodeList
var typecheckdefstack []*Node
/*
* resolve ONONAME to definition, if any.
......@@ -3679,16 +3679,13 @@ func typecheckdef(n *Node) *Node {
return n
}
l := new(NodeList)
l.N = n
l.Next = typecheckdefstack
typecheckdefstack = l
typecheckdefstack = append(typecheckdefstack, n)
if n.Walkdef == 2 {
Flusherrors()
fmt.Printf("typecheckdef loop:")
for l := typecheckdefstack; l != nil; l = l.Next {
fmt.Printf(" %v", l.N.Sym)
for i := len(typecheckdefstack) - 1; i >= 0; i-- {
n := typecheckdefstack[i]
fmt.Printf(" %v", n.Sym)
}
fmt.Printf("\n")
Fatalf("typecheckdef loop")
......@@ -3824,11 +3821,12 @@ ret:
if n.Op != OLITERAL && n.Type != nil && isideal(n.Type) {
Fatalf("got %v for %v", n.Type, n)
}
if typecheckdefstack.N != n {
last := len(typecheckdefstack) - 1
if typecheckdefstack[last] != n {
Fatalf("typecheckdefstack mismatch")
}
l = typecheckdefstack
typecheckdefstack = l.Next
typecheckdefstack[last] = nil
typecheckdefstack = typecheckdefstack[:last]
lineno = int32(lno)
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