微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

swift class的虚函数表

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()

}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐