// 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
}
// 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)
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
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),
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
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)