]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: make ifaceData accept a position
authorJosh Bleecher Snyder <josharian@gmail.com>
Tue, 14 Apr 2020 06:29:17 +0000 (23:29 -0700)
committerJosh Bleecher Snyder <josharian@gmail.com>
Tue, 14 Apr 2020 17:43:56 +0000 (17:43 +0000)
This lets us provide a better position in its use in swt.go.

Change-Id: I7c0da6bd0adea81acfc9a591e6a01b241a5e0942
Reviewed-on: https://go-review.googlesource.com/c/go/+/228219
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
src/cmd/compile/internal/gc/subr.go
src/cmd/compile/internal/gc/swt.go
src/cmd/compile/internal/gc/walk.go

index 7805079a632842e13f5e06c8918933955ca4930f..ff0fffb9bd241bc9a4870a206d93a4e1a9ab3866 100644 (file)
@@ -376,7 +376,13 @@ func newnamel(pos src.XPos, s *types.Sym) *Node {
 // nodSym makes a Node with Op op and with the Left field set to left
 // and the Sym field set to sym. This is for ODOT and friends.
 func nodSym(op Op, left *Node, sym *types.Sym) *Node {
-       n := nod(op, left, nil)
+       return nodlSym(lineno, op, left, sym)
+}
+
+// nodlSym makes a Node with position Pos, with Op op, and with the Left field set to left
+// and the Sym field set to sym. This is for ODOT and friends.
+func nodlSym(pos src.XPos, op Op, left *Node, sym *types.Sym) *Node {
+       n := nodl(pos, op, left, nil)
        n.Sym = sym
        return n
 }
@@ -1896,11 +1902,11 @@ func itabType(itab *Node) *Node {
 // ifaceData loads the data field from an interface.
 // The concrete type must be known to have type t.
 // It follows the pointer if !isdirectiface(t).
-func ifaceData(n *Node, t *types.Type) *Node {
+func ifaceData(pos src.XPos, n *Node, t *types.Type) *Node {
        if t.IsInterface() {
                Fatalf("ifaceData interface: %v", t)
        }
-       ptr := nodSym(OIDATA, n, nil)
+       ptr := nodlSym(pos, OIDATA, n, nil)
        if isdirectiface(t) {
                ptr.Type = t
                ptr.SetTypecheck(1)
@@ -1909,7 +1915,7 @@ func ifaceData(n *Node, t *types.Type) *Node {
        ptr.Type = types.NewPtr(t)
        ptr.SetBounded(true)
        ptr.SetTypecheck(1)
-       ind := nod(ODEREF, ptr, nil)
+       ind := nodl(pos, ODEREF, ptr, nil)
        ind.Type = t
        ind.SetTypecheck(1)
        return ind
index 6c931f2dabd5798c744dc337274b1c30ca614c5a..88c8ea8146a6405cfc37d1994d594724751d2456 100644 (file)
@@ -584,7 +584,7 @@ func walkTypeSwitch(sw *Node) {
                                if singleType.IsInterface() {
                                        Fatalf("singleType interface should have been handled in Add")
                                }
-                               val = ifaceData(s.facename, singleType)
+                               val = ifaceData(ncase.Pos, s.facename, singleType)
                        }
                        l := []*Node{
                                nodl(ncase.Pos, ODCL, caseVar, nil),
index 56062f8c570ad00cf5d962ca92df29128f44f6ba..bf12455a5d4ef5196f87544e65d50a01ead76e9d 100644 (file)
@@ -886,7 +886,7 @@ opswitch:
                        init.Append(nif)
 
                        // Build the result.
-                       e := nod(OEFACE, tmp, ifaceData(c, types.NewPtr(types.Types[TUINT8])))
+                       e := nod(OEFACE, tmp, ifaceData(n.Pos, c, types.NewPtr(types.Types[TUINT8])))
                        e.Type = toType // assign type manually, typecheck doesn't understand OEFACE.
                        e.SetTypecheck(1)
                        n = e
@@ -3165,7 +3165,7 @@ func walkcompare(n *Node, init *Nodes) *Node {
                        eqtype = nod(andor, nonnil, match)
                }
                // Check for data equal.
-               eqdata := nod(eq, ifaceData(l, r.Type), r)
+               eqdata := nod(eq, ifaceData(n.Pos, l, r.Type), r)
                // Put it all together.
                expr := nod(andor, eqtype, eqdata)
                n = finishcompare(n, expr, init)