文章40 | 阅读 19085 | 点赞0
protocol Drawable {
func draw() -> Int
}
struct Point: Drawable {
var x, y: Int
func draw() -> Int {
return x + y
}
}
struct Line: Drawable {
var length: Int
func draw() -> Int {
return length
}
}
func foo() -> Int {
let p: Drawable = xxx
return p.draw()
}
protocol Drawable {
func draw() -> Int
}
struct Point: Drawable {
var x, y: Int
func draw() -> Int {
return x + y
}
}
func foo() -> Int {
let p: Drawable = Point(x: 1, y: 2)
return p.draw()
}
swift-ui-test`foo():
0x10518a860 <+0>: push rbp
0x10518a861 <+1>: mov rbp, rsp
0x10518a864 <+4>: push r13
0x10518a866 <+6>: sub rsp, 0x48
0x10518a86a <+10>: mov edi, 0x1
0x10518a86f <+15>: mov esi, 0x2
0x10518a874 <+20>: call 0x10518ae50 ; swift_ui_test.Point.init(x: Swift.Int, y: Swift.Int) -> swift_ui_test.Point at ContentView.swift:27
0x10518a879 <+25>: lea rcx, [rip + 0x1948] ; type metadata for swift_ui_test.Point
0x10518a880 <+32>: mov qword ptr [rbp - 0x18], rcx
0x10518a884 <+36>: lea rcx, [rip + 0x189d] ; protocol witness table for swift_ui_test.Point : swift_ui_test.Drawable in swift_ui_test
0x10518a88b <+43>: mov qword ptr [rbp - 0x10], rcx
0x10518a88f <+47>: mov qword ptr [rbp - 0x30], rax
0x10518a893 <+51>: mov qword ptr [rbp - 0x28], rdx
0x10518a897 <+55>: mov rax, qword ptr [rbp - 0x18]
0x10518a89b <+59>: mov rcx, qword ptr [rbp - 0x10]
0x10518a89f <+63>: lea rdx, [rbp - 0x30]
0x10518a8a3 <+67>: mov rdi, rdx
0x10518a8a6 <+70>: mov rsi, rax
0x10518a8a9 <+73>: mov qword ptr [rbp - 0x38], rax
0x10518a8ad <+77>: mov qword ptr [rbp - 0x40], rcx
0x10518a8b1 <+81>: mov qword ptr [rbp - 0x48], rdx
0x10518a8b5 <+85>: call 0x10518ae60 ; __swift_project_boxed_opaque_existential_1 at <compiler-generated>
0x10518a8ba <+90>: mov rcx, qword ptr [rbp - 0x40]
0x10518a8be <+94>: mov rdx, qword ptr [rcx + 0x8]
0x10518a8c2 <+98>: mov r13, rax
0x10518a8c5 <+101>: mov rdi, qword ptr [rbp - 0x38]
0x10518a8c9 <+105>: mov rsi, rcx
0x10518a8cc <+108>: call rdx
-> 0x10518a8ce <+110>: mov rdi, qword ptr [rbp - 0x48]
0x10518a8d2 <+114>: mov qword ptr [rbp - 0x50], rax
0x10518a8d6 <+118>: call 0x10518aec0 ; __swift_destroy_boxed_opaque_existential_1 at <compiler-generated>
0x10518a8db <+123>: mov rax, qword ptr [rbp - 0x50]
0x10518a8df <+127>: add rsp, 0x48
0x10518a8e3 <+131>: pop r13
0x10518a8e5 <+133>: pop rbp
0x10518a8e6 <+134>: ret
0x10518a86a <+10>: mov edi, 0x1
0x10518a86f <+15>: mov esi, 0x2
0x10518a874 <+20>: call 0x10518ae50 ; swift_ui_test.Point.init(x: Swift.Int, y: Swift.Int) -> swift_ui_test.Point at ContentView.swift:27
let p: Drawable = Point(x: 1, y: 2)
0x10518a89f <+63>: lea rdx, [rbp - 0x30]
0x10518a8a3 <+67>: mov rdi, rdx
0x1073be8be <+94>: mov rdx, qword ptr [rcx + 0x8]
0x1073be884 <+36>: lea rcx, [rip + 0x189d] ; protocol witness table for swift_ui_test.Point : swift_ui_test.Drawable in swift_ui_test
版权说明 : 本文为转载文章, 版权归原作者所有 版权申明
原文链接 : https://blog.csdn.net/Forever_wj/article/details/121940356
内容来源于网络,如有侵权,请联系作者删除!