mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
[dev.regabi] cmd/compile: simplify export data representation of nil
The handling of ONIL and Orig has been a mess for a while, and dates back to how fmt.go used to print out typed nils. That hasn't applied for a while, but we've kept dragging it along to appease toolstash with the intention of someday finally removing it. Today is that day. Change-Id: I9a441628e53068ab1993cd2b67b977574d8117b7 Reviewed-on: https://go-review.googlesource.com/c/go/+/274212 Trust: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org>
This commit is contained in:
parent
ae1a337809
commit
c6de5d8d1f
2 changed files with 9 additions and 14 deletions
|
|
@ -1201,11 +1201,7 @@ func (w *exportWriter) expr(n ir.Node) {
|
|||
if !n.Type().HasNil() {
|
||||
base.Fatalf("unexpected type for nil: %v", n.Type())
|
||||
}
|
||||
if orig := ir.Orig(n); orig != nil && orig != n {
|
||||
w.expr(orig)
|
||||
break
|
||||
}
|
||||
w.op(ir.OLITERAL)
|
||||
w.op(ir.ONIL)
|
||||
w.pos(n.Pos())
|
||||
w.typ(n.Type())
|
||||
|
||||
|
|
|
|||
|
|
@ -809,20 +809,19 @@ func (r *importReader) node() ir.Node {
|
|||
// case OPAREN:
|
||||
// unreachable - unpacked by exporter
|
||||
|
||||
// case ONIL:
|
||||
// unreachable - mapped to OLITERAL
|
||||
case ir.ONIL:
|
||||
pos := r.pos()
|
||||
typ := r.typ()
|
||||
|
||||
n := npos(pos, nodnil())
|
||||
n.SetType(typ)
|
||||
return n
|
||||
|
||||
case ir.OLITERAL:
|
||||
pos := r.pos()
|
||||
typ := r.typ()
|
||||
|
||||
var n ir.Node
|
||||
if typ.HasNil() {
|
||||
n = nodnil()
|
||||
} else {
|
||||
n = ir.NewLiteral(r.value(typ))
|
||||
}
|
||||
n = npos(pos, n)
|
||||
n := npos(pos, ir.NewLiteral(r.value(typ)))
|
||||
n.SetType(typ)
|
||||
return n
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue