@@ -111,7 +111,7 @@ deriveBodyTensorArrayProtocol_unpackTensorHandles(
111
111
tensorArrayProto, C.Id_tensorHandleCount );
112
112
113
113
Type intType = C.getIntDecl ()->getDeclaredType ();
114
- TypeExpr *intTE = TypeExpr::createImplicit (intType, C);
114
+ TypeExpr *intTypeExpr = TypeExpr::createImplicit (intType, C);
115
115
116
116
// Iterate through the `TensorArrayProtocol`-conforming members and call
117
117
// `member._unpackTensorHandles(into:)`.
@@ -144,11 +144,8 @@ deriveBodyTensorArrayProtocol_unpackTensorHandles(
144
144
// Obtain the method call argument.
145
145
auto *addressDRE = new (C) DeclRefExpr (
146
146
currAddressDecl, DeclNameLoc (), /* implicit*/ true );
147
- auto *loadExpr = new (C) LoadExpr (addressDRE, baseAddressType);
148
- auto *injectExpr = new (C) InjectIntoOptionalExpr (loadExpr, addressType);
149
-
150
- auto *callExpr = CallExpr::createImplicit (
151
- C, memberMethodExpr, {injectExpr}, {C.getIdentifier (" into" )});
147
+ auto *callExpr = CallExpr::createImplicit (C, memberMethodExpr, {addressDRE},
148
+ {C.getIdentifier (" into" )});
152
149
153
150
// Advance the current address.
154
151
DeclName advancedName (C, C.getIdentifier (" advanced" ),
@@ -170,9 +167,9 @@ deriveBodyTensorArrayProtocol_unpackTensorHandles(
170
167
// Cast the tensor handle count to Int.
171
168
auto intInitName = DeclName (C, DeclBaseName::createConstructor (),
172
169
{Identifier ()});
173
- auto *intInitExpr =
174
- new (C) UnresolvedDotExpr (intTE , SourceLoc (), DeclNameRef (intInitName),
175
- DeclNameLoc (), /* Implicit*/ true );
170
+ auto *intInitExpr = new (C)
171
+ UnresolvedDotExpr (intTypeExpr , SourceLoc (), DeclNameRef (intInitName),
172
+ DeclNameLoc (), /* Implicit*/ true );
176
173
auto *intInitCallExpr = CallExpr::createImplicit (
177
174
C, intInitExpr, {memberCountMRE}, {Identifier ()});
178
175
@@ -276,16 +273,15 @@ deriveBodyTensorArrayProtocol_tensorHandleCount(AbstractFunctionDecl *funcDecl,
276
273
277
274
// Concatenate all member `_tensorHandleCount`s.
278
275
Type intType = C.getInt32Decl ()->getDeclaredType ();
279
- TypeExpr *intTE = TypeExpr::createImplicit (intType, C);
276
+ TypeExpr *intTypeExpr = TypeExpr::createImplicit (intType, C);
280
277
auto plusOpLookup = C.getInt32Decl ()->lookupDirect (C.getIdentifier (" +" ));
281
278
assert (plusOpLookup.size () == 1 && " Ambiguous 'Int32.+' operator." );
282
279
ValueDecl *plusOpDecl = plusOpLookup.front ();
283
- auto plusOpDRE = new (C)
284
- DeclRefExpr (plusOpDecl, DeclNameLoc (), /* Implicit*/ true );
285
- auto plusOpExpr = new (C) DotSyntaxCallExpr (plusOpDRE, SourceLoc (), intTE);
286
280
Expr *tensorHandleCountExpr = new (C)
287
281
IntegerLiteralExpr (" 0" , SourceLoc (), /* implicit*/ true );
288
282
for (auto member : nominal->getStoredProperties ()) {
283
+ auto plusOpExpr = new (C) MemberRefExpr (
284
+ intTypeExpr, SourceLoc (), plusOpDecl, DeclNameLoc (), /* Implicit*/ true );
289
285
auto *memberDRE = new (C) MemberRefExpr (
290
286
selfDRE, SourceLoc (), member, DeclNameLoc (), /* Implicit*/ true );
291
287
auto *memberTensorHandleCountExpr = new (C)
@@ -360,12 +356,11 @@ deriveBodyTensorArrayProtocol_typeList(AbstractFunctionDecl *funcDecl, void *) {
360
356
auto plusOpLookup = C.getArrayDecl ()->lookupDirect (C.getIdentifier (" +" ));
361
357
assert (plusOpLookup.size () == 1 && " Ambiguous 'Array.+' operator." );
362
358
ValueDecl *plusOpDecl = plusOpLookup.front ();
363
- auto plusOpDRE = new (C)
364
- DeclRefExpr (plusOpDecl, DeclNameLoc (), /* Implicit*/ true );
365
- auto plusOpExpr = new (C)
366
- DotSyntaxCallExpr (plusOpDRE, SourceLoc (), arrayTypeExpr);
367
359
Expr *typeListExpr = ArrayExpr::create (C, SourceLoc (), {}, {}, SourceLoc ());
368
360
for (auto member : nominal->getStoredProperties ()) {
361
+ auto *plusOpExpr =
362
+ new (C) MemberRefExpr (arrayTypeExpr, SourceLoc (), plusOpDecl,
363
+ DeclNameLoc (), /* Implicit*/ true );
369
364
auto memberType =
370
365
parentDC->mapTypeIntoContext (member->getValueInterfaceType ());
371
366
auto *memberTypeExpr = TypeExpr::createImplicit (memberType, C);
@@ -436,7 +431,7 @@ deriveBodyTensorArrayProtocol_init(AbstractFunctionDecl *funcDecl, void *) {
436
431
C.getUnsafePointerDecl (), Type (), {cTensorHandleType});
437
432
auto addressType = BoundGenericType::get (
438
433
C.getOptionalDecl (), Type (), {baseAddressType});
439
- auto *addressTE = TypeExpr::createImplicit (addressType, C);
434
+ auto *addressTypeExpr = TypeExpr::createImplicit (addressType, C);
440
435
441
436
// Get references to `self` and parameter declarations.
442
437
auto *selfDecl = funcDecl->getImplicitSelfDecl ();
@@ -474,7 +469,7 @@ deriveBodyTensorArrayProtocol_init(AbstractFunctionDecl *funcDecl, void *) {
474
469
tensorArrayProto, C.Id_tensorHandleCount );
475
470
476
471
Type intType = C.getIntDecl ()->getDeclaredType ();
477
- TypeExpr *intTE = TypeExpr::createImplicit (intType, C);
472
+ TypeExpr *intTypeExpr = TypeExpr::createImplicit (intType, C);
478
473
479
474
// Iterate over members and call `self.member = MemberType(_owning:)`.
480
475
llvm::SmallVector<ASTNode, 2 > thenMemberExprs;
@@ -507,22 +502,15 @@ deriveBodyTensorArrayProtocol_init(AbstractFunctionDecl *funcDecl, void *) {
507
502
508
503
auto *addressDRE = new (C) DeclRefExpr (
509
504
currAddressDecl, DeclNameLoc (), /* implicit*/ true );
510
- auto *loadExpr = new (C) LoadExpr (addressDRE, baseAddressType);
511
-
512
- // Initialize the member using its `TensorGroup` constructor.
513
- // Note that, initialization is dependent on the branch of the
514
- // if-statement taken.
515
- auto *thenInitExpr = new (C) InjectIntoOptionalExpr (loadExpr, addressType);
516
505
auto *thenInitCallExpr = CallExpr::createImplicit (
517
- C, memberInitExpr, {thenInitExpr }, {C.getIdentifier (" _owning" )});
506
+ C, memberInitExpr, {addressDRE }, {C.getIdentifier (" _owning" )});
518
507
519
508
// Create a nil expression with type `UnsafePointer<CTensorHandle>?` for the
520
509
// `else` branch.
521
510
auto *nilDecl = C.getOptionalNoneDecl ();
522
- auto *nilDRE = new (C) DeclRefExpr (
523
- nilDecl, DeclNameLoc (), /* implicit*/ true );
524
- auto *elseInitExpr = new (C) DotSyntaxCallExpr (
525
- nilDRE, SourceLoc (), addressTE);
511
+ auto *elseInitExpr =
512
+ new (C) MemberRefExpr (addressTypeExpr, SourceLoc (), nilDecl,
513
+ DeclNameLoc (), /* Implicit*/ true );
526
514
auto *elseInitCallExpr = CallExpr::createImplicit (
527
515
C, memberInitExpr, {elseInitExpr}, {C.getIdentifier (" _owning" )});
528
516
@@ -558,9 +546,9 @@ deriveBodyTensorArrayProtocol_init(AbstractFunctionDecl *funcDecl, void *) {
558
546
// Cast the tensor handle count to Int.
559
547
auto intInitName = DeclName (C, DeclBaseName::createConstructor (),
560
548
{Identifier ()});
561
- auto *intInitExpr =
562
- new (C) UnresolvedDotExpr (intTE , SourceLoc (), DeclNameRef (intInitName),
563
- DeclNameLoc (), /* Implicit*/ true );
549
+ auto *intInitExpr = new (C)
550
+ UnresolvedDotExpr (intTypeExpr , SourceLoc (), DeclNameRef (intInitName),
551
+ DeclNameLoc (), /* Implicit*/ true );
564
552
auto *intInitCallExpr = CallExpr::createImplicit (
565
553
C, intInitExpr, {memberCountMRE}, {Identifier ()});
566
554
0 commit comments