Commits

Slava Pestov committed 48c928938a1
Reflection: Single-payload enum layout Attempt to lay out single-payload enums, using knowledge of extra inhabitants where possible. - The extra inhabitants of an aggregate are the extra inhabitants of the first field. If the first field is empty, there are no extra inhabitants, and subsequent fields do not affect anything. - Function pointers and metatypes have different extra inhabitants than Builtin.RawPointer, so have IRGen emit distinct builtin type descriptors for those. - Opaque existentials do not have extra inhabitants. - Weak references do not have extra inhabitants. Also, fix IRGen to emit more accurate enum reflection metadata in these two cases: - We now record whether enum cases are indirect or not. An indirect case is the same as a payload case with Builtin.NativeObject. - We now record whether a case is empty or not using the same logic as the rest of IRGen. Previously, we would incorrectly emit a payload type for a case with a payload that is an empty struct, for example. At this point we don't have a way to get the currently inhabited enum case from a value. However, this is still an improvement because we can still reflect other fields of aggregates containing enums, instead of just giving up. Finally make some methods on TypeCoverter private, and use 'friend' to allow them to be accessed from other internal classes, making the public API simpler.