@@ -3777,92 +3777,6 @@ class SequenceExpr final : public Expr,
37773777 }
37783778};
37793779
3780- // / Actor isolation for a closure.
3781- class ClosureActorIsolation {
3782- public:
3783- enum Kind {
3784- // / The closure is not isolated to any actor.
3785- Nonisolated,
3786-
3787- // / The closure is tied to the actor instance described by the given
3788- // / \c VarDecl*, which is the (captured) `self` of an actor.
3789- ActorInstance,
3790-
3791- // / The closure is tied to the global actor described by the given type.
3792- GlobalActor,
3793- };
3794-
3795- private:
3796- // / The actor to which this closure is isolated, plus a bit indicating
3797- // / whether the isolation was imposed by a preconcurrency declaration.
3798- // /
3799- // / There are three possible states for the pointer:
3800- // / - NULL: The closure is independent of any actor.
3801- // / - VarDecl*: The 'self' variable for the actor instance to which
3802- // / this closure is isolated. It will always have a type that conforms
3803- // / to the \c Actor protocol.
3804- // / - Type: The type of the global actor on which
3805- llvm::PointerIntPair<llvm::PointerUnion<VarDecl *, Type>, 1 , bool > storage;
3806-
3807- ClosureActorIsolation (VarDecl *selfDecl, bool preconcurrency)
3808- : storage(selfDecl, preconcurrency) { }
3809- ClosureActorIsolation (Type globalActorType, bool preconcurrency)
3810- : storage(globalActorType, preconcurrency) { }
3811-
3812- public:
3813- ClosureActorIsolation (bool preconcurrency = false )
3814- : storage(nullptr , preconcurrency) { }
3815-
3816- static ClosureActorIsolation forNonisolated (bool preconcurrency) {
3817- return ClosureActorIsolation (preconcurrency);
3818- }
3819-
3820- static ClosureActorIsolation forActorInstance (VarDecl *selfDecl,
3821- bool preconcurrency) {
3822- return ClosureActorIsolation (selfDecl, preconcurrency);
3823- }
3824-
3825- static ClosureActorIsolation forGlobalActor (Type globalActorType,
3826- bool preconcurrency) {
3827- return ClosureActorIsolation (globalActorType, preconcurrency);
3828- }
3829-
3830- // / Determine the kind of isolation.
3831- Kind getKind () const {
3832- if (storage.getPointer ().isNull ())
3833- return Kind::Nonisolated;
3834-
3835- if (storage.getPointer ().is <VarDecl *>())
3836- return Kind::ActorInstance;
3837-
3838- return Kind::GlobalActor;
3839- }
3840-
3841- // / Whether the closure is isolated at all.
3842- explicit operator bool () const {
3843- return getKind () != Kind::Nonisolated;
3844- }
3845-
3846- // / Whether the closure is isolated at all.
3847- operator Kind () const {
3848- return getKind ();
3849- }
3850-
3851- VarDecl *getActorInstance () const {
3852- return storage.getPointer ().dyn_cast <VarDecl *>();
3853- }
3854-
3855- Type getGlobalActor () const {
3856- return storage.getPointer ().dyn_cast <Type>();
3857- }
3858-
3859- bool preconcurrency () const {
3860- return storage.getInt ();
3861- }
3862-
3863- ActorIsolation getActorIsolation () const ;
3864- };
3865-
38663780// / A base class for closure expressions.
38673781class AbstractClosureExpr : public DeclContext , public Expr {
38683782 CaptureInfo Captures;
@@ -3960,29 +3874,6 @@ class AbstractClosureExpr : public DeclContext, public Expr {
39603874 this ->actorIsolation = actorIsolation;
39613875 }
39623876
3963- ClosureActorIsolation getClosureActorIsolation () const {
3964- bool preconcurrency = actorIsolation.preconcurrency ();
3965-
3966- switch (actorIsolation) {
3967- case ActorIsolation::Unspecified:
3968- case ActorIsolation::Nonisolated:
3969- return ClosureActorIsolation::forNonisolated (preconcurrency);
3970-
3971- case ActorIsolation::ActorInstance:
3972- return ClosureActorIsolation::forActorInstance (
3973- actorIsolation.getActorInstance (), preconcurrency);
3974-
3975- case ActorIsolation::GlobalActor:
3976- case ActorIsolation::GlobalActorUnsafe:
3977- return ClosureActorIsolation::forGlobalActor (
3978- actorIsolation.getGlobalActor (), preconcurrency);
3979- }
3980- }
3981-
3982- void setActorIsolation (ClosureActorIsolation closureIsolation) {
3983- this ->actorIsolation = closureIsolation.getActorIsolation ();
3984- }
3985-
39863877 static bool classof (const Expr *E) {
39873878 return E->getKind () >= ExprKind::First_AbstractClosureExpr &&
39883879 E->getKind () <= ExprKind::Last_AbstractClosureExpr;
0 commit comments