swift class的虚函数表

时间:2024-03-25 10:37:02

class NSObjectBase: NSObject {

func Msg_Normal(){ }

func Msg_Second(){}

func Msg_Third(){}

@objc func Msg_ObjcX(){}

@objc dynamic func Msg_Objc_DynamicX(){ }

func callTest(){self.Msg_Normal()}

func callAgain(){self.Msg_Third()}

}

extension NSObjectBase{

@objc func OcExtensionFunc(){}

}

class DerivedOcClass:NSObjectBase{

override func Msg_Normal() {}

override func OcExtensionFunc(){}

override func Msg_Objc_DynamicX() {}

}

swiftc -emit-sil BaseClass.swift | xcrun swift-demangle > ClassFunc.silgen

cat ClassFunc.silgen

class NSObjectBase : NSObject {

func Msg_Normal()

func Msg_Second()

func Msg_Third()

@objc func Msg_ObjcX()

@objc dynamic func Msg_Objc_DynamicX()

func callTest()

func callAgain()

}

extension NSObjectBase {

@objc dynamic func OcExtensionFunc()

}

class DerivedOcClass : NSObjectBase {

override func Msg_Normal()

override dynamic func OcExtensionFunc()

override dynamic func Msg_Objc_DynamicX()

}

sil_vtable NSObjectBase {

#NSObjectBase.Msg_Normal!1: (NSObjectBase) -> () -> () : @NSObjectBase.NSObjectBase.Msg_Normal() -> () // NSObjectBase.Msg_Normal()

#NSObjectBase.Msg_Second!1: (NSObjectBase) -> () -> () : @NSObjectBase.NSObjectBase.Msg_Second() -> () // NSObjectBase.Msg_Second()

#NSObjectBase.Msg_Third!1: (NSObjectBase) -> () -> () : @NSObjectBase.NSObjectBase.Msg_Third() -> () // NSObjectBase.Msg_Third()

#NSObjectBase.Msg_ObjcX!1: (NSObjectBase) -> () -> () : @NSObjectBase.NSObjectBase.Msg_ObjcX() -> () // NSObjectBase.Msg_ObjcX()

#NSObjectBase.callTest!1: (NSObjectBase) -> () -> () : @NSObjectBase.NSObjectBase.callTest() -> () // NSObjectBase.callTest()

#NSObjectBase.callAgain!1: (NSObjectBase) -> () -> () : @NSObjectBase.NSObjectBase.callAgain() -> () // NSObjectBase.callAgain()

}

sil_vtable DerivedOcClass {

#NSObjectBase.Msg_Normal!1: (NSObjectBase) -> () -> () : @NSObjectBase.DerivedOcClass.Msg_Normal() -> () [override] // DerivedOcClass.Msg_Normal()

#NSObjectBase.Msg_Second!1: (NSObjectBase) -> () -> () : @NSObjectBase.NSObjectBase.Msg_Second() -> () [inherited] // NSObjectBase.Msg_Second()

#NSObjectBase.Msg_Third!1: (NSObjectBase) -> () -> () : @NSObjectBase.NSObjectBase.Msg_Third() -> () [inherited] // NSObjectBase.Msg_Third()

#NSObjectBase.Msg_ObjcX!1: (NSObjectBase) -> () -> () : @NSObjectBase.NSObjectBase.Msg_ObjcX() -> () [inherited] // NSObjectBase.Msg_ObjcX()

#NSObjectBase.callTest!1: (NSObjectBase) -> () -> () : @NSObjectBase.NSObjectBase.callTest() -> () [inherited] // NSObjectBase.callTest()

#NSObjectBase.callAgain!1: (NSObjectBase) -> () -> () : @NSObjectBase.NSObjectBase.callAgain() -> () [inherited] // NSObjectBase.callAgain()

}

class BaseClass {

func NormalFunc(){}

@objc func ObjcFunc(){}

@objc dynamic func ObjcDynamicFunc(){}

}

extension BaseClass{

@objc func ExtensionNormal(){}

func ExtenNoneOcNormal(){}

}

class DerivedClass:BaseClass{

override func NormalFunc() {}

override func ObjcFunc(){}

override func ObjcDynamicFunc(){}

override func ExtensionNormal(){}

}

extension DerivedClass{}

class BaseClass {

func NormalFunc()

@objc func ObjcFunc()

@objc dynamic func ObjcDynamicFunc()

init()

deinit

}

extension BaseClass {

@objc dynamic func ExtensionNormal()

func ExtenNoneOcNormal()

}

class DerivedClass : BaseClass {

override func NormalFunc()

override func ObjcFunc()

override dynamic func ObjcDynamicFunc()

override dynamic func ExtensionNormal()

override init()

deinit

}

sil_vtable BaseClass {

#BaseClass.NormalFunc!1: (BaseClass) -> () -> () : @BaseClass.BaseClass.NormalFunc() -> () // BaseClass.NormalFunc()

#BaseClass.ObjcFunc!1: (BaseClass) -> () -> () : @BaseClass.BaseClass.ObjcFunc() -> () // BaseClass.ObjcFunc()

}

sil_vtable DerivedClass {

#BaseClass.NormalFunc!1: (BaseClass) -> () -> () : @BaseClass.DerivedClass.NormalFunc() -> () [override] // DerivedClass.NormalFunc()

#BaseClass.ObjcFunc!1: (BaseClass) -> () -> () : @BaseClass.DerivedClass.ObjcFunc() -> () [override] // DerivedClass.ObjcFunc()

}