Skip to content

Commit 0a953b6

Browse files
committed
SIL/AST: add var InjectEnumAddrInst.element and var EnumElementDecl.hasAssociatedValues
1 parent eeb7946 commit 0a953b6

File tree

6 files changed

+14
-1
lines changed

6 files changed

+14
-1
lines changed

SwiftCompilerSources/Sources/AST/Declarations.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,9 @@ final public class AccessorDecl: FuncDecl {}
116116

117117
final public class MacroDecl: ValueDecl {}
118118

119-
final public class EnumElementDecl: ValueDecl {}
119+
final public class EnumElementDecl: ValueDecl {
120+
public var hasAssociatedValues: Bool { bridged.EnumElementDecl_hasAssociatedValues() }
121+
}
120122

121123
final public class ExtensionDecl: Decl {}
122124

SwiftCompilerSources/Sources/SIL/Instruction.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,7 @@ final public class ExtendLifetimeInst : Instruction, UnaryInstruction {}
673673
final public class InjectEnumAddrInst : Instruction, UnaryInstruction, EnumInstruction {
674674
public var `enum`: Value { operand.value }
675675
public var caseIndex: Int { bridged.InjectEnumAddrInst_caseIndex() }
676+
public var element: EnumElementDecl { bridged.InjectEnumAddrInst_element().getAs(EnumElementDecl.self) }
676677
}
677678

678679
//===----------------------------------------------------------------------===//

include/swift/AST/ASTBridging.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,7 @@ struct BridgedDeclObj {
377377
BRIDGED_INLINE bool ProtocolDecl_requiresClass() const;
378378
BRIDGED_INLINE bool AbstractFunction_isOverridden() const;
379379
BRIDGED_INLINE bool Destructor_isIsolated() const;
380+
BRIDGED_INLINE bool EnumElementDecl_hasAssociatedValues() const;
380381
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedStringRef AccessorDecl_getKindName() const;
381382
};
382383

include/swift/AST/ASTBridgingImpl.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,10 @@ bool BridgedDeclObj::Destructor_isIsolated() const {
219219
return ai.isActorIsolated();
220220
}
221221

222+
bool BridgedDeclObj::EnumElementDecl_hasAssociatedValues() const {
223+
return getAs<swift::EnumElementDecl>()->hasAssociatedValues();
224+
}
225+
222226
//===----------------------------------------------------------------------===//
223227
// MARK: BridgedASTNode
224228
//===----------------------------------------------------------------------===//

include/swift/SIL/SILBridging.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -772,6 +772,7 @@ struct BridgedInstruction {
772772
BRIDGED_INLINE SwiftInt InitEnumDataAddrInst_caseIndex() const;
773773
BRIDGED_INLINE SwiftInt UncheckedTakeEnumDataAddrInst_caseIndex() const;
774774
BRIDGED_INLINE SwiftInt InjectEnumAddrInst_caseIndex() const;
775+
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedDeclObj InjectEnumAddrInst_element() const;
775776
BRIDGED_INLINE SwiftInt RefElementAddrInst_fieldIndex() const;
776777
BRIDGED_INLINE bool RefElementAddrInst_fieldIsLet() const;
777778
BRIDGED_INLINE bool RefElementAddrInst_isImmutable() const;

include/swift/SIL/SILBridgingImpl.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1277,6 +1277,10 @@ SwiftInt BridgedInstruction::InjectEnumAddrInst_caseIndex() const {
12771277
return getAs<swift::InjectEnumAddrInst>()->getCaseIndex();
12781278
}
12791279

1280+
BridgedDeclObj BridgedInstruction::InjectEnumAddrInst_element() const {
1281+
return {getAs<swift::InjectEnumAddrInst>()->getElement()};
1282+
}
1283+
12801284
SwiftInt BridgedInstruction::RefElementAddrInst_fieldIndex() const {
12811285
return getAs<swift::RefElementAddrInst>()->getFieldIndex();
12821286
}

0 commit comments

Comments
 (0)