ssa: ChangeInterface

This commit is contained in:
visualfc
2024-06-03 16:03:05 +08:00
parent 7596658e6c
commit 193e6dfc93
7 changed files with 539 additions and 331 deletions

View File

@@ -198,6 +198,9 @@ func Interface(pkgPath, name string, methods []Imethod) *InterfaceType {
// NewItab returns a new itab.
func NewItab(inter *InterfaceType, typ *Type) *Itab {
if typ == nil {
return nil
}
n := len(inter.Methods)
size := itabHdrSize + uintptr(n)*pointerSize
ptr := AllocU(size)
@@ -246,7 +249,17 @@ func methods(u *abi.UncommonType, from string) []abi.Method {
return u.ExportedMethods()
}
func IfaceData(i iface) unsafe.Pointer {
func IfaceType(i iface) *abi.Type {
if i.tab == nil {
return nil
}
return i.tab._type
}
func IfacePtrData(i iface) unsafe.Pointer {
if i.tab == nil {
panic(errorString("invalid memory address or nil pointer dereference").Error())
}
if i.tab._type.Kind_&abi.KindDirectIface != 0 {
return unsafe.Pointer(&i.data)
}