File tree Expand file tree Collapse file tree 3 files changed +37
-0
lines changed Expand file tree Collapse file tree 3 files changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -2125,6 +2125,16 @@ struct TargetExtendedExistentialTypeMetadata
2125
2125
return this ->template getTrailingObjects <ConstTargetPointer<Runtime, void >>();
2126
2126
}
2127
2127
2128
+ public:
2129
+ // / Project the value pointer from an extended existential container of the
2130
+ // / type described by this metadata.
2131
+ const OpaqueValue *projectValue (const OpaqueValue *container) const ;
2132
+
2133
+ OpaqueValue *projectValue (OpaqueValue *container) const {
2134
+ return const_cast <OpaqueValue *>(
2135
+ projectValue ((const OpaqueValue *)container));
2136
+ }
2137
+
2128
2138
public:
2129
2139
static bool classof (const TargetMetadata<Runtime> *metadata) {
2130
2140
return metadata->getKind () == MetadataKind::ExtendedExistential;
Original file line number Diff line number Diff line change @@ -899,6 +899,7 @@ class ExtendedExistentialTypeShapeFlags {
899
899
SpecialKind getSpecialKind () const {
900
900
return SpecialKind ((Data & SpecialKindMask) >> SpecialKindShift);
901
901
}
902
+ bool isOpaque () const { return getSpecialKind () == SpecialKind::None; }
902
903
bool isClassConstrained () const {
903
904
return getSpecialKind () == SpecialKind::Class;
904
905
}
Original file line number Diff line number Diff line change @@ -3977,6 +3977,32 @@ ExistentialTypeMetadata::projectValue(const OpaqueValue *container) const {
3977
3977
" Unhandled ExistentialTypeRepresentation in switch." );
3978
3978
}
3979
3979
3980
+ template <>
3981
+ const OpaqueValue *ExtendedExistentialTypeMetadata::projectValue (
3982
+ const OpaqueValue *container) const {
3983
+ switch (Shape->Flags .getSpecialKind ()) {
3984
+ case ExtendedExistentialTypeShape::SpecialKind::None: {
3985
+ auto *opaqueContainer =
3986
+ reinterpret_cast <const OpaqueExistentialContainer *>(container);
3987
+ return opaqueContainer->projectValue ();
3988
+ }
3989
+ case ExtendedExistentialTypeShape::SpecialKind::Class: {
3990
+ auto classContainer =
3991
+ reinterpret_cast <const ClassExistentialContainer *>(container);
3992
+ return reinterpret_cast <const OpaqueValue *>(&classContainer->Value );
3993
+ }
3994
+ case ExtendedExistentialTypeShape::SpecialKind::Metatype: {
3995
+ auto *metatypeContainer =
3996
+ reinterpret_cast <const ExistentialMetatypeContainer *>(container);
3997
+ return reinterpret_cast <const OpaqueValue *>(&metatypeContainer->Value );
3998
+ }
3999
+ case ExtendedExistentialTypeShape::SpecialKind::ExplicitLayout:
4000
+ swift_unreachable (" ExplicitLayout not yet handled." );
4001
+ }
4002
+
4003
+ swift_unreachable (" Unhandled ExistentialTypeRepresentation in switch." );
4004
+ }
4005
+
3980
4006
template <> const Metadata *
3981
4007
ExistentialTypeMetadata::getDynamicType (const OpaqueValue *container) const {
3982
4008
switch (getRepresentation ()) {
You can’t perform that action at this time.
0 commit comments