|
36 | 36 | #include "Explosion.h" |
37 | 37 | #include "IndirectTypeInfo.h" |
38 | 38 | #include "NonFixedTypeInfo.h" |
| 39 | +#include "ResilientTypeInfo.h" |
39 | 40 |
|
40 | 41 | #include "GenTuple.h" |
41 | 42 |
|
|
44 | 45 | using namespace swift; |
45 | 46 | using namespace irgen; |
46 | 47 |
|
| 48 | +namespace { |
| 49 | + /// A type implementation for tuple types with a dynamic number of |
| 50 | + /// elements, that is, that contain pack expansion types. For now, |
| 51 | + /// these are completely abstract. |
| 52 | + class DynamicTupleTypeInfo |
| 53 | + : public ResilientTypeInfo<DynamicTupleTypeInfo> |
| 54 | + { |
| 55 | + public: |
| 56 | + DynamicTupleTypeInfo(llvm::Type *T, |
| 57 | + IsCopyable_t copyable) |
| 58 | + : ResilientTypeInfo(T, copyable, IsABIAccessible) {} |
| 59 | + |
| 60 | + TypeLayoutEntry |
| 61 | + *buildTypeLayoutEntry(IRGenModule &IGM, |
| 62 | + SILType T, |
| 63 | + bool useStructLayouts) const override { |
| 64 | + return IGM.typeLayoutCache.getOrCreateResilientEntry(T); |
| 65 | + } |
| 66 | + }; |
| 67 | +} // end anonymous namespace |
| 68 | + |
| 69 | +const TypeInfo * |
| 70 | +TypeConverter::convertDynamicTupleType(IsCopyable_t copyable) { |
| 71 | + llvm::Type *storageType = IGM.OpaqueTy; |
| 72 | + return new DynamicTupleTypeInfo(storageType, copyable); |
| 73 | +} |
| 74 | + |
47 | 75 | namespace { |
48 | 76 | class TupleFieldInfo : public RecordField<TupleFieldInfo> { |
49 | 77 | public: |
@@ -488,6 +516,11 @@ namespace { |
488 | 516 | } // end anonymous namespace |
489 | 517 |
|
490 | 518 | const TypeInfo *TypeConverter::convertTupleType(TupleType *tuple) { |
| 519 | + if (tuple->containsPackExpansionType()) { |
| 520 | + // FIXME: Figure out if its copyable at least |
| 521 | + return &getDynamicTupleTypeInfo(IsCopyable); |
| 522 | + } |
| 523 | + |
491 | 524 | TupleTypeBuilder builder(IGM, SILType::getPrimitiveAddressType(CanType(tuple))); |
492 | 525 | return builder.layout(tuple->getElements()); |
493 | 526 | } |
|
0 commit comments