-
Notifications
You must be signed in to change notification settings - Fork 10.4k
/
Copy pathshared-linkage.swift
48 lines (36 loc) · 1.36 KB
/
shared-linkage.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// RUN: %empty-directory(%t)
// RUN: %{python} %utils/split_file.py -o %t %s
// RUN: %target-swift-frontend -emit-module -o %t/Module.swiftmodule %t/Module.swift -enable-experimental-feature Embedded
// RUN: %target-swift-frontend -emit-ir %t/Main.swift -I%t -enable-experimental-feature Embedded
// RUN: %target-swift-frontend -O -emit-module -o %t/Module.swiftmodule %t/Module.swift -enable-experimental-feature Embedded
// RUN: %target-swift-frontend -O -emit-ir %t/Main.swift -I%t -enable-experimental-feature Embedded
// RUN: %target-swift-frontend -Osize -emit-module -o %t/Module.swiftmodule %t/Module.swift -enable-experimental-feature Embedded
// RUN: %target-swift-frontend -Osize -emit-ir %t/Main.swift -I%t -enable-experimental-feature Embedded
// REQUIRES: swift_in_compiler
// REQUIRES: swift_feature_Embedded
// BEGIN Module.swift
public func bar<R>(count: Int, _ body: (UnsafeMutableBufferPointer<Int>) -> R) -> R {
let pointer = UnsafeMutablePointer<Int>(bitPattern: 42)!
let inoutBufferPointer = UnsafeMutableBufferPointer(start: pointer, count: count)
return body(inoutBufferPointer)
}
public func foo<R>(_ body: () -> R) -> R {
bar(count: 10) { p in
body()
}
}
public func module_func() {
foo {
return 0
}
}
// BEGIN Main.swift
import Module
public func test() {
module_func()
}
public func client_func() {
foo {
return 0
}
}