]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: separate out parameter and field export encoding
authorKeith Randall <khr@golang.org>
Tue, 20 Apr 2021 22:36:11 +0000 (15:36 -0700)
committerKeith Randall <khr@golang.org>
Tue, 20 Apr 2021 23:41:54 +0000 (23:41 +0000)
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>

src/cmd/compile/internal/typecheck/iexport.go
src/cmd/compile/internal/typecheck/iimport.go

index b59a610cf79e4a31d0fec7df8e77f08298d9a363..6a56abb1b99b28eb9d7c101a5518e74b9141b5af 100644 (file)
@@ -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.
index 53576bf725d83b0c2439f886d08c10da6e5b4336..8c197215d7244b854c97dde1f7e7118cf4900e22 100644 (file)
@@ -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()