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 @@ -3980,6 +3980,32 @@ ExistentialTypeMetadata::projectValue(const OpaqueValue *container) const {
3980
3980
" Unhandled ExistentialTypeRepresentation in switch." );
3981
3981
}
3982
3982
3983
+ template <>
3984
+ const OpaqueValue *ExtendedExistentialTypeMetadata::projectValue (
3985
+ const OpaqueValue *container) const {
3986
+ switch (Shape->Flags .getSpecialKind ()) {
3987
+ case ExtendedExistentialTypeShape::SpecialKind::None: {
3988
+ auto *opaqueContainer =
3989
+ reinterpret_cast <const OpaqueExistentialContainer *>(container);
3990
+ return opaqueContainer->projectValue ();
3991
+ }
3992
+ case ExtendedExistentialTypeShape::SpecialKind::Class: {
3993
+ auto classContainer =
3994
+ reinterpret_cast <const ClassExistentialContainer *>(container);
3995
+ return reinterpret_cast <const OpaqueValue *>(&classContainer->Value );
3996
+ }
3997
+ case ExtendedExistentialTypeShape::SpecialKind::Metatype: {
3998
+ auto *metatypeContainer =
3999
+ reinterpret_cast <const ExistentialMetatypeContainer *>(container);
4000
+ return reinterpret_cast <const OpaqueValue *>(&metatypeContainer->Value );
4001
+ }
4002
+ case ExtendedExistentialTypeShape::SpecialKind::ExplicitLayout:
4003
+ swift_unreachable (" ExplicitLayout not yet handled." );
4004
+ }
4005
+
4006
+ swift_unreachable (" Unhandled ExistentialTypeRepresentation in switch." );
4007
+ }
4008
+
3983
4009
template <> const Metadata *
3984
4010
ExistentialTypeMetadata::getDynamicType (const OpaqueValue *container) const {
3985
4011
switch (getRepresentation ()) {
You can’t perform that action at this time.
0 commit comments