Skip to content

Commit a0afb18

Browse files
committed
Add ScopedInstruction.instruction
So we can use existentials of this type. This seems really inefficient, but I don't have another solution.
1 parent 3271c19 commit a0afb18

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

SwiftCompilerSources/Sources/SIL/Instruction.swift

+12-1
Original file line numberDiff line numberDiff line change
@@ -1333,6 +1333,8 @@ final public class AllocExistentialBoxInst : SingleValueInstruction, Allocation
13331333
/// scope ending instruction such as `begin_access` (ending with `end_access`) and `begin_borrow` (ending with
13341334
/// `end_borrow`).
13351335
public protocol ScopedInstruction {
1336+
var instruction: Instruction { get }
1337+
13361338
var endOperands: LazyFilterSequence<UseList> { get }
13371339

13381340
var endInstructions: EndInstructions { get }
@@ -1349,7 +1351,12 @@ extension Instruction {
13491351
}
13501352

13511353
/// Instructions beginning a borrow-scope which must be ended by `end_borrow`.
1352-
public protocol BorrowIntroducingInstruction : SingleValueInstruction, ScopedInstruction {}
1354+
public protocol BorrowIntroducingInstruction : SingleValueInstruction, ScopedInstruction {
1355+
}
1356+
1357+
extension BorrowIntroducingInstruction {
1358+
public var instruction: Instruction { get { self } }
1359+
}
13531360

13541361
final public class EndBorrowInst : Instruction, UnaryInstruction {
13551362
public var borrow: Value { operand.value }
@@ -1428,6 +1435,8 @@ final public class EndAccessInst : Instruction, UnaryInstruction {
14281435
}
14291436

14301437
extension BeginAccessInst : ScopedInstruction {
1438+
public var instruction: Instruction { get { self } }
1439+
14311440
public var endOperands: LazyFilterSequence<UseList> {
14321441
return uses.lazy.filter { $0.instruction is EndAccessInst }
14331442
}
@@ -1462,6 +1471,8 @@ final public class AbortApplyInst : Instruction, UnaryInstruction {
14621471
}
14631472

14641473
extension BeginApplyInst : ScopedInstruction {
1474+
public var instruction: Instruction { get { self } }
1475+
14651476
public var endOperands: LazyFilterSequence<UseList> {
14661477
return token.uses.lazy.filter { $0.isScopeEndingUse }
14671478
}

0 commit comments

Comments
 (0)