mirror of
https://github.com/golang/go
synced 2024-11-12 07:10:22 -07:00
cmd/compile: delete Func.Outer
This was just storage for a linked list. Change-Id: I850e8db1e1f5e72410f5c904be9409179b56a94a Reviewed-on: https://go-review.googlesource.com/23484 Reviewed-by: David Chase <drchase@google.com>
This commit is contained in:
parent
cedc7c8f20
commit
93369001c7
@ -505,10 +505,8 @@ func ifacedcl(n *Node) {
|
|||||||
n.Func = new(Func)
|
n.Func = new(Func)
|
||||||
n.Func.FCurfn = Curfn
|
n.Func.FCurfn = Curfn
|
||||||
dclcontext = PPARAM
|
dclcontext = PPARAM
|
||||||
markdcl()
|
|
||||||
Funcdepth++
|
funcstart(n)
|
||||||
n.Func.Outer = Curfn
|
|
||||||
Curfn = n
|
|
||||||
funcargs(n.Right)
|
funcargs(n.Right)
|
||||||
|
|
||||||
// funcbody is normally called after the parser has
|
// funcbody is normally called after the parser has
|
||||||
@ -535,11 +533,7 @@ func funchdr(n *Node) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dclcontext = PAUTO
|
dclcontext = PAUTO
|
||||||
markdcl()
|
funcstart(n)
|
||||||
Funcdepth++
|
|
||||||
|
|
||||||
n.Func.Outer = Curfn
|
|
||||||
Curfn = n
|
|
||||||
|
|
||||||
if n.Func.Nname != nil {
|
if n.Func.Nname != nil {
|
||||||
funcargs(n.Func.Nname.Name.Param.Ntype)
|
funcargs(n.Func.Nname.Name.Param.Ntype)
|
||||||
@ -672,6 +666,19 @@ func funcargs2(t *Type) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var funcstack []*Node // stack of previous values of Curfn
|
||||||
|
var Funcdepth int32 // len(funcstack) during parsing, but then forced to be the same later during compilation
|
||||||
|
|
||||||
|
|
||||||
|
// start the function.
|
||||||
|
// called before funcargs; undone at end of funcbody.
|
||||||
|
func funcstart(n *Node) {
|
||||||
|
markdcl()
|
||||||
|
funcstack = append(funcstack, Curfn)
|
||||||
|
Funcdepth++
|
||||||
|
Curfn = n
|
||||||
|
}
|
||||||
|
|
||||||
// finish the body.
|
// finish the body.
|
||||||
// called in auto-declaration context.
|
// called in auto-declaration context.
|
||||||
// returns in extern-declaration context.
|
// returns in extern-declaration context.
|
||||||
@ -681,9 +688,8 @@ func funcbody(n *Node) {
|
|||||||
Fatalf("funcbody: unexpected dclcontext %d", dclcontext)
|
Fatalf("funcbody: unexpected dclcontext %d", dclcontext)
|
||||||
}
|
}
|
||||||
popdcl()
|
popdcl()
|
||||||
|
funcstack, Curfn = funcstack[:len(funcstack)-1], funcstack[len(funcstack)-1]
|
||||||
Funcdepth--
|
Funcdepth--
|
||||||
Curfn = n.Func.Outer
|
|
||||||
n.Func.Outer = nil
|
|
||||||
if Funcdepth == 0 {
|
if Funcdepth == 0 {
|
||||||
dclcontext = PEXTERN
|
dclcontext = PEXTERN
|
||||||
}
|
}
|
||||||
|
@ -259,8 +259,6 @@ var Widthreg int
|
|||||||
|
|
||||||
var nblank *Node
|
var nblank *Node
|
||||||
|
|
||||||
var Funcdepth int32
|
|
||||||
|
|
||||||
var typecheckok bool
|
var typecheckok bool
|
||||||
|
|
||||||
var compiling_runtime bool
|
var compiling_runtime bool
|
||||||
|
@ -23,7 +23,7 @@ func TestSizeof(t *testing.T) {
|
|||||||
_64bit uintptr // size on 64bit platforms
|
_64bit uintptr // size on 64bit platforms
|
||||||
}{
|
}{
|
||||||
{Flow{}, 52, 88},
|
{Flow{}, 52, 88},
|
||||||
{Func{}, 96, 168},
|
{Func{}, 92, 160},
|
||||||
{Name{}, 52, 80},
|
{Name{}, 52, 80},
|
||||||
{Node{}, 92, 144},
|
{Node{}, 92, 144},
|
||||||
{Sym{}, 60, 112},
|
{Sym{}, 60, 112},
|
||||||
|
@ -199,9 +199,8 @@ type Func struct {
|
|||||||
Dcl []*Node // autodcl for this func/closure
|
Dcl []*Node // autodcl for this func/closure
|
||||||
Inldcl Nodes // copy of dcl for use in inlining
|
Inldcl Nodes // copy of dcl for use in inlining
|
||||||
Closgen int
|
Closgen int
|
||||||
Outerfunc *Node
|
Outerfunc *Node // outer function (for closure)
|
||||||
FieldTrack map[*Sym]struct{}
|
FieldTrack map[*Sym]struct{}
|
||||||
Outer *Node // outer func for closure
|
|
||||||
Ntype *Node // signature
|
Ntype *Node // signature
|
||||||
Top int // top context (Ecall, Eproc, etc)
|
Top int // top context (Ecall, Eproc, etc)
|
||||||
Closure *Node // OCLOSURE <-> ODCLFUNC
|
Closure *Node // OCLOSURE <-> ODCLFUNC
|
||||||
|
Loading…
Reference in New Issue
Block a user