cmd/compile: extract common noding code from func{Decl,Lit}

Passes toolstash-check.

Change-Id: I8290221d6169e077dfa4ea737d685c7fcecf6841
Reviewed-on: https://go-review.googlesource.com/100835
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
This commit is contained in:
Matthew Dempsky 2018-03-14 16:53:30 -07:00
parent 463fe95bdd
commit 29517daff9
2 changed files with 17 additions and 30 deletions

View file

@ -26,18 +26,7 @@ func (p *noder) funcLit(expr *syntax.FuncLit) *Node {
xfunc.Func.Closure = clo
clo.Func.Closure = xfunc
oldScope := p.funchdr(xfunc)
body := p.stmts(expr.Body.List)
if body == nil {
body = []*Node{nod(OEMPTY, nil, nil)}
}
xfunc.Nbody.Set(body)
lineno = p.makeXPos(expr.Body.Rbrace)
xfunc.Func.Endlineno = lineno
p.funcbody(oldScope)
p.funcBody(xfunc, expr.Body)
// closure-specific variables are hanging off the
// ordinary ones in the symbol table; see oldname.