@@ -31,32 +31,25 @@ extension BridgedASTContext {
31
31
/// queries.
32
32
struct CompilerBuildConfiguration : BuildConfiguration {
33
33
let ctx : BridgedASTContext
34
+ let staticBuildConfiguration : StaticBuildConfiguration
34
35
let sourceBuffer : UnsafeBufferPointer < UInt8 >
35
36
36
37
init ( ctx: BridgedASTContext , sourceBuffer: UnsafeBufferPointer < UInt8 > ) {
37
38
self . ctx = ctx
39
+ self . staticBuildConfiguration = ctx. staticBuildConfiguration
38
40
self . sourceBuffer = sourceBuffer
39
41
}
40
42
41
- func isCustomConditionSet( name: String ) throws -> Bool {
42
- var name = name
43
- return name. withBridgedString { nameRef in
44
- ctx. langOpts. customConditionSet ( nameRef)
45
- }
43
+ func isCustomConditionSet( name: String ) -> Bool {
44
+ staticBuildConfiguration. isCustomConditionSet ( name: name)
46
45
}
47
46
48
- func hasFeature( name: String ) throws -> Bool {
49
- var name = name
50
- return name. withBridgedString { nameRef in
51
- ctx. langOpts. hasFeatureNamed ( nameRef)
52
- }
47
+ func hasFeature( name: String ) -> Bool {
48
+ staticBuildConfiguration. hasFeature ( name: name)
53
49
}
54
50
55
- func hasAttribute( name: String ) throws -> Bool {
56
- var name = name
57
- return name. withBridgedString { nameRef in
58
- ctx. langOpts. hasAttributeNamed ( nameRef)
59
- }
51
+ func hasAttribute( name: String ) -> Bool {
52
+ staticBuildConfiguration. hasAttribute ( name: name)
60
53
}
61
54
62
55
func canImport(
@@ -97,85 +90,50 @@ struct CompilerBuildConfiguration: BuildConfiguration {
97
90
}
98
91
}
99
92
100
- func isActiveTargetOS( name: String ) throws -> Bool {
101
- var name = name
102
- return name. withBridgedString { nameRef in
103
- ctx. langOpts. isActiveTargetOS ( nameRef)
104
- }
93
+ func isActiveTargetOS( name: String ) -> Bool {
94
+ staticBuildConfiguration. isActiveTargetOS ( name: name)
105
95
}
106
96
107
- func isActiveTargetArchitecture( name: String ) throws -> Bool {
108
- var name = name
109
- return name. withBridgedString { nameRef in
110
- ctx. langOpts. isActiveTargetArchitecture ( nameRef)
111
- }
97
+ func isActiveTargetArchitecture( name: String ) -> Bool {
98
+ staticBuildConfiguration. isActiveTargetArchitecture ( name: name)
112
99
}
113
100
114
- func isActiveTargetEnvironment( name: String ) throws -> Bool {
115
- var name = name
116
- return name. withBridgedString { nameRef in
117
- ctx. langOpts. isActiveTargetEnvironment ( nameRef)
118
- }
101
+ func isActiveTargetEnvironment( name: String ) -> Bool {
102
+ staticBuildConfiguration. isActiveTargetEnvironment ( name: name)
119
103
}
120
104
121
105
func isActiveTargetRuntime( name: String ) throws -> Bool {
122
- var name = name
123
-
124
106
// Complain if the provided runtime isn't one of the known values.
125
107
switch name {
126
108
case " _Native " , " _ObjC " , " _multithreaded " : break
127
109
default : throw IfConfigError . unexpectedRuntimeCondition
128
110
}
129
111
130
- return name. withBridgedString { nameRef in
131
- ctx. langOpts. isActiveTargetRuntime ( nameRef)
132
- }
112
+ return staticBuildConfiguration. isActiveTargetRuntime ( name: name)
133
113
}
134
-
135
- func isActiveTargetPointerAuthentication( name: String ) throws -> Bool {
136
- var name = name
137
- return name. withBridgedString { nameRef in
138
- ctx. langOpts. isActiveTargetPtrAuth ( nameRef)
139
- }
114
+
115
+ func isActiveTargetPointerAuthentication( name: String ) -> Bool {
116
+ staticBuildConfiguration. isActiveTargetPointerAuthentication ( name: name)
140
117
}
141
118
142
119
var targetPointerBitWidth : Int {
143
- Int ( ctx . langOpts . targetPointerBitWidth)
120
+ staticBuildConfiguration . targetPointerBitWidth
144
121
}
145
122
146
123
var targetAtomicBitWidths : [ Int ] {
147
- var bitWidthsBuf : UnsafeMutablePointer < SwiftInt > ? = nil
148
- let count = ctx. langOpts. getTargetAtomicBitWidths ( & bitWidthsBuf)
149
- let bitWidths = Array ( UnsafeMutableBufferPointer ( start: bitWidthsBuf, count: count) )
150
- deallocateIntBuffer ( bitWidthsBuf) ;
151
- return bitWidths
124
+ staticBuildConfiguration. targetAtomicBitWidths
152
125
}
153
126
154
127
var endianness : Endianness {
155
- switch ctx. langOpts. targetEndianness {
156
- case . EndianBig: return . big
157
- case . EndianLittle: return . little
158
- }
128
+ staticBuildConfiguration. endianness
159
129
}
160
130
161
- var languageVersion : VersionTuple {
162
- var componentsBuf : UnsafeMutablePointer < SwiftInt > ? = nil
163
- let count = ctx. langOpts. getLanguageVersion ( & componentsBuf)
164
- let version = VersionTuple (
165
- components: Array ( UnsafeMutableBufferPointer ( start: componentsBuf, count: count) )
166
- )
167
- deallocateIntBuffer ( componentsBuf) ;
168
- return version
131
+ var languageVersion : VersionTuple {
132
+ staticBuildConfiguration. languageVersion
169
133
}
170
134
171
- var compilerVersion : VersionTuple {
172
- var componentsBuf : UnsafeMutablePointer < SwiftInt > ? = nil
173
- let count = ctx. langOpts. getCompilerVersion ( & componentsBuf)
174
- let version = VersionTuple (
175
- components: Array ( UnsafeMutableBufferPointer ( start: componentsBuf, count: count) )
176
- )
177
- deallocateIntBuffer ( componentsBuf) ;
178
- return version
135
+ var compilerVersion : VersionTuple {
136
+ staticBuildConfiguration. compilerVersion
179
137
}
180
138
}
181
139
0 commit comments