File tree Expand file tree Collapse file tree 3 files changed +22
-11
lines changed Expand file tree Collapse file tree 3 files changed +22
-11
lines changed Original file line number Diff line number Diff line change 50
50
51
51
#include " swift/Basic/SourceLoc.h"
52
52
#include " llvm/ADT/StringRef.h"
53
+ #include " llvm/ADT/APInt.h"
53
54
#include < string>
54
55
#include < vector>
55
56
#endif
@@ -273,6 +274,24 @@ BRIDGED_INLINE SwiftInt BridgedOwnedString_count(BridgedOwnedString str);
273
274
SWIFT_NAME (" getter:BridgedOwnedString.isEmpty(self:)" )
274
275
BRIDGED_INLINE bool BridgedOwnedString_empty(BridgedOwnedString str);
275
276
277
+ // ===----------------------------------------------------------------------===//
278
+ // MARK: BridgedOptionalInt
279
+ // ===----------------------------------------------------------------------===//
280
+
281
+ struct BridgedOptionalInt {
282
+ SwiftInt value;
283
+ bool hasValue;
284
+
285
+ #ifdef USED_IN_CPP_SOURCE
286
+ static BridgedOptionalInt getFromAPInt (llvm::APInt i) {
287
+ if (i.getSignificantBits () <= std::min (std::numeric_limits<SwiftInt>::digits, 64 )) {
288
+ return {(SwiftInt)i.getSExtValue (), true };
289
+ }
290
+ return {0 , false };
291
+ }
292
+ #endif
293
+ };
294
+
276
295
// ===----------------------------------------------------------------------===//
277
296
// MARK: OStream
278
297
// ===----------------------------------------------------------------------===//
Original file line number Diff line number Diff line change @@ -699,11 +699,6 @@ struct BridgedInstruction {
699
699
unknown
700
700
};
701
701
702
- struct OptionalInt {
703
- SwiftInt value;
704
- bool hasValue;
705
- };
706
-
707
702
enum class MarkDependenceKind {
708
703
Unresolved, Escaping, NonEscaping
709
704
};
@@ -744,7 +739,7 @@ struct BridgedInstruction {
744
739
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedGlobalVar GlobalAccessInst_getGlobal () const ;
745
740
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedGlobalVar AllocGlobalInst_getGlobal () const ;
746
741
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedFunction FunctionRefBaseInst_getReferencedFunction () const ;
747
- BRIDGED_INLINE OptionalInt IntegerLiteralInst_getValue () const ;
742
+ BRIDGED_INLINE BridgedOptionalInt IntegerLiteralInst_getValue () const ;
748
743
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedStringRef StringLiteralInst_getValue () const ;
749
744
BRIDGED_INLINE int StringLiteralInst_getEncoding () const ;
750
745
BRIDGED_INLINE SwiftInt TupleExtractInst_fieldIndex () const ;
Original file line number Diff line number Diff line change @@ -1170,12 +1170,9 @@ BridgedFunction BridgedInstruction::FunctionRefBaseInst_getReferencedFunction()
1170
1170
return {getAs<swift::FunctionRefBaseInst>()->getInitiallyReferencedFunction ()};
1171
1171
}
1172
1172
1173
- BridgedInstruction::OptionalInt BridgedInstruction::IntegerLiteralInst_getValue () const {
1173
+ BridgedOptionalInt BridgedInstruction::IntegerLiteralInst_getValue () const {
1174
1174
llvm::APInt result = getAs<swift::IntegerLiteralInst>()->getValue ();
1175
- if (result.getSignificantBits () <= std::min (std::numeric_limits<SwiftInt>::digits, 64 )) {
1176
- return {(SwiftInt)result.getSExtValue (), true };
1177
- }
1178
- return {0 , false };
1175
+ return BridgedOptionalInt::getFromAPInt (result);
1179
1176
}
1180
1177
1181
1178
BridgedStringRef BridgedInstruction::StringLiteralInst_getValue () const {
You can’t perform that action at this time.
0 commit comments