public override DefType ComputeHomogeneousFloatAggregateElementType(DefType type) { if (!type.IsHfa) { return(null); } if (type.IsWellKnownType(WellKnownType.Double) || type.IsWellKnownType(WellKnownType.Single)) { return(type); } for (;;) { Debug.Assert(type.IsValueType); // All HFA fields have to be of the same HFA type, so we can just return the type of the first field TypeDesc firstFieldType = null; foreach (var field in type.GetFields()) { if (field.IsStatic) { continue; } firstFieldType = field.FieldType; break; } Debug.Assert(firstFieldType != null, "Why is IsHfa true on this type?"); switch (firstFieldType.Category) { case TypeFlags.Single: case TypeFlags.Double: return((DefType)firstFieldType); case TypeFlags.ValueType: // Drill into the struct and find the type of its first field type = (DefType)firstFieldType; break; default: Debug.Assert(false, "Why is IsHfa true on this type?"); return(null); } } }
public override DefType ComputeHomogeneousFloatAggregateElementType(DefType type) { if (!type.IsHfa) return null; if (type.IsWellKnownType(WellKnownType.Double) || type.IsWellKnownType(WellKnownType.Single)) return type; for (;;) { Debug.Assert(type.IsValueType); // All HFA fields have to be of the same HFA type, so we can just return the type of the first field TypeDesc firstFieldType = null; foreach (var field in type.GetFields()) { if (field.IsStatic) continue; firstFieldType = field.FieldType; break; } Debug.Assert(firstFieldType != null, "Why is IsHfa true on this type?"); switch (firstFieldType.Category) { case TypeFlags.Single: case TypeFlags.Double: return (DefType)firstFieldType; case TypeFlags.ValueType: // Drill into the struct and find the type of its first field type = (DefType)firstFieldType; break; default: Debug.Assert(false, "Why is IsHfa true on this type?"); return null; } } }