@@ -18,11 +18,11 @@ final public class Function : CustomStringConvertible, HasShortDescription, Hash
1818 public private( set) var effects = FunctionEffects ( )
1919
2020 public var name : StringRef {
21- return StringRef ( bridged: SILFunction_getName ( bridged) )
21+ return StringRef ( bridged: bridged. getName ( ) )
2222 }
2323
2424 final public var description : String {
25- let stdString = SILFunction_debugDescription ( bridged)
25+ let stdString = bridged. getDebugDescription ( )
2626 return String ( _cxxString: stdString)
2727 }
2828
@@ -32,20 +32,16 @@ final public class Function : CustomStringConvertible, HasShortDescription, Hash
3232 hasher. combine ( ObjectIdentifier ( self ) )
3333 }
3434
35- public var hasOwnership : Bool { SILFunction_hasOwnership ( bridged) != 0 }
35+ public var hasOwnership : Bool { bridged. hasOwnership ( ) }
3636
3737 /// Returns true if the function is a definition and not only an external declaration.
3838 ///
3939 /// This is the case if the functioun contains a body, i.e. some basic blocks.
4040 public var isDefinition : Bool { blocks. first != nil }
4141
42- public var entryBlock : BasicBlock {
43- SILFunction_firstBlock ( bridged) . block!
44- }
42+ public var blocks : BasicBlockList { BasicBlockList ( first: bridged. getFirstBlock ( ) . block) }
4543
46- public var blocks : BasicBlockList {
47- BasicBlockList ( first: SILFunction_firstBlock ( bridged) . block)
48- }
44+ public var entryBlock : BasicBlock { blocks. first! }
4945
5046 public var arguments : LazyMapSequence < ArgumentArray , FunctionArgument > {
5147 entryBlock. arguments. lazy. map { $0 as! FunctionArgument }
@@ -61,14 +57,10 @@ final public class Function : CustomStringConvertible, HasShortDescription, Hash
6157 }
6258
6359 /// The number of indirect result arguments.
64- public var numIndirectResultArguments : Int {
65- SILFunction_numIndirectResultArguments ( bridged)
66- }
60+ public var numIndirectResultArguments : Int { bridged. getNumIndirectFormalResults ( ) }
6761
6862 /// The number of arguments which correspond to parameters (and not to indirect results).
69- public var numParameterArguments : Int {
70- SILFunction_numParameterArguments ( bridged)
71- }
63+ public var numParameterArguments : Int { bridged. getNumParameters ( ) }
7264
7365 /// The total number of arguments.
7466 ///
@@ -78,23 +70,23 @@ final public class Function : CustomStringConvertible, HasShortDescription, Hash
7870 public var numArguments : Int { numIndirectResultArguments + numParameterArguments }
7971
8072 public var hasSelfArgument : Bool {
81- SILFunction_getSelfArgumentIndex ( bridged) >= 0
73+ bridged. getSelfArgumentIndex ( ) >= 0
8274 }
8375
8476 public var selfArgumentIndex : Int {
85- let selfIdx = SILFunction_getSelfArgumentIndex ( bridged)
77+ let selfIdx = bridged. getSelfArgumentIndex ( )
8678 assert ( selfIdx >= 0 )
8779 return selfIdx
8880 }
8981
9082 public var argumentTypes : ArgumentTypeArray { ArgumentTypeArray ( function: self ) }
91- public var resultType : Type { SILFunction_getSILResultType ( bridged) . type }
83+ public var resultType : Type { bridged. getSILResultType ( ) . type }
9284
9385 public func getArgumentConvention( for argumentIndex: Int ) -> ArgumentConvention {
9486 if argumentIndex < numIndirectResultArguments {
9587 return . indirectOut
9688 }
97- return SILFunction_getSILArgumentConvention ( bridged, argumentIndex) . convention
89+ return bridged. getSILArgumentConvention ( argumentIndex) . convention
9890 }
9991
10092 public var returnInstruction : ReturnInst ? {
@@ -109,20 +101,20 @@ final public class Function : CustomStringConvertible, HasShortDescription, Hash
109101 ///
110102 /// For example, `public` linkage.
111103 public var isPossiblyUsedExternally : Bool {
112- return SILFunction_isPossiblyUsedExternally ( bridged) != 0
104+ return bridged. isPossiblyUsedExternally ( )
113105 }
114106
115107 /// True, if the linkage of the function indicates that it has a definition outside the
116108 /// current compilation unit.
117109 ///
118110 /// For example, `public_external` linkage.
119111 public var isAvailableExternally : Bool {
120- return SILFunction_isAvailableExternally ( bridged) != 0
112+ return bridged. isAvailableExternally ( )
121113 }
122114
123115 public func hasSemanticsAttribute( _ attr: StaticString ) -> Bool {
124116 attr. withUTF8Buffer { ( buffer: UnsafeBufferPointer < UInt8 > ) in
125- SILFunction_hasSemanticsAttr ( bridged, llvm. StringRef ( buffer. baseAddress!, buffer. count) ) != 0
117+ bridged. hasSemanticsAttr ( llvm. StringRef ( buffer. baseAddress!, buffer. count) )
126118 }
127119 }
128120
@@ -175,24 +167,23 @@ final public class Function : CustomStringConvertible, HasShortDescription, Hash
175167
176168 /// The effect attribute which is specified in the source code (if any).
177169 public var effectAttribute : EffectAttribute {
178- switch SILFunction_getEffectAttribute ( bridged) {
179- case EffectKind_none: return . none
180- case EffectKind_readNone: return . readNone
181- case EffectKind_readOnly: return . readOnly
182- case EffectKind_releaseNone: return . releaseNone
183- default : fatalError ( )
170+ switch bridged. getEffectAttribute ( ) {
171+ case . ReadNone: return . readNone
172+ case . ReadOnly: return . readOnly
173+ case . ReleaseNone: return . releaseNone
174+ default : return . none
184175 }
185176 }
186177
187178 /// True, if the function runs with a swift 5.1 runtime.
188179 /// Note that this is function specific, because inlinable functions are de-serialized
189180 /// in a client module, which might be compiled with a different deployment target.
190181 public var isSwift51RuntimeAvailable : Bool {
191- SILFunction_isSwift51RuntimeAvailable ( bridged) != 0
182+ bridged. isSwift51RuntimeAvailable ( )
192183 }
193184
194185 public var needsStackProtection : Bool {
195- SILFunction_needsStackProtection ( bridged) != 0
186+ bridged. needsStackProtection ( )
196187 }
197188
198189 public var isDeinitBarrier : Bool {
@@ -212,7 +203,7 @@ final public class Function : CustomStringConvertible, HasShortDescription, Hash
212203 }
213204
214205 let metatype = unsafeBitCast ( Function . self, to: SwiftMetatype . self)
215- Function_register ( metatype,
206+ BridgedFunction . registerBridging ( metatype,
216207 // initFn
217208 { ( f: BridgedFunction , data: UnsafeMutableRawPointer , size: Int ) in
218209 checkLayout ( & f. function. effects, data: data, size: size)
@@ -245,36 +236,36 @@ final public class Function : CustomStringConvertible, HasShortDescription, Hash
245236 s. _withStringRef { OStream_write ( os, $0) }
246237 } ,
247238 // parseFn:
248- { ( f: BridgedFunction , str: llvm . StringRef , mode: ParseEffectsMode , argumentIndex: Int , paramNames: BridgedArrayRef ) -> BridgedParsingError in
239+ { ( f: BridgedFunction , str: llvm . StringRef , mode: BridgedFunction . ParseEffectsMode , argumentIndex: Int , paramNames: BridgedArrayRef ) -> BridgedFunction . ParsingError in
249240 do {
250241 var parser = StringParser ( str. string)
251242 let function = f. function
252243
253244 switch mode {
254- case ParseArgumentEffectsFromSource :
245+ case . argumentEffectsFromSource :
255246 let paramToIdx = paramNames. withElements ( ofType: llvm. StringRef. self) {
256247 ( buffer: UnsafeBufferPointer < llvm . StringRef > ) -> Dictionary < String , Int > in
257248 let keyValPairs = buffer. enumerated ( ) . lazy. map { ( $0. 1 . string, $0. 0 ) }
258249 return Dictionary ( uniqueKeysWithValues: keyValPairs)
259250 }
260251 let effect = try parser. parseEffectFromSource ( for: function, params: paramToIdx)
261252 function. effects. escapeEffects. arguments. append ( effect)
262- case ParseArgumentEffectsFromSIL :
253+ case . argumentEffectsFromSIL :
263254 try parser. parseEffectsFromSIL ( argumentIndex: argumentIndex, to: & function. effects)
264- case ParseGlobalEffectsFromSIL :
255+ case . globalEffectsFromSIL :
265256 try parser. parseGlobalSideEffectsFromSIL ( to: & function. effects)
266- case ParseMultipleEffectsFromSIL :
257+ case . multipleEffectsFromSIL :
267258 try parser. parseEffectsFromSIL ( to: & function. effects)
268259 default :
269260 fatalError ( " invalid ParseEffectsMode " )
270261 }
271262 if !parser. isEmpty ( ) { try parser. throwError ( " syntax error " ) }
272263 } catch let error as ParsingError {
273- return BridgedParsingError ( message: error. message. utf8Start, position: error. position)
264+ return BridgedFunction . ParsingError ( message: error. message. utf8Start, position: error. position)
274265 } catch {
275266 fatalError ( )
276267 }
277- return BridgedParsingError ( message: nil , position: 0 )
268+ return BridgedFunction . ParsingError ( message: nil , position: 0 )
278269 } ,
279270 // copyEffectsFn
280271 { ( toFunc: BridgedFunction , fromFunc: BridgedFunction ) -> Int in
@@ -295,25 +286,25 @@ final public class Function : CustomStringConvertible, HasShortDescription, Hash
295286 return 1
296287 } ,
297288 // getEffectInfo
298- { ( f: BridgedFunction , idx: Int ) -> BridgedEffectInfo in
289+ { ( f: BridgedFunction , idx: Int ) -> BridgedFunction . EffectInfo in
299290 let effects = f. function. effects
300291 if idx < effects. escapeEffects. arguments. count {
301292 let effect = effects. escapeEffects. arguments [ idx]
302- return BridgedEffectInfo ( argumentIndex: effect. argumentIndex,
303- isDerived: effect. isDerived, isEmpty: false , isValid: true )
293+ return BridgedFunction . EffectInfo ( argumentIndex: effect. argumentIndex,
294+ isDerived: effect. isDerived, isEmpty: false , isValid: true )
304295 }
305296 if let sideEffects = effects. sideEffects {
306297 let globalIdx = idx - effects. escapeEffects. arguments. count
307298 if globalIdx == 0 {
308- return BridgedEffectInfo ( argumentIndex: - 1 , isDerived: true , isEmpty: false , isValid: true )
299+ return BridgedFunction . EffectInfo ( argumentIndex: - 1 , isDerived: true , isEmpty: false , isValid: true )
309300 }
310301 let seIdx = globalIdx - 1
311302 if seIdx < sideEffects. arguments. count {
312- return BridgedEffectInfo ( argumentIndex: seIdx, isDerived: true ,
313- isEmpty: sideEffects. arguments [ seIdx] . isEmpty, isValid: true )
303+ return BridgedFunction . EffectInfo ( argumentIndex: seIdx, isDerived: true ,
304+ isEmpty: sideEffects. arguments [ seIdx] . isEmpty, isValid: true )
314305 }
315306 }
316- return BridgedEffectInfo ( argumentIndex: - 1 , isDerived: false , isEmpty: true , isValid: false )
307+ return BridgedFunction . EffectInfo ( argumentIndex: - 1 , isDerived: false , isEmpty: true , isValid: false )
317308 } ,
318309 // getMemBehaviorFn
319310 { ( f: BridgedFunction , observeRetains: Bool ) -> BridgedMemoryBehavior in
@@ -333,10 +324,10 @@ public struct ArgumentTypeArray : RandomAccessCollection, FormattedLikeArray {
333324 fileprivate let function : Function
334325
335326 public var startIndex : Int { return 0 }
336- public var endIndex : Int { SILFunction_getNumSILArguments ( function. bridged) }
327+ public var endIndex : Int { function. bridged. getNumSILArguments ( ) }
337328
338329 public subscript( _ index: Int ) -> Type {
339- SILFunction_getSILArgumentType ( function. bridged, index) . type
330+ function. bridged. getSILArgumentType ( index) . type
340331 }
341332}
342333
@@ -381,7 +372,7 @@ public struct BasicBlockList : CollectionLikeSequence, IteratorProtocol {
381372
382373 public func reversed( ) -> ReverseBasicBlockList {
383374 if let block = currentBlock {
384- let lastBlock = SILFunction_lastBlock ( block. parentFunction. bridged) . block
375+ let lastBlock = block. parentFunction. bridged. getLastBlock ( ) . block
385376 return ReverseBasicBlockList ( first: lastBlock)
386377 }
387378 return ReverseBasicBlockList ( first: nil )
0 commit comments