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. webpack4打包报错:WARNING in configuration The 'mode' option has not been set, webpack will fallback to 'production' for this value. Set 'mode' option to 'development' or 'production' to enable defaults fo

    运行命令webpack ./src/main.js ./dist/murenziwei.js后,目录上神马动静都没有,你以为在dist文件夹上会有murenziwei.js吗?毛都没有 警告和错误倒是 ...

  2. [EZOJ1007] 神奇的三角形

    Description 求 \(\sum\limits_{i=0}^{n-1}\sum\limits_{j=0}^{i}C(i,j)\times (j+1)^m\operatorname{mod}99 ...

  3. SpringMVC+SpringJdbc+SQLServer+EasyUI增删改查

    前言 前天用SpringJdbc连接了一把SQLServer,早上起来用SpringMVC+SpringJdbc+EasUI写了个增删改查的demo,主要是熟悉下SpringMVC相关知识点,如vie ...

  4. C#实现接口IHttpModule完成统一的权限验证

    测试代码如下: using System; using System.Collections.Generic; using System.Text; using System.Collections; ...

  5. Git实战手册(二): 标签应用和版本管理

    教程所示图片使用的是 github 仓库图片,墙内朋友请移步原文地址 有空就来看看个人技术小站, 我一直都在 0. 背景介绍 当一个代码仓库进过长时间的迭代,针对不同的时期和需求,必定会有不同的版本. ...

  6. SoapUI SoapUI测试WebService协议接口简介

    SoapUI测试WebService协议接口简介 by:授客 QQ:1033553122 1. 创建项目,入口:File -> New SOAP Project,或者右键默认项目Project- ...

  7. web工程设计<mysql数据模型-数据类型的优化>

    Schema与数据类型优化 良好的逻辑设计和物理设计是高性能的基石,应该根据系统将要执行的查询语句来设计schema,这往往需要权衡各种因素. 一:选择优化的数据类型 ①:更小的通常更好 整数类型:M ...

  8. ubuntu18.04突然无法上网解决方法

    sudo service network-manager stop sudo rm /var/lib/NetworkManager/NetworkManager.state sudo service ...

  9. Djanggo ORM操作

    Django ORM那些相关操作  一般操作 看专业的官网文档:https://docs.djangoproject.com/en/1.11/ref/models/querysets/,做专业的程序员 ...

  10. Java —— 对象

    创建对象 int[] b = new int[30]; 等号右侧:创建了一个数组对象  // 等号左侧:变量 b 称为该对应的引用  // 称作 变量 b 指向了一个对象  // 有时也简称为: b ...