@@ -2279,7 +2279,6 @@ class KeyPathPatternComponent {
2279
2279
StoredProperty,
2280
2280
GettableProperty,
2281
2281
SettableProperty,
2282
- External,
2283
2282
OptionalChain,
2284
2283
OptionalForce,
2285
2284
OptionalWrap,
@@ -2298,7 +2297,6 @@ class KeyPathPatternComponent {
2298
2297
enum PackedKind: unsigned {
2299
2298
PackedStored,
2300
2299
PackedComputed,
2301
- PackedExternal,
2302
2300
Unpacked,
2303
2301
};
2304
2302
@@ -2311,8 +2309,6 @@ class KeyPathPatternComponent {
2311
2309
case Kind::GettableProperty:
2312
2310
case Kind::SettableProperty:
2313
2311
return PackedComputed;
2314
- case Kind::External:
2315
- return PackedExternal;
2316
2312
case Kind::OptionalChain:
2317
2313
case Kind::OptionalForce:
2318
2314
case Kind::OptionalWrap:
@@ -2323,23 +2319,18 @@ class KeyPathPatternComponent {
2323
2319
// Value is the VarDecl* for StoredProperty, the SILFunction* of the
2324
2320
// Getter for computed properties, or the Kind for other kinds
2325
2321
llvm::PointerIntPair<void *, KindPackingBits, unsigned > ValueAndKind;
2326
- union {
2327
- // Valid if Kind == GettableProperty || Kind == SettableProperty
2328
- struct {
2329
- llvm::PointerIntPair<SILFunction *, 2 ,
2330
- ComputedPropertyId::KindType> SetterAndIdKind;
2331
- ComputedPropertyId::ValueType IdValue;
2332
- } Computed;
2333
- // Valid if Kind == External
2334
- SubstitutionMap ExternalSubstitutions;
2335
- };
2322
+ llvm::PointerIntPair<SILFunction *, 2 ,
2323
+ ComputedPropertyId::KindType> SetterAndIdKind;
2324
+ ComputedPropertyId::ValueType IdValue;
2336
2325
ArrayRef<Index> Indices;
2337
2326
struct {
2338
2327
SILFunction *Equal;
2339
2328
SILFunction *Hash;
2340
2329
} IndexEquality;
2341
2330
CanType ComponentType;
2342
-
2331
+ AbstractStorageDecl *ExternalStorage;
2332
+ SubstitutionMap ExternalSubstitutions;
2333
+
2343
2334
// / Constructor for stored components
2344
2335
KeyPathPatternComponent (VarDecl *storedProp,
2345
2336
CanType ComponentType)
@@ -2353,26 +2344,18 @@ class KeyPathPatternComponent {
2353
2344
ArrayRef<Index> indices,
2354
2345
SILFunction *indicesEqual,
2355
2346
SILFunction *indicesHash,
2347
+ AbstractStorageDecl *externalStorage,
2348
+ SubstitutionMap externalSubstitutions,
2356
2349
CanType ComponentType)
2357
2350
: ValueAndKind(getter, PackedComputed),
2358
- Computed{{setter, id.Kind }, {id.Value }},
2351
+ SetterAndIdKind{setter, id.Kind },
2352
+ IdValue{id.Value },
2359
2353
Indices (indices),
2360
2354
IndexEquality{indicesEqual, indicesHash},
2361
- ComponentType (ComponentType) {
2362
- }
2363
-
2364
- // / Constructor for external components
2365
- KeyPathPatternComponent (AbstractStorageDecl *externalStorage,
2366
- SubstitutionMap substitutions,
2367
- ArrayRef<Index> indices,
2368
- SILFunction *indicesEqual,
2369
- SILFunction *indicesHash,
2370
- CanType componentType)
2371
- : ValueAndKind(externalStorage, PackedExternal),
2372
- ExternalSubstitutions(substitutions),
2373
- Indices(indices),
2374
- IndexEquality{indicesEqual, indicesHash},
2375
- ComponentType (componentType) {
2355
+ ComponentType (ComponentType),
2356
+ ExternalStorage (externalStorage),
2357
+ ExternalSubstitutions (externalSubstitutions)
2358
+ {
2376
2359
}
2377
2360
2378
2361
// / Constructor for optional components.
@@ -2396,10 +2379,8 @@ class KeyPathPatternComponent {
2396
2379
case PackedStored:
2397
2380
return Kind::StoredProperty;
2398
2381
case PackedComputed:
2399
- return Computed. SetterAndIdKind .getPointer ()
2382
+ return SetterAndIdKind.getPointer ()
2400
2383
? Kind::SettableProperty : Kind::GettableProperty;
2401
- case PackedExternal:
2402
- return Kind::External;
2403
2384
case Unpacked:
2404
2385
return (Kind)((uintptr_t )ValueAndKind.getPointer () >> KindPackingBits);
2405
2386
}
@@ -2418,7 +2399,6 @@ class KeyPathPatternComponent {
2418
2399
case Kind::OptionalChain:
2419
2400
case Kind::OptionalForce:
2420
2401
case Kind::OptionalWrap:
2421
- case Kind::External:
2422
2402
llvm_unreachable (" not a stored property" );
2423
2403
}
2424
2404
llvm_unreachable (" unhandled kind" );
@@ -2430,12 +2410,11 @@ class KeyPathPatternComponent {
2430
2410
case Kind::OptionalChain:
2431
2411
case Kind::OptionalForce:
2432
2412
case Kind::OptionalWrap:
2433
- case Kind::External:
2434
2413
llvm_unreachable (" not a computed property" );
2435
2414
case Kind::GettableProperty:
2436
2415
case Kind::SettableProperty:
2437
- return ComputedPropertyId (Computed. IdValue ,
2438
- Computed. SetterAndIdKind .getInt ());
2416
+ return ComputedPropertyId (IdValue,
2417
+ SetterAndIdKind.getInt ());
2439
2418
}
2440
2419
llvm_unreachable (" unhandled kind" );
2441
2420
}
@@ -2446,7 +2425,6 @@ class KeyPathPatternComponent {
2446
2425
case Kind::OptionalChain:
2447
2426
case Kind::OptionalForce:
2448
2427
case Kind::OptionalWrap:
2449
- case Kind::External:
2450
2428
llvm_unreachable (" not a computed property" );
2451
2429
case Kind::GettableProperty:
2452
2430
case Kind::SettableProperty:
@@ -2462,10 +2440,9 @@ class KeyPathPatternComponent {
2462
2440
case Kind::OptionalChain:
2463
2441
case Kind::OptionalForce:
2464
2442
case Kind::OptionalWrap:
2465
- case Kind::External:
2466
2443
llvm_unreachable (" not a settable computed property" );
2467
2444
case Kind::SettableProperty:
2468
- return Computed. SetterAndIdKind .getPointer ();
2445
+ return SetterAndIdKind.getPointer ();
2469
2446
}
2470
2447
llvm_unreachable (" unhandled kind" );
2471
2448
}
@@ -2479,7 +2456,6 @@ class KeyPathPatternComponent {
2479
2456
return {};
2480
2457
case Kind::GettableProperty:
2481
2458
case Kind::SettableProperty:
2482
- case Kind::External:
2483
2459
return Indices;
2484
2460
}
2485
2461
}
@@ -2491,7 +2467,6 @@ class KeyPathPatternComponent {
2491
2467
case Kind::OptionalForce:
2492
2468
case Kind::OptionalWrap:
2493
2469
llvm_unreachable (" not a computed property" );
2494
- case Kind::External:
2495
2470
case Kind::GettableProperty:
2496
2471
case Kind::SettableProperty:
2497
2472
return IndexEquality.Equal ;
@@ -2504,7 +2479,6 @@ class KeyPathPatternComponent {
2504
2479
case Kind::OptionalForce:
2505
2480
case Kind::OptionalWrap:
2506
2481
llvm_unreachable (" not a computed property" );
2507
- case Kind::External:
2508
2482
case Kind::GettableProperty:
2509
2483
case Kind::SettableProperty:
2510
2484
return IndexEquality.Hash ;
@@ -2519,15 +2493,29 @@ class KeyPathPatternComponent {
2519
2493
}
2520
2494
2521
2495
AbstractStorageDecl *getExternalDecl () const {
2522
- assert (getKind () == Kind::External
2523
- && " not an external property" );
2524
- return (AbstractStorageDecl*)ValueAndKind.getPointer ();
2496
+ switch (getKind ()) {
2497
+ case Kind::StoredProperty:
2498
+ case Kind::OptionalChain:
2499
+ case Kind::OptionalForce:
2500
+ case Kind::OptionalWrap:
2501
+ llvm_unreachable (" not a computed property" );
2502
+ case Kind::GettableProperty:
2503
+ case Kind::SettableProperty:
2504
+ return ExternalStorage;
2505
+ }
2525
2506
}
2526
2507
2527
2508
SubstitutionMap getExternalSubstitutions () const {
2528
- assert (getKind () == Kind::External
2529
- && " not an external property" );
2530
- return ExternalSubstitutions;
2509
+ switch (getKind ()) {
2510
+ case Kind::StoredProperty:
2511
+ case Kind::OptionalChain:
2512
+ case Kind::OptionalForce:
2513
+ case Kind::OptionalWrap:
2514
+ llvm_unreachable (" not a computed property" );
2515
+ case Kind::GettableProperty:
2516
+ case Kind::SettableProperty:
2517
+ return ExternalSubstitutions;
2518
+ }
2531
2519
}
2532
2520
2533
2521
static KeyPathPatternComponent
@@ -2536,10 +2524,14 @@ class KeyPathPatternComponent {
2536
2524
ArrayRef<Index> indices,
2537
2525
SILFunction *indicesEquals,
2538
2526
SILFunction *indicesHash,
2527
+ AbstractStorageDecl *externalDecl,
2528
+ SubstitutionMap externalSubs,
2539
2529
CanType ty) {
2540
2530
return KeyPathPatternComponent (identifier,
2541
2531
getter, nullptr , indices,
2542
- indicesEquals, indicesHash, ty);
2532
+ indicesEquals, indicesHash,
2533
+ externalDecl, externalSubs,
2534
+ ty);
2543
2535
}
2544
2536
2545
2537
static KeyPathPatternComponent
@@ -2549,10 +2541,14 @@ class KeyPathPatternComponent {
2549
2541
ArrayRef<Index> indices,
2550
2542
SILFunction *indicesEquals,
2551
2543
SILFunction *indicesHash,
2544
+ AbstractStorageDecl *externalDecl,
2545
+ SubstitutionMap externalSubs,
2552
2546
CanType ty) {
2553
2547
return KeyPathPatternComponent (identifier,
2554
2548
getter, setter, indices,
2555
- indicesEquals, indicesHash, ty);
2549
+ indicesEquals, indicesHash,
2550
+ externalDecl, externalSubs,
2551
+ ty);
2556
2552
}
2557
2553
2558
2554
static KeyPathPatternComponent
@@ -2568,23 +2564,11 @@ class KeyPathPatternComponent {
2568
2564
case Kind::StoredProperty:
2569
2565
case Kind::GettableProperty:
2570
2566
case Kind::SettableProperty:
2571
- case Kind::External:
2572
2567
llvm_unreachable (" not an optional kind" );
2573
2568
}
2574
2569
return KeyPathPatternComponent (kind, ty);
2575
2570
}
2576
2571
2577
- static KeyPathPatternComponent
2578
- forExternal (AbstractStorageDecl *externalDecl,
2579
- SubstitutionMap substitutions,
2580
- ArrayRef<Index> indices,
2581
- SILFunction *indicesEquals,
2582
- SILFunction *indicesHash,
2583
- CanType ty) {
2584
- return KeyPathPatternComponent (externalDecl, substitutions,
2585
- indices, indicesEquals, indicesHash, ty);
2586
- }
2587
-
2588
2572
void incrementRefCounts () const ;
2589
2573
void decrementRefCounts () const ;
2590
2574
0 commit comments