return TypeSym(t).Linksym()
}
+// Deprecated: Use TypePtrAt instead.
func TypePtr(t *types.Type) *ir.AddrExpr {
- n := ir.NewLinksymExpr(base.Pos, TypeLinksym(t), types.Types[types.TUINT8])
- return typecheck.Expr(typecheck.NodAddr(n)).(*ir.AddrExpr)
+ return TypePtrAt(base.Pos, t)
+}
+
+// TypePtrAt returns an expression that evaluates to the
+// *runtime._type value for t.
+func TypePtrAt(pos src.XPos, t *types.Type) *ir.AddrExpr {
+ return typecheck.LinksymAddr(pos, TypeLinksym(t), types.Types[types.TUINT8])
}
// ITabLsym returns the LSym representing the itab for concrete type typ implementing
return lsym
}
-// ITabAddr returns an expression representing a pointer to the itab
-// for concrete type typ implementing interface iface.
+// Deprecated: Use ITabAddrAt instead.
func ITabAddr(typ, iface *types.Type) *ir.AddrExpr {
+ return ITabAddrAt(base.Pos, typ, iface)
+}
+
+// ITabAddrAt returns an expression that evaluates to the
+// *runtime.itab value for concrete type typ implementing interface
+// iface.
+func ITabAddrAt(pos src.XPos, typ, iface *types.Type) *ir.AddrExpr {
s, existed := ir.Pkgs.Itab.LookupOK(typ.LinkString() + "," + iface.LinkString())
lsym := s.Linksym()
writeITab(lsym, typ, iface, false)
}
- n := ir.NewLinksymExpr(base.Pos, lsym, types.Types[types.TUINT8])
- return typecheck.Expr(typecheck.NodAddr(n)).(*ir.AddrExpr)
+ return typecheck.LinksymAddr(pos, lsym, types.Types[types.TUINT8])
}
// needkeyupdate reports whether map updates with t as a key
"cmd/compile/internal/base"
"cmd/compile/internal/ir"
"cmd/compile/internal/types"
+ "cmd/internal/obj"
"cmd/internal/objabi"
"cmd/internal/src"
)
}
}
+// LinksymAddr returns a new expression that evaluates to the address
+// of lsym. typ specifies the type of the addressed memory.
+func LinksymAddr(pos src.XPos, lsym *obj.LSym, typ *types.Type) *ir.AddrExpr {
+ n := ir.NewLinksymExpr(pos, lsym, typ)
+ return Expr(NodAddrAt(pos, n)).(*ir.AddrExpr)
+}
+
func NodNil() ir.Node {
n := ir.NewNilExpr(base.Pos)
n.SetType(types.Types[types.TNIL])