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

}

相关文章

软件简介:蓝湖辅助工具,减少移动端开发中控件属性的复制和粘...
现实生活中,我们听到的声音都是时间连续的,我们称为这种信...
前言最近在B站上看到一个漂亮的仙女姐姐跳舞视频,循环看了亿...
【Android App】实战项目之仿抖音的短视频分享App(附源码和...
前言这一篇博客应该是我花时间最多的一次了,从2022年1月底至...
因为我既对接过session、cookie,也对接过JWT,今年因为工作...