File tree Expand file tree Collapse file tree 6 files changed +58
-0
lines changed Expand file tree Collapse file tree 6 files changed +58
-0
lines changed Original file line number Diff line number Diff line change @@ -250,6 +250,8 @@ class ASTBuilder {
250
250
251
251
Type createNegativeIntegerType (intptr_t value);
252
252
253
+ Type createBuiltinFixedArrayType (Type size, Type element);
254
+
253
255
BuiltGenericSignature
254
256
createGenericSignature (ArrayRef<BuiltType> params,
255
257
ArrayRef<BuiltRequirement> requirements);
Original file line number Diff line number Diff line change @@ -1530,6 +1530,23 @@ class TypeDecoder {
1530
1530
return Builder.createNegativeIntegerType ((intptr_t )Node->getIndex ());
1531
1531
}
1532
1532
1533
+ case NodeKind::BuiltinFixedArray: {
1534
+ if (Node->getNumChildren () < 2 )
1535
+ return MAKE_NODE_TYPE_ERROR (Node,
1536
+ " fewer children (%zu) than required (2)" ,
1537
+ Node->getNumChildren ());
1538
+
1539
+ auto size = decodeMangledType (Node->getChild (0 ), depth + 1 );
1540
+ if (size.isError ())
1541
+ return size;
1542
+
1543
+ auto element = decodeMangledType (Node->getChild (1 ), depth + 1 );
1544
+ if (element.isError ())
1545
+ return element;
1546
+
1547
+ return Builder.createBuiltinFixedArrayType (size.getType (), element.getType ());
1548
+ }
1549
+
1533
1550
// TODO: Handle OpaqueReturnType, when we're in the middle of reconstructing
1534
1551
// the defining decl
1535
1552
default :
Original file line number Diff line number Diff line change @@ -933,6 +933,12 @@ class TypeRefBuilder {
933
933
return nullptr ;
934
934
}
935
935
936
+ const TypeRef *createBuiltinFixedArrayType (const TypeRef *size,
937
+ const TypeRef *element) {
938
+ // FIXME: implement
939
+ return nullptr ;
940
+ }
941
+
936
942
// Construct a bound generic type ref along with the parent type info
937
943
// The parent list contains every parent type with at least 1 generic
938
944
// type parameter.
Original file line number Diff line number Diff line change @@ -1065,6 +1065,11 @@ Type ASTBuilder::createNegativeIntegerType(intptr_t value) {
1065
1065
return IntegerType::get (std::to_string (value), /* isNegative*/ true , Ctx);
1066
1066
}
1067
1067
1068
+ Type ASTBuilder::createBuiltinFixedArrayType (Type size, Type element) {
1069
+ return BuiltinFixedArrayType::get (size->getCanonicalType (),
1070
+ element->getCanonicalType ());
1071
+ }
1072
+
1068
1073
GenericSignature
1069
1074
ASTBuilder::createGenericSignature (ArrayRef<BuiltType> builtParams,
1070
1075
ArrayRef<BuiltRequirement> requirements) {
Original file line number Diff line number Diff line change @@ -2454,6 +2454,13 @@ class DecodedMetadataBuilder {
2454
2454
TypeLookupErrorOr<BuiltType> createNegativeIntegerType (intptr_t value) {
2455
2455
return BuiltType (value);
2456
2456
}
2457
+
2458
+ TypeLookupErrorOr<BuiltType> createBuiltinFixedArrayType (BuiltType size,
2459
+ BuiltType element) {
2460
+ return BuiltType (swift_getFixedArrayTypeMetadata (MetadataState::Abstract,
2461
+ size.getValue (),
2462
+ element.getMetadata ()));
2463
+ }
2457
2464
};
2458
2465
2459
2466
}
Original file line number Diff line number Diff line change
1
+ // RUN: %target-swift-frontend %s -emit-ir -g -enable-builtin-module -enable-experimental-feature ValueGenerics -disable-experimental-parser-round-trip -disable-availability-checking -o - | %FileCheck %s
2
+
3
+ import Builtin
4
+
5
+ struct Vector < let N: Int , Element: ~ Copyable> : ~ Copyable {
6
+ let storage : Builtin . FixedArray < N , Element >
7
+ }
8
+
9
+ extension Vector : Copyable where Element: Copyable { }
10
+
11
+ // CHECK-DAG: !DICompositeType({{.*}}name: "Builtin.FixedArray", {{.*}}identifier: "$sxq_BVD"
12
+ func genericBA< let N: Int , Element> ( _: Builtin . FixedArray < N , Element > ) { }
13
+
14
+ // CHECK-DAG: !DICompositeType({{.*}}name: "$s4main6VectorVyxq_GD"
15
+ func genericV< let N: Int , Element> ( _: Vector < N , Element > ) { }
16
+
17
+ // CHECK-DAG: !DICompositeType({{.*}}name: "Builtin.FixedArray", {{.*}}identifier: "$s$4SiBVD"
18
+ func concreteBA( _: Builtin . FixedArray < 4 , Int> ) { }
19
+
20
+ // CHECK-DAG: !DICompositeType({{.*}}name: "$s4main6VectorVy$2SiGD"
21
+ func concreteV( _: Vector < 2 , Int> ) { }
You can’t perform that action at this time.
0 commit comments