File tree Expand file tree Collapse file tree 6 files changed +34
-0
lines changed
SwiftCompilerSources/Sources Expand file tree Collapse file tree 6 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -791,3 +791,9 @@ extension Function {
791
791
return context. _bridged. appendBlock ( bridged) . block
792
792
}
793
793
}
794
+
795
+ extension DeclRef {
796
+ func calleesAreStaticallyKnowable( _ context: some Context ) -> Bool {
797
+ context. _bridged. calleesAreStaticallyKnowable ( bridged)
798
+ }
799
+ }
Original file line number Diff line number Diff line change 11
11
//===----------------------------------------------------------------------===//
12
12
13
13
import SILBridging
14
+ import AST
14
15
16
+ /// A key for referencing an AST declaration in SIL.
17
+ ///
18
+ /// In addition to the AST reference, there are discriminators for referencing different
19
+ /// implementation-level entities associated with a single language-level declaration,
20
+ /// such as the allocating and initializing entry points of a constructor, etc.
15
21
public struct DeclRef : CustomStringConvertible , NoReflectionChildren {
16
22
public let bridged : BridgedDeclRef
17
23
18
24
public var location : Location { Location ( bridged: bridged. getLocation ( ) ) }
19
25
20
26
public var description : String { String ( taking: bridged. getDebugDescription ( ) ) }
27
+
28
+ public var decl : Decl { bridged. getDecl ( ) . decl }
29
+
30
+ public static func == ( lhs: DeclRef , rhs: DeclRef ) -> Bool {
31
+ lhs. bridged. isEqualTo ( rhs. bridged)
32
+ }
21
33
}
Original file line number Diff line number Diff line change @@ -927,8 +927,10 @@ struct BridgedDeclRef {
927
927
BRIDGED_INLINE BridgedDeclRef (swift::SILDeclRef declRef);
928
928
BRIDGED_INLINE swift::SILDeclRef unbridged () const ;
929
929
930
+ BRIDGED_INLINE bool isEqualTo (BridgedDeclRef rhs) const ;
930
931
BridgedOwnedString getDebugDescription () const ;
931
932
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedLocation getLocation () const ;
933
+ SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedDeclObj getDecl () const ;
932
934
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedDiagnosticArgument asDiagnosticArgument () const ;
933
935
};
934
936
Original file line number Diff line number Diff line change @@ -1726,10 +1726,18 @@ swift::SILDeclRef BridgedDeclRef::unbridged() const {
1726
1726
return *reinterpret_cast <const swift::SILDeclRef *>(&storage);
1727
1727
}
1728
1728
1729
+ bool BridgedDeclRef::isEqualTo (BridgedDeclRef rhs) const {
1730
+ return unbridged () == rhs.unbridged ();
1731
+ }
1732
+
1729
1733
BridgedLocation BridgedDeclRef::getLocation () const {
1730
1734
return swift::SILDebugLocation (unbridged ().getDecl (), nullptr );
1731
1735
}
1732
1736
1737
+ BridgedDeclObj BridgedDeclRef::getDecl () const {
1738
+ return {unbridged ().getDecl ()};
1739
+ }
1740
+
1733
1741
BridgedDiagnosticArgument BridgedDeclRef::asDiagnosticArgument () const {
1734
1742
return swift::DiagnosticArgument (unbridged ().getDecl ()->getName ());
1735
1743
}
Original file line number Diff line number Diff line change @@ -339,6 +339,7 @@ struct BridgedPassContext {
339
339
SWIFT_IMPORT_UNSAFE OptionalBridgedFunction lookUpNominalDeinitFunction (BridgedDeclObj nominal) const ;
340
340
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedSubstitutionMap getContextSubstitutionMap (BridgedType type) const ;
341
341
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedType getBuiltinIntegerType (SwiftInt bitWidth) const ;
342
+ BRIDGED_INLINE bool calleesAreStaticallyKnowable (BridgedDeclRef method) const ;
342
343
SWIFT_IMPORT_UNSAFE BridgedFunction createEmptyFunction (BridgedStringRef name,
343
344
const BridgedParameterInfo * _Nullable bridgedParams,
344
345
SwiftInt paramCount,
Original file line number Diff line number Diff line change @@ -488,6 +488,11 @@ BridgedType BridgedPassContext::getBuiltinIntegerType(SwiftInt bitWidth) const {
488
488
return swift::SILType::getBuiltinIntegerType (bitWidth, ctxt);
489
489
}
490
490
491
+ bool BridgedPassContext::calleesAreStaticallyKnowable (BridgedDeclRef method) const {
492
+ swift::SILModule *mod = invocation->getPassManager ()->getModule ();
493
+ return swift::calleesAreStaticallyKnowable (*mod, method.unbridged ());
494
+ }
495
+
491
496
void BridgedPassContext::beginTransformFunction (BridgedFunction function) const {
492
497
invocation->beginTransformFunction (function.getFunction ());
493
498
}
You can’t perform that action at this time.
0 commit comments