swift的静态绑定

Swift Calling Convention @convention(swift)

func foo(_ x:Int, y:Int)

sil @foo : $(x:Int, y:Int) -> () {

entry(%x : $Int, %y : $Int):

...

}

func bar(_ x:Int, y:(Int, Int))

sil @bar : $(x:Int, y:(Int, Int)) -> () {

entry(%x : $Int, %y0 : $Int, %y1 : $Int):

...

}

func call_foo_and_bar() {

foo(1, 2)

bar(4, (5, 6))

}

sil @call_foo_and_bar : $() -> () {

entry:

...

%foo = function_ref @foo : $(x:Int, y:Int) -> ()

%foo_result = apply %foo(%1, %2) : $(x:Int, y:Int) -> ()

...

%bar = function_ref @bar : $(x:Int, y:(Int, Int)) -> ()

%bar_result = apply %bar(%4, %5, %6) : $(x:Int, y:(Int, Int)) -> ()

}

Swift Method Calling Convention @convention(method)

The method calling convention is currently identical to the freestanding function convention. Methods are considered to be curried functions, taking the "self" argument as their outer argument clause, and the method arguments as the inner argument clause(s). When uncurried, the "self" argument is thus passed last:

struct Foo {

func method(_ x:Int) -> Int {}

}

sil @Foo_method_1 : $((x : Int), @inout Foo) -> Int { ... }

//例子

class NSObjectBase: NSObject {

func Msg_Second(str:String){}

}

// NSObjectBase.Msg_Second(str:)

sil hidden @NSObjectBase.NSObjectBase.Msg_Second(str: Swift.String) -> () : $@convention(method) (@guaranteed String, @guaranteed NSObjectBase) -> ()

sil_vtable NSObjectBase {

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

}

Objective-C Calling Convention @convention(objc_method)

https://github.com/apple/swift/blob/master/docs/SIL.rst#objective-c-calling-convention-convention-objc-method

swift的调用约定的更多相关文章

  1. C# DllImport“调用导致堆栈不对称。原因可能是托管的 PInvoke 签名与非托管的目标签名不匹配。请检查 PInvoke 签名的调用约定和参数与非托管的目标签名是否匹配 ”

    调用外部dll时,出现如下问题 C# DllImport“调用导致堆栈不对称.原因可能是托管的 PInvoke 签名与非托管的目标签名不匹配.请检查 PInvoke 签名的调用约定和参数与非托管的目标 ...

  2. C++调用约定和名字约定

    C++调用约定和名字约定 转自http://www.cppblog.com/mzty/archive/2007/04/20/22349.html 调用约定:__cdecl __fastcall与 __ ...

  3. 调用约定__cdecl和__stdcall

    首先,__cdecl,c declaration,C风格声明.或者 c default calling(笔者瞎编的).(那么问题来了,为什么PASCAL风格被称为std?) 调用约定的内容包括三点:参 ...

  4. DLL中调用约定和名称修饰(一)

    DLL中调用约定和名称修饰(一) 调用约定(Calling Convention)是指在程序设计语言中为了实现函数调用而建立的一种协议.这种协议规定了该语言的函数中的参数传送方式.参数是否可变和由谁来 ...

  5. cdecl和stdcall调用约定-汇编演示

    . .model flat, stdcall .stack ExitProcess PROTO, dwExitCode:DWORD .data val2 sdword result dword ? . ...

  6. Delphi调用约定

    Register Calling Convention Ojbect Pascal的默认调用约定为register,寄存器调用约定会将前三个参数依次放入eax,edx,ecx,返回值是eax(根据类型 ...

  7. x64的调用约定

    在设计调用约定时,x64 体系结构利用机会清除了现有 Win32 调用约定(如 __stdcall.__cdecl.__fastcall._thiscall 等)的混乱.在 Win64 中,只有一个本 ...

  8. X86调用约定

    cdecl      C语言默认的调用约定,从右往左压栈,由调用者负责清栈,所以参数个数可以不固定: stdcall    windows默认调用方式,从右往左压栈,由被调用者负责栈操作. pasca ...

  9. DLL导出与调用约定

    一般来说,从DLL导出函数有两种方法.一种是使用.def文件:另一种是使用__declspec(dllexport). 使用上面两种方法各有优缺点.使用.def文件就是需要额外维护,当导出函数更改名字 ...

随机推荐

  1. 轻量级.NET CORE ORM框架Insql使用教程

    Insql 国人开发,是一款汲取 Mybatis 优点的.NET ORM 框架.追求简单直观,使用自由灵活等特点. 项目主页:https://rainrcn.github.io/insql 此 ORM ...

  2. Java关键字(一)——instanceof

    instanceof 严格来说是Java中的一个双目运算符,用来测试一个对象是否为一个类的实例,用法为: boolean result = obj instanceof Class 其中 obj 为一 ...

  3. POJ 1724 ROADS(使用邻接表和优先队列的BFS求解最短路问题)

    题目链接: https://cn.vjudge.net/problem/POJ-1724 N cities named with numbers 1 ... N are connected with ...

  4. 金山wps面经

    前言: 金山wps笔试是好久之前的了,忘记具体几号了.当时在华师参加的宣讲会,然后线下笔试通过了, 昨天(4月2号通知现场面试).今天是在华工酒店进行面试的,一二面一起进行的 一面: 1: 自我介绍 ...

  5. SQL 数据快速查询优化小技巧(仅供参考)

    .应尽量避免在where子句中使用!=或<>操作符 .应尽量避免在where子句中使用or来连接条件 如: 可以这样查询 Union all .in 和not in 也要慎用,否则会导致全 ...

  6. spring cloud config与eureka配合使用

    前面两篇介绍了Spring Cloud Config服务端和客户端的简单配置,本篇介绍Spring Cloud Config与Eureka配合使用 前言 默认情况下,配置客户端启动时,都是通过配置属性 ...

  7. c# 封装Dapper操作类

    using Dapper; using DapperExtensions; using System.Collections.Generic; using System.Configuration; ...

  8. MVC架构介绍—查询功能的开发

    select和from语句 注意:select和from可以不设置,默认情况下: select获取映射表的所有字段: from获取实体映射表的表名:如果设置select则必须设置frorm,但是允许仅 ...

  9. MVCHtmlHelper使用

    实例产品源码下载地址:http://www.jinhusns.com/Products/Download

  10. Java使用for循环输出菱形

    /** * This program would print out a diamond * @param row the row of diamond * @version 2018-7-23 * ...