@@ -612,7 +612,23 @@ layout is as follows:
612
612
613
613
* For an enum:
614
614
615
- + TODO: Offsets 2-5 are always zero.
615
+ + The **number of payload cases ** and **payload size offset ** are stored
616
+ at **offset 2 **. The least significant 24 bits are the number of payload
617
+ cases, and the most significant 8 bits are the offset of the payload
618
+ size in the type metadata, if present.
619
+ + The **number of no-payload cases ** is stored at **offset 3 **.
620
+ + The **case names ** are referenced as a doubly-null-terminated list of
621
+ C strings at **offset 4 **. The names are ordered such that payload cases
622
+ come first, followed by no-payload cases. Within each half of the list,
623
+ the order of names corresponds to the order of cases in the enum
624
+ declaration.
625
+ + The **case type accessor ** is a function pointer at **offset 5 **. If
626
+ non-null, the function takes a pointer to an instance of type metadata
627
+ for the enum, and returns a pointer to an array of type metadata
628
+ references for the types of the cases of that instance. The order matches
629
+ that of the case name list. This function is similar to the field type
630
+ accessor for a struct, except also the least significant bit of each
631
+ element in the result is set if the enum case is an **indirect case **.
616
632
617
633
- If the nominal type is generic, a pointer to the **metadata pattern ** that
618
634
is used to form instances of the type is stored at **offset 6 **. The pointer
@@ -1047,6 +1063,8 @@ the outermost depth::
1047
1063
Value Witnesses
1048
1064
~~~~~~~~~~~~~~~
1049
1065
1066
+ TODO: document these
1067
+
1050
1068
::
1051
1069
1052
1070
value-witness-kind ::= 'al' // allocateBuffer
@@ -1065,11 +1083,11 @@ Value Witnesses
1065
1083
value-witness-kind ::= 'pr' // projectBuffer
1066
1084
value-witness-kind ::= 'xs' // storeExtraInhabitant
1067
1085
value-witness-kind ::= 'xg' // getExtraInhabitantIndex
1068
- value-witness-kind ::= 'ug' // getEnumTag
1069
- value-witness-kind ::= 'up' // inplaceProjectEnumData
1070
1086
value-witness-kind ::= 'Cc' // initializeArrayWithCopy
1071
1087
value-witness-kind ::= 'Tt' // initializeArrayWithTakeFrontToBack
1072
1088
value-witness-kind ::= 'tT' // initializeArrayWithTakeBackToFront
1089
+ value-witness-kind ::= 'ug' // getEnumTag
1090
+ value-witness-kind ::= 'up' // destructiveProjectEnumData
1073
1091
1074
1092
``<value-witness-kind> `` differentiates the kinds of value
1075
1093
witness functions for a type.
0 commit comments