Skip to content

Commit d6192f4

Browse files
author
Anxhelo Xhebraj
committed
Swift SIL: add ScopedInstruction protocol for instructions like BeginAccess
1 parent 462d208 commit d6192f4

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

SwiftCompilerSources/Sources/SIL/Instruction.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,20 @@ final public class BeginAccessInst : SingleValueInstruction, UnaryInstruction {
520520
public var accessKind: AccessKind { BeginAccessInst_getAccessKind(bridged).kind }
521521
}
522522

523+
public protocol ScopedInstruction {
524+
associatedtype EndInstructions
525+
526+
var endInstructions: EndInstructions { get }
527+
}
528+
529+
extension BeginAccessInst : ScopedInstruction {
530+
public typealias EndInstructions = LazyMapSequence<LazyFilterSequence<LazyMapSequence<UseList, EndAccessInst?>>, EndAccessInst>
531+
532+
public var endInstructions: EndInstructions {
533+
uses.lazy.compactMap({ $0.value.definingInstruction as? EndAccessInst })
534+
}
535+
}
536+
523537
final public class BeginBorrowInst : SingleValueInstruction, UnaryInstruction {}
524538

525539
final public class ProjectBoxInst : SingleValueInstruction, UnaryInstruction {

0 commit comments

Comments
 (0)