@@ -38,21 +38,6 @@ using namespace Lowering;
38
38
39
39
// MARK: utility functions
40
40
41
- // / Obtain a nominal type's member by name, as a VarDecl.
42
- // / \returns nullptr if the name lookup doesn't resolve to exactly one member,
43
- // / or the subsequent cast to VarDecl failed.
44
- static VarDecl* lookupProperty (NominalTypeDecl *decl, DeclName name) {
45
- assert (decl && " decl was null" );
46
- if (auto clazz = dyn_cast<ClassDecl>(decl)) {
47
- auto refs = decl->lookupDirect (name);
48
- if (refs.size () != 1 )
49
- return nullptr ;
50
- return dyn_cast<VarDecl>(refs.front ());
51
- }
52
-
53
- return nullptr ;
54
- }
55
-
56
41
// / Emit a reference to a specific stored property of the actor.
57
42
static SILValue emitActorPropertyReference (
58
43
SILGenFunction &SGF, SILLocation loc, SILValue actorSelf,
@@ -186,7 +171,7 @@ static void emitActorSystemInit(SILGenFunction &SGF,
186
171
// By construction, automatically generated distributed actor ctors have
187
172
// exactly one ActorSystem-conforming argument to the constructor,
188
173
// so we grab the first one from the params.
189
- VarDecl *var = lookupProperty ( classDecl, C. Id_actorSystem );
174
+ VarDecl *var = classDecl-> getDistributedActorSystemProperty ( );
190
175
assert (var);
191
176
192
177
initializeProperty (SGF, loc, actorSelf.getValue (), var, systemValue);
@@ -219,7 +204,7 @@ void SILGenFunction::emitDistActorIdentityInit(ConstructorDecl *ctor,
219
204
220
205
// --- create a temporary storage for the result of the call
221
206
// it will be deallocated automatically as we exit this scope
222
- VarDecl *var = lookupProperty ( classDecl, C. Id_id );
207
+ VarDecl *var = classDecl-> getDistributedActorIDProperty ( );
223
208
auto resultTy = getLoweredType (F.mapTypeIntoContext (var->getInterfaceType ()));
224
209
auto temp = emitTemporaryAllocation (loc, resultTy);
225
210
@@ -332,7 +317,7 @@ void SILGenFunction::emitDistributedActorReady(
332
317
ManagedValue actorSystem;
333
318
SGFContext sgfCxt;
334
319
{
335
- VarDecl *property = lookupProperty ( classDecl, C. Id_actorSystem );
320
+ VarDecl *property = classDecl-> getDistributedActorSystemProperty ( );
336
321
Type formalType = F.mapTypeIntoContext (property->getInterfaceType ());
337
322
SILType loweredType = getLoweredType (formalType).getAddressType ();
338
323
SILValue actorSystemRef = emitActorPropertyReference (
@@ -466,11 +451,11 @@ void SILGenFunction::emitDistributedActorFactory(FuncDecl *fd) { // TODO(distrib
466
451
auto classDecl = dc->getSelfClassDecl ();
467
452
468
453
initializeProperty (*this , loc, remote,
469
- lookupProperty ( classDecl, C. Id_id ),
454
+ classDecl-> getDistributedActorIDProperty ( ),
470
455
idArg);
471
456
472
457
initializeProperty (*this , loc, remote,
473
- lookupProperty ( classDecl, C. Id_actorSystem ),
458
+ classDecl-> getDistributedActorSystemProperty ( ),
474
459
actorSystemArg);
475
460
476
461
// ==== Branch to return the fully initialized remote instance
@@ -513,12 +498,12 @@ void SILGenFunction::emitDistributedActorSystemResignIDCall(
513
498
514
499
// ==== locate: self.id
515
500
auto idRef = emitActorPropertyReference (
516
- *this , loc, actorSelf.getValue (), lookupProperty ( actorDecl, ctx. Id_id ));
501
+ *this , loc, actorSelf.getValue (), actorDecl-> getDistributedActorIDProperty ( ));
517
502
518
503
// ==== locate: self.actorSystem
519
504
auto systemRef = emitActorPropertyReference (
520
505
*this , loc, actorSelf.getValue (),
521
- lookupProperty ( actorDecl, ctx. Id_actorSystem ));
506
+ actorDecl-> getDistributedActorSystemProperty ( ));
522
507
523
508
// Perform the call.
524
509
emitDistributedActorSystemWitnessCall (
0 commit comments