mirror of
https://github.com/golang/go
synced 2024-09-05 16:04:50 +00:00
cmd/compile: separate out parameter and field export encoding
These two types of *types.Field encode different concepts, so we encode them separately (and ignore fields that don't matter for each concept). Change-Id: I9d1608413949a109f12a3ebd52cd7af5f476e415 Reviewed-on: https://go-review.googlesource.com/c/go/+/312130 Trust: Keith Randall <khr@golang.org> Run-TryBot: Keith Randall <khr@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org>
This commit is contained in:
parent
48e3d92454
commit
e12b0afa54
|
@ -749,8 +749,16 @@ func (w *exportWriter) exoticParam(f *types.Field) {
|
||||||
w.uint64(uint64(f.Offset))
|
w.uint64(uint64(f.Offset))
|
||||||
w.exoticType(f.Type)
|
w.exoticType(f.Type)
|
||||||
w.bool(f.IsDDD())
|
w.bool(f.IsDDD())
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w *exportWriter) exoticField(f *types.Field) {
|
||||||
|
w.pos(f.Pos)
|
||||||
|
w.exoticSym(f.Sym)
|
||||||
|
w.uint64(uint64(f.Offset))
|
||||||
|
w.exoticType(f.Type)
|
||||||
w.string(f.Note)
|
w.string(f.Note)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *exportWriter) exoticSym(s *types.Sym) {
|
func (w *exportWriter) exoticSym(s *types.Sym) {
|
||||||
if s == nil {
|
if s == nil {
|
||||||
w.string("")
|
w.string("")
|
||||||
|
@ -1593,7 +1601,7 @@ func (w *exportWriter) expr(n ir.Node) {
|
||||||
if go117ExportTypes {
|
if go117ExportTypes {
|
||||||
w.exoticType(n.Type())
|
w.exoticType(n.Type())
|
||||||
if n.Op() == ir.ODOT || n.Op() == ir.ODOTPTR || n.Op() == ir.ODOTINTER {
|
if n.Op() == ir.ODOT || n.Op() == ir.ODOTPTR || n.Op() == ir.ODOTINTER {
|
||||||
w.exoticParam(n.Selection)
|
w.exoticField(n.Selection)
|
||||||
}
|
}
|
||||||
// n.Selection is not required for OMETHEXPR, ODOTMETH, and OCALLPART. It will
|
// n.Selection is not required for OMETHEXPR, ODOTMETH, and OCALLPART. It will
|
||||||
// be reconstructed during import.
|
// be reconstructed during import.
|
||||||
|
|
|
@ -592,7 +592,21 @@ func (r *importReader) exoticParam() *types.Field {
|
||||||
f.Nname = ir.NewNameAt(pos, sym)
|
f.Nname = ir.NewNameAt(pos, sym)
|
||||||
}
|
}
|
||||||
f.SetIsDDD(ddd)
|
f.SetIsDDD(ddd)
|
||||||
f.Note = r.string()
|
return f
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *importReader) exoticField() *types.Field {
|
||||||
|
pos := r.pos()
|
||||||
|
sym := r.exoticSym()
|
||||||
|
off := r.uint64()
|
||||||
|
typ := r.exoticType()
|
||||||
|
note := r.string()
|
||||||
|
f := types.NewField(pos, sym, typ)
|
||||||
|
f.Offset = int64(off)
|
||||||
|
if sym != nil {
|
||||||
|
f.Nname = ir.NewNameAt(pos, sym)
|
||||||
|
}
|
||||||
|
f.Note = note
|
||||||
return f
|
return f
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1202,7 +1216,7 @@ func (r *importReader) node() ir.Node {
|
||||||
n.SetType(r.exoticType())
|
n.SetType(r.exoticType())
|
||||||
switch op {
|
switch op {
|
||||||
case ir.ODOT, ir.ODOTPTR, ir.ODOTINTER:
|
case ir.ODOT, ir.ODOTPTR, ir.ODOTINTER:
|
||||||
n.Selection = r.exoticParam()
|
n.Selection = r.exoticField()
|
||||||
case ir.ODOTMETH, ir.OCALLPART, ir.OMETHEXPR:
|
case ir.ODOTMETH, ir.OCALLPART, ir.OMETHEXPR:
|
||||||
// These require a Lookup to link to the correct declaration.
|
// These require a Lookup to link to the correct declaration.
|
||||||
rcvrType := expr.Type()
|
rcvrType := expr.Type()
|
||||||
|
|
Loading…
Reference in a new issue