aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Randall <khr@golang.org>2021-04-20 15:36:11 -0700
committerKeith Randall <khr@golang.org>2021-04-20 23:41:54 +0000
commite12b0afa5454c7683cb27bef0b6979f964dd0e96 (patch)
treee6bde57c389b6ed24e92548d08a20cdf0fcce39f
parent48e3d924548ce6b96f55ff74e40f9a16449ac659 (diff)
downloadgo-e12b0afa5454c7683cb27bef0b6979f964dd0e96.tar.gz
go-e12b0afa5454c7683cb27bef0b6979f964dd0e96.zip
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>
-rw-r--r--src/cmd/compile/internal/typecheck/iexport.go10
-rw-r--r--src/cmd/compile/internal/typecheck/iimport.go18
2 files changed, 25 insertions, 3 deletions
diff --git a/src/cmd/compile/internal/typecheck/iexport.go b/src/cmd/compile/internal/typecheck/iexport.go
index b59a610cf7..6a56abb1b9 100644
--- a/src/cmd/compile/internal/typecheck/iexport.go
+++ b/src/cmd/compile/internal/typecheck/iexport.go
@@ -749,8 +749,16 @@ func (w *exportWriter) exoticParam(f *types.Field) {
w.uint64(uint64(f.Offset))
w.exoticType(f.Type)
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)
}
+
func (w *exportWriter) exoticSym(s *types.Sym) {
if s == nil {
w.string("")
@@ -1593,7 +1601,7 @@ func (w *exportWriter) expr(n ir.Node) {
if go117ExportTypes {
w.exoticType(n.Type())
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
// be reconstructed during import.
diff --git a/src/cmd/compile/internal/typecheck/iimport.go b/src/cmd/compile/internal/typecheck/iimport.go
index 53576bf725..8c197215d7 100644
--- a/src/cmd/compile/internal/typecheck/iimport.go
+++ b/src/cmd/compile/internal/typecheck/iimport.go
@@ -592,7 +592,21 @@ func (r *importReader) exoticParam() *types.Field {
f.Nname = ir.NewNameAt(pos, sym)
}
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
}
@@ -1202,7 +1216,7 @@ func (r *importReader) node() ir.Node {
n.SetType(r.exoticType())
switch op {
case ir.ODOT, ir.ODOTPTR, ir.ODOTINTER:
- n.Selection = r.exoticParam()
+ n.Selection = r.exoticField()
case ir.ODOTMETH, ir.OCALLPART, ir.OMETHEXPR:
// These require a Lookup to link to the correct declaration.
rcvrType := expr.Type()