@@ -267,18 +267,6 @@ struct ASTContext::Implementation {
267
267
// / -> Builtin.Int1
268
268
FuncDecl *IsOSVersionAtLeastDecl = nullptr ;
269
269
270
- // / func recordArgument(_:) throws
271
- FuncDecl *RecordArgumentDistributedInvocationEncoderDecl = nullptr ;
272
-
273
- // / func recordErrorType(_:) throws
274
- FuncDecl *RecordErrorTypeDistributedInvocationEncoderDecl = nullptr ;
275
-
276
- // / func recordReturnType(_:) throws
277
- FuncDecl *RecordReturnTypeDistributedInvocationEncoderDecl = nullptr ;
278
-
279
- // / func doneRecording() throws
280
- FuncDecl *DoneRecordingDistributedInvocationEncoderDecl = nullptr ;
281
-
282
270
// / The set of known protocols, lazily populated as needed.
283
271
ProtocolDecl *KnownProtocols[NumKnownProtocols] = { };
284
272
@@ -1295,7 +1283,7 @@ AbstractFunctionDecl *ASTContext::getRemoteCallOnDistributedActorSystem(
1295
1283
NominalTypeDecl *actorOrSystem, bool isVoidReturn) const {
1296
1284
assert (actorOrSystem && " distributed actor (or system) decl must be provided" );
1297
1285
const NominalTypeDecl *system = actorOrSystem;
1298
- if (actorOrSystem && actorOrSystem ->isDistributedActor ()) {
1286
+ if (actorOrSystem->isDistributedActor ()) {
1299
1287
auto var = actorOrSystem->getDistributedActorSystemProperty ();
1300
1288
system = var->getInterfaceType ()->getAnyNominal ();
1301
1289
}
@@ -1310,113 +1298,99 @@ AbstractFunctionDecl *ASTContext::getRemoteCallOnDistributedActorSystem(
1310
1298
nullptr );
1311
1299
}
1312
1300
1313
- FuncDecl *ASTContext::getRecordArgumentOnDistributedInvocationEncoder (
1314
- NominalTypeDecl *nominal) const {
1315
- if (getImpl ().RecordArgumentDistributedInvocationEncoderDecl ) {
1316
- return getImpl ().RecordArgumentDistributedInvocationEncoderDecl ;
1301
+ FuncDecl *ASTContext::getMakeInvocationEncoderOnDistributedActorSystem (
1302
+ NominalTypeDecl *actorOrSystem) const {
1303
+ NominalTypeDecl *system = actorOrSystem;
1304
+ assert (actorOrSystem && " distributed actor (or system) decl must be provided" );
1305
+ if (actorOrSystem->isDistributedActor ()) {
1306
+ auto var = actorOrSystem->getDistributedActorSystemProperty ();
1307
+ system = var->getInterfaceType ()->getAnyNominal ();
1317
1308
}
1318
1309
1319
- NominalTypeDecl *encoderProto = nominal ?
1320
- nominal :
1321
- getProtocol (KnownProtocolKind::DistributedTargetInvocationEncoder);
1322
- assert (encoderProto && " Missing DistributedTargetInvocationEncoder protocol" );
1323
- for (auto result : encoderProto->lookupDirect (Id_recordArgument)) {
1310
+ for (auto result : system->lookupDirect (Id_makeInvocationEncoder)) {
1324
1311
auto *fd = dyn_cast<FuncDecl>(result);
1325
1312
if (!fd)
1326
1313
continue ;
1314
+ if (fd->getParameters ()->size () != 0 )
1315
+ continue ;
1316
+ if (fd->hasAsync ())
1317
+ continue ;
1318
+ if (fd->hasThrows ())
1319
+ continue ;
1320
+ // TODO(distributed): more checks, return type etc
1327
1321
1322
+ return fd;
1323
+ }
1324
+
1325
+ return nullptr ;
1326
+ }
1327
+
1328
+ FuncDecl *ASTContext::getRecordArgumentOnDistributedInvocationEncoder (
1329
+ NominalTypeDecl *nominal) const {
1330
+ for (auto result : nominal->lookupDirect (Id_recordArgument)) {
1331
+ auto *fd = dyn_cast<FuncDecl>(result);
1332
+ if (!fd)
1333
+ continue ;
1328
1334
if (fd->getParameters ()->size () != 1 )
1329
1335
continue ;
1330
-
1336
+ if (fd->hasAsync ())
1337
+ continue ;
1338
+ if (!fd->hasThrows ())
1339
+ continue ;
1331
1340
// TODO(distributed): more checks
1332
1341
1333
- if (fd->getResultInterfaceType ()->isVoid () &&
1334
- fd->hasThrows () &&
1335
- !fd->hasAsync ()) {
1336
- getImpl ().RecordArgumentDistributedInvocationEncoderDecl = fd;
1342
+ if (fd->getResultInterfaceType ()->isVoid ())
1337
1343
return fd;
1338
- }
1339
1344
}
1340
1345
1341
1346
return nullptr ;
1342
1347
}
1343
1348
1344
1349
FuncDecl *ASTContext::getRecordErrorTypeOnDistributedInvocationEncoder (
1345
1350
NominalTypeDecl *nominal) const {
1346
- if (getImpl ().RecordErrorTypeDistributedInvocationEncoderDecl ) {
1347
- return getImpl ().RecordErrorTypeDistributedInvocationEncoderDecl ;
1348
- }
1349
-
1350
- NominalTypeDecl *encoderProto =
1351
- nominal
1352
- ? nominal
1353
- : getProtocol (KnownProtocolKind::DistributedTargetInvocationEncoder);
1354
- assert (encoderProto && " Missing DistributedTargetInvocationEncoder protocol" );
1355
- for (auto result : encoderProto->lookupDirect (Id_recordErrorType)) {
1351
+ for (auto result : nominal->lookupDirect (Id_recordErrorType)) {
1356
1352
auto *fd = dyn_cast<FuncDecl>(result);
1357
1353
if (!fd)
1358
1354
continue ;
1359
-
1360
1355
if (fd->getParameters ()->size () != 1 )
1361
1356
continue ;
1357
+ if (fd->hasAsync ())
1358
+ continue ;
1359
+ if (!fd->hasThrows ())
1360
+ continue ;
1361
+ // TODO(distributed): more checks
1362
1362
1363
- // TODO(distributed): more checks that the arg type matches (!!!)
1364
-
1365
- if (fd->getResultInterfaceType ()->isVoid () &&
1366
- fd->hasThrows () &&
1367
- !fd->hasAsync ()) {
1368
- getImpl ().RecordErrorTypeDistributedInvocationEncoderDecl = fd;
1363
+ if (fd->getResultInterfaceType ()->isVoid ())
1369
1364
return fd;
1370
- }
1371
1365
}
1372
1366
1373
1367
return nullptr ;
1374
1368
}
1375
1369
1376
1370
FuncDecl *ASTContext::getRecordReturnTypeOnDistributedInvocationEncoder (
1377
1371
NominalTypeDecl *nominal) const {
1378
- if (getImpl ().RecordReturnTypeDistributedInvocationEncoderDecl ) {
1379
- return getImpl ().RecordReturnTypeDistributedInvocationEncoderDecl ;
1380
- }
1381
-
1382
- NominalTypeDecl *encoderProto =
1383
- nominal
1384
- ? nominal
1385
- : getProtocol (KnownProtocolKind::DistributedTargetInvocationEncoder);
1386
- assert (encoderProto && " Missing DistributedTargetInvocationEncoder protocol" );
1387
- for (auto result : encoderProto->lookupDirect (Id_recordReturnType)) {
1372
+ for (auto result : nominal->lookupDirect (Id_recordReturnType)) {
1388
1373
auto *fd = dyn_cast<FuncDecl>(result);
1389
1374
if (!fd)
1390
1375
continue ;
1391
-
1392
1376
if (fd->getParameters ()->size () != 1 )
1393
1377
continue ;
1378
+ if (fd->hasAsync ())
1379
+ continue ;
1380
+ if (!fd->hasThrows ())
1381
+ continue ;
1382
+ // TODO(distributed): more checks
1394
1383
1395
- // TODO(distributed): more checks that the arg type matches (!!!)
1396
-
1397
- if (fd->getResultInterfaceType ()->isVoid () &&
1398
- fd->hasThrows () &&
1399
- !fd->hasAsync ()) {
1400
- getImpl ().RecordReturnTypeDistributedInvocationEncoderDecl = fd;
1384
+ if (fd->getResultInterfaceType ()->isVoid ())
1401
1385
return fd;
1402
- }
1403
1386
}
1404
1387
1405
1388
return nullptr ;
1406
1389
}
1407
1390
1408
1391
FuncDecl *ASTContext::getDoneRecordingOnDistributedInvocationEncoder (
1409
1392
NominalTypeDecl *nominal) const {
1410
- if (getImpl ().DoneRecordingDistributedInvocationEncoderDecl ) {
1411
- return getImpl ().DoneRecordingDistributedInvocationEncoderDecl ;
1412
- }
1413
-
1414
- NominalTypeDecl *encoderProto =
1415
- nominal
1416
- ? nominal
1417
- : getProtocol (KnownProtocolKind::DistributedTargetInvocationEncoder);
1418
- assert (encoderProto && " Missing DistributedTargetInvocationEncoder protocol" );
1419
- for (auto result : encoderProto->lookupDirect (Id_doneRecording)) {
1393
+ for (auto result : nominal->lookupDirect (Id_doneRecording)) {
1420
1394
auto *fd = dyn_cast<FuncDecl>(result);
1421
1395
if (!fd)
1422
1396
continue ;
@@ -1426,10 +1400,8 @@ FuncDecl *ASTContext::getDoneRecordingOnDistributedInvocationEncoder(
1426
1400
1427
1401
if (fd->getResultInterfaceType ()->isVoid () &&
1428
1402
fd->hasThrows () &&
1429
- !fd->hasAsync ()) {
1430
- getImpl ().DoneRecordingDistributedInvocationEncoderDecl = fd;
1403
+ !fd->hasAsync ())
1431
1404
return fd;
1432
- }
1433
1405
}
1434
1406
1435
1407
return nullptr ;
0 commit comments